<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>hosts &#8211; スグブログ</title>
	<atom:link href="https://sugublog.org/tag/hosts/feed/" rel="self" type="application/rss+xml" />
	<link>https://sugublog.org</link>
	<description>ブログ運営について発信中</description>
	<lastBuildDate>Mon, 13 May 2024 13:27:04 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://sugublog.org/wp-content/uploads/2021/07/icon_20210703-min-150x150.png</url>
	<title>hosts &#8211; スグブログ</title>
	<link>https://sugublog.org</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>【Linux】hostsファイルの設定する！反映するタイミングなど</title>
		<link>https://sugublog.org/linux-hosts/</link>
					<comments>https://sugublog.org/linux-hosts/?noamp=mobile#respond</comments>
		
		<dc:creator><![CDATA[suguru]]></dc:creator>
		<pubDate>Mon, 13 May 2024 15:00:00 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[サーバ]]></category>
		<category><![CDATA[hosts]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[名前解決]]></category>
		<guid isPermaLink="false">https://sugublog.org/?p=6769</guid>

					<description><![CDATA[<p><img src="https://sugublog.org/wp-content/uploads/2021/09/moving_09268-1024x640.jpg" class="webfeedsFeaturedVisual" /></p>Linuxでhostsファイルの設定方法などを教えます。 またhostsファイルの設定、編集して反映するタイミングや確認方法などを現役エンジニアの筆者が教えます。 簡単に名前解決できる、Linuxサーバーのhostsファ [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><img src="https://sugublog.org/wp-content/uploads/2021/09/moving_09268-1024x640.jpg" class="webfeedsFeaturedVisual" /></p>
<p>Linuxで<strong><span class="swl-inline-color has-swl-deep-01-color">hostsファイルの設定方法</span></strong>などを教えます。</p>



<p>また<strong>hostsファイルの設定</strong>、<strong>編集して反映するタイミング</strong>や<strong>確認方法</strong>などを現役エンジニアの筆者が教えます。</p>


<div class="p-blogParts post_content" data-partsID="5908">
<p>筆者はWindowsサーバーやLinuxサーバーの運用構築を11年間以上おこなってきました。その経験を元に知識を公開していきます！</p>
</div>


<p>簡単に名前解決できる、<strong><span class="swl-inline-color has-swl-deep-01-color">Linuxサーバーのhostsファイルの設定</span></strong>をマスターできます。</p>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle ads" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-9330904718533231" data-ad-slot="6086594686"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<h2 class="wp-block-heading">Linuxサーバーでhostsファイルの設定する</h2>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img decoding="async" width="1024" height="770" src="https://sugublog.org/wp-content/uploads/2021/12/PC教室20211216-2-1024x770.jpg" alt="Linuxサーバーのhostsファイル" class="wp-image-4805" srcset="https://sugublog.org/wp-content/uploads/2021/12/PC教室20211216-2-1024x770.jpg 1024w, https://sugublog.org/wp-content/uploads/2021/12/PC教室20211216-2-300x226.jpg 300w, https://sugublog.org/wp-content/uploads/2021/12/PC教室20211216-2-768x577.jpg 768w, https://sugublog.org/wp-content/uploads/2021/12/PC教室20211216-2.jpg 1200w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p><span class="swl-marker mark_orange"><strong>hostsファイル</strong>は<strong>一番優先順位が高い名前解決方法</strong>です。</span></p>



<p>Linuxサーバーのローカルにあるのでviエディタで設定できます。</p>



<h3 class="wp-block-heading">hostsファイルの設定方法</h3>



<p><strong><span class="swl-inline-color has-swl-deep-01-color">hostsファイルの設定方法</span></strong>は以下の通りです。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>IPアドレス 名前</code></pre></div>



<p>IPアドレスと対応する名前を記述すれば良いだけです。</p>



<h3 class="wp-block-heading">hostsファイルの場所について</h3>



<p>Linuxサーバーで<strong><span class="swl-inline-color has-swl-deep-02-color">hostsファイルの場所</span></strong>はどこにあるのでしょうか？</p>



<p>findコマンドで検索して場所を探してみます。</p>


<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://sugublog.org/wp-content/uploads/2021/07/analytics-1-300x200.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://sugublog.org/linux-find-file-search/">【Linux】findコマンドでファイル検索する方法</a>
						<span class="p-blogCard__excerpt">Linuxでファイル検索するfindコマンドについて説明します。 ファイル名を指定して検索や再帰的に検索、全ディレクトリを対象に検索するといった方法も実例を用いて説明&#8230;</span>					</div>
				</div>
			</div>
		</div>


<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>[root@localhost ~]# find /etc -name hosts
/etc/hosts</code></pre></div>



<p class="has-border -border01"><strong>hostsファイル</strong>は<strong>「/etc/hosts」</strong>の場所にありました。</p>



<p>このファイルをviエディタで編集します。</p>


<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://sugublog.org/wp-content/uploads/2021/06/search-min-1-e1623599919108-300x180.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://sugublog.org/linux-vi-how-to-use/">【Linux】viの使い方！必須のコマンドから作業効率出来るコマンドまで</a>
						<span class="p-blogCard__excerpt">今回はLinuxサーバーのviエディタの使い方です Linuxsサーバーを使用していて、通常使用するテキストエディタはviエディタです。 しかしviエディタは癖が強く使いにくい&#8230;</span>					</div>
				</div>
			</div>
		</div>


<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.1 router</code></pre></div>



<p>最終行に「192.168.0.1 router」の行を追加しました。</p>



<p class="is-style-icon_book">「127.0.0.1」と「::1」はデフォルトの設定でLinuxサーバー自身を表します。</p>



<p>これで<strong><span class="swl-inline-color has-swl-deep-01-color">hostsファイルを保存</span></strong>してviエディタを終了します。</p>


<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://sugublog.org/wp-content/uploads/2021/06/rocket0627-300x200.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://sugublog.org/linux-vi-how-to-quit/">【Linux】viで終了のやり方！保存して終了や保存しないで保存の方法</a>
						<span class="p-blogCard__excerpt">Linuxを使用していて、viエディタの終了のやり方が分からなくなる時があります。 そんな時の為にviの終了のやり方を、現役エンジニアの筆者がまとめます。 保存して終了&#8230;</span>					</div>
				</div>
			</div>
		</div>


<h3 class="wp-block-heading">hostsファイルの反映のタイミング</h3>



<p><strong>hostsファイル</strong>の<strong>反映のタイミング</strong>は<strong>設定保存した直後</strong>です。</p>



<p>再起動など必要ありません。</p>



<p class="is-style-big_icon_caution">hostsファイルを保存したタイミングで、設定をミスすると通信が出来なくなる場合があるので注意してください。</p>



<h3 class="wp-block-heading">hostsファイルの確認方法</h3>



<p>先程設定した<span class="swl-marker mark_orange"><strong><span class="swl-inline-color has-swl-deep-01-color">hostsファイルの設定が反映</span></strong>しているか、pingコマンドで<strong>確認</strong>してみます。</span></p>


<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://sugublog.org/wp-content/uploads/2021/12/PC教室20211216-3-300x232.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://sugublog.org/linux-ping/">【Linux】pingの使い方！オプションでポート指定して疎通確認を行う</a>
						<span class="p-blogCard__excerpt">Linuxサーバーでpingコマンドの使い方についてまとめます。 相手先のポートが開いているか確認する為に、ポートを指定してPingを行いたい。 Pingの回数を指定して行いた&#8230;</span>					</div>
				</div>
			</div>
		</div>


<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>[root@localhost ~]# ping -c 4 router
PING router (192.168.0.1) 56(84) bytes of data.
64 bytes from router (192.168.0.1): icmp_seq=1 ttl=64 time=12.6 ms
64 bytes from router (192.168.0.1): icmp_seq=2 ttl=64 time=7.13 ms
64 bytes from router (192.168.0.1): icmp_seq=3 ttl=64 time=5.22 ms
64 bytes from router (192.168.0.1): icmp_seq=4 ttl=64 time=3.63 ms

--- router ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3019ms
rtt min/avg/max/mdev = 3.639/7.161/12.650/3.401 ms</code></pre></div>



<p class="has-border -border01">pingコマンドで<span class="swl-marker mark_orange"><strong><span class="swl-inline-color has-swl-deep-01-color">hostsファイルに設定した「router」を指定</span></strong>すれば、IPアドレス(192.168.0.1)と疎通する事が出来ました。</span></p>



<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-9330904718533231"
     crossorigin="anonymous"></script>
<ins class="adsbygoogle"
     style="display:block"
     data-ad-format="autorelaxed"
     data-ad-client="ca-pub-9330904718533231"
     data-ad-slot="8455594968"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<h2 class="wp-block-heading">まとめ：Linuxサーバーでhostsファイルの設定</h2>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img decoding="async" width="1024" height="683" src="https://sugublog.org/wp-content/uploads/2021/09/moving_0926-2-1024x683.jpg" alt="Linuxサーバーのhostsファイル" class="wp-image-4208" srcset="https://sugublog.org/wp-content/uploads/2021/09/moving_0926-2-1024x683.jpg 1024w, https://sugublog.org/wp-content/uploads/2021/09/moving_0926-2-300x200.jpg 300w, https://sugublog.org/wp-content/uploads/2021/09/moving_0926-2-768x512.jpg 768w, https://sugublog.org/wp-content/uploads/2021/09/moving_0926-2.jpg 1200w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p><strong><span class="swl-inline-color has-swl-deep-01-color">hostsファイルの設定方法</span></strong>は以下の通りです。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>IPアドレス 名前</code></pre></div>



<p><span class="swl-inline-color has-swl-deep-02-color"><strong>hostsファイルの場所</strong></span>は以下です。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>/etc/hosts</code></pre></div>



<p><strong><span class="swl-inline-color has-swl-deep-01-color">hostsファイルの反映のタイミング</span></strong>は<span class="swl-inline-color has-swl-deep-01-color">保存した直後</span>です。</p>



<p><strong><span class="swl-inline-color has-swl-deep-01-color">hostsファイルの確認方法</span></strong>は、<span class="swl-inline-color has-swl-deep-01-color">pingで指定した名前で疎通できるか確認</span>すればOKです。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sugublog.org/linux-hosts/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
