<?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>ping &#8211; スグブログ</title>
	<atom:link href="https://sugublog.org/tag/ping/feed/" rel="self" type="application/rss+xml" />
	<link>https://sugublog.org</link>
	<description>ブログ運営について発信中</description>
	<lastBuildDate>Sun, 02 Jun 2024 07:26:29 +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>ping &#8211; スグブログ</title>
	<link>https://sugublog.org</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>【Linux】pingの使い方！オプションでポート指定して疎通確認を行う</title>
		<link>https://sugublog.org/linux-ping/</link>
					<comments>https://sugublog.org/linux-ping/?noamp=mobile#respond</comments>
		
		<dc:creator><![CDATA[suguru]]></dc:creator>
		<pubDate>Tue, 07 May 2024 15:00:00 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[サーバ]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ping]]></category>
		<guid isPermaLink="false">https://sugublog.org/?p=6722</guid>

					<description><![CDATA[<p><img src="https://sugublog.org/wp-content/uploads/2021/12/PC教室20211216-3-1024x791.jpg" class="webfeedsFeaturedVisual" /></p>Linuxサーバーでpingコマンドの使い方についてまとめます。 相手先のポートが開いているか確認する為に、ポートを指定してPingを行いたい。 Pingの回数を指定して行いたい。などと言った事もあると思います。 Pin [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><img src="https://sugublog.org/wp-content/uploads/2021/12/PC教室20211216-3-1024x791.jpg" class="webfeedsFeaturedVisual" /></p>
<p>Linuxサーバーで<strong><span class="swl-inline-color has-swl-deep-01-color">pingコマンドの使い方</span></strong>についてまとめます。</p>



<p>相手先のポートが開いているか確認する為に、ポートを指定してPingを行いたい。</p>



<p>Pingの回数を指定して行いたい。などと言った事もあると思います。</p>



<p><span class="swl-marker mark_orange"><strong><span class="swl-inline-color has-swl-deep-01-color">Pingの基礎のやり方からオプションまで</span></strong>を、現役エンジニアの筆者が実例を踏まえて説明します。</span></p>


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


<p><span class="swl-marker mark_orange"><strong>Linuxサーバー</strong>の<strong>Ping</strong>について全て理解でき、効率よく疎通確認などが出来る様になります。</span></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サーバーでpingの使い方</h2>


<div class="wp-block-image is-style-photo_frame">
<figure class="aligncenter size-large"><img decoding="async" width="1024" height="522" src="https://sugublog.org/wp-content/uploads/2021/11/Server_20211109-10-1024x522.jpg" alt="疎通" class="wp-image-4417" srcset="https://sugublog.org/wp-content/uploads/2021/11/Server_20211109-10-1024x522.jpg 1024w, https://sugublog.org/wp-content/uploads/2021/11/Server_20211109-10-300x153.jpg 300w, https://sugublog.org/wp-content/uploads/2021/11/Server_20211109-10-768x392.jpg 768w, https://sugublog.org/wp-content/uploads/2021/11/Server_20211109-10.jpg 1200w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>Linuxサーバーで<span class="swl-marker mark_orange"><strong>インターネットの接続や他のサーバーや端末などの疎通確認する場合</strong>に、<strong><span class="swl-inline-color has-swl-deep-01-color">Pingコマンドを</span></strong>使用します。</span></p>



<p class="is-style-icon_book">その他のコマンドでインターネット接続の確認する方法は、以下の記事を参照下さい。</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/09/code_0923-1-300x198.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-internet-connect-check/">【Linux】インターネット接続の確認方法！コマンドをご紹介</a>
						<span class="p-blogCard__excerpt">Linuxサーバーでインターネット接続の確認方法をまとめます。 Linuxサーバー構築でインターネット接続が出来ない事も多いので、確認のやり方を現役エンジニアの筆者がま&#8230;</span>					</div>
				</div>
			</div>
		</div>


<p>Pingの使い方については、pingコマンドの後にIPアドレスかURLを指定します。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>ping IPアドレスもしくはURL</code></pre></div>



<p>これで指定したIPアドレスかURLに疎通性があるか確認できます。</p>



<p class="is-style-icon_announce">停止する場合はCtrl+Cで可能です。</p>



<h2 class="wp-block-heading">Linuxサーバーでpingのオプション</h2>


<div class="wp-block-image is-style-photo_frame">
<figure class="aligncenter size-large"><img decoding="async" width="1024" height="576" src="https://sugublog.org/wp-content/uploads/2021/11/DB_1103-2-1024x576.jpg" alt="オプション" class="wp-image-4331" srcset="https://sugublog.org/wp-content/uploads/2021/11/DB_1103-2-1024x576.jpg 1024w, https://sugublog.org/wp-content/uploads/2021/11/DB_1103-2-300x169.jpg 300w, https://sugublog.org/wp-content/uploads/2021/11/DB_1103-2-768x432.jpg 768w, https://sugublog.org/wp-content/uploads/2021/11/DB_1103-2.jpg 1200w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<h3 class="wp-block-heading">Linuxサーバーでpingのオプション一覧まとめ</h3>



<p>pingの使い方で紹介したものは基本で、<strong><span class="swl-inline-color has-swl-deep-01-color">オプション</span></strong>も使用する事が可能です。</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>オプション</th><th>効果</th></tr></thead><tbody><tr><td>-c 回数</td><td>指定した回数だけPingパケットを送信</td></tr><tr><td>-i 秒数</td><td>指定した秒数だけ間隔を空けてPingパケット送信</td></tr><tr><td>-s</td><td>Pingのパケットサイズを指定する</td></tr><tr><td>-q</td><td>Pingの統計のみ表示する</td></tr><tr><td>-w 秒数</td><td>Pingを終了する時間を指定する</td></tr><tr><td>-4 IPv4アドレス</td><td>IPv4でPingを行う</td></tr><tr><td>-6 IPv6アドレス</td><td>IPv6でPingを行う</td></tr><tr><td>-p</td><td>パターンを指定してPingパケット送信</td></tr><tr><td>-t</td><td>TTLを指定してPingパケット送信</td></tr></tbody></table><figcaption class="wp-element-caption">LinuxサーバでのPingコマンドオプション一覧</figcaption></figure>



<h3 class="wp-block-heading">指定した回数だけPingパケットを送信</h3>



<p>LinuxサーバーのPingコマンドは永遠に打ち続けます。<strong><span class="swl-inline-color has-swl-deep-01-color"><span class="swl-marker mark_orange">cオプションでPingの回数を指定</span></span></strong>できます。</p>



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

--- 192.168.0.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3022ms
rtt min/avg/max/mdev = 7.196/11.744/18.147/4.482 ms</code></pre></div>



<p class="has-border -border01">4回のPingで終了しています。</p>



<h3 class="wp-block-heading">指定した秒数だけ間隔を空けてPingパケット送信</h3>



<p>LinuxサーバーのPingコマンドは1秒ごとにPingを打ちます。<strong><span class="swl-inline-color has-swl-deep-01-color"><span class="swl-marker mark_orange">iオプションでPingの間隔を指定</span></span></strong>できます。</p>



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

--- 192.168.0.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 9029ms
rtt min/avg/max/mdev = 3.026/8.085/15.405/4.771 ms</code></pre></div>



<p class="has-border -border01">1秒から3秒間隔でPingを打っていますので、「time」欄が先程の3倍になっています。</p>



<h3 class="wp-block-heading">Pingのパケットサイズを指定する</h3>



<p>LinuxサーバーのPingコマンドは64バイトのPingを打ちます。<strong><span class="swl-inline-color has-swl-deep-01-color"><span class="swl-marker mark_orange">sオプションでPingのバイト数を指定</span></span></strong>できます。</p>



<p class="is-style-icon_info">※8バイト＋指定したバイト数になります。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>[root@localhost ~]# ping -c 4 -s 8 192.168.0.1
PING 192.168.0.1 (192.168.0.1) 8(36) bytes of data.
16 bytes from 192.168.0.1: icmp_seq=1 ttl=64
16 bytes from 192.168.0.1: icmp_seq=2 ttl=64
16 bytes from 192.168.0.1: icmp_seq=3 ttl=64
16 bytes from 192.168.0.1: icmp_seq=4 ttl=64

--- 192.168.0.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3017ms</code></pre></div>



<p class="has-border -border01">サイズを8バイト指定しましたので8+8で16バイトのPingを打っています。「64 bytes」の表記が「16 bytes」になりました。</p>



<p class="is-style-icon_info">※バイトが小さすぎてtimeの欄がありません。24バイト以上になるとtimeの欄が現れます。</p>



<h3 class="wp-block-heading">Pingの統計のみ表示する</h3>



<p>LinuxサーバーのPingコマンドは1つのPingごとの結果の後に統計が表示されます。<strong><span class="swl-inline-color has-swl-deep-01-color">qオプションで統計のみ表示</span></strong>できます。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>[root@localhost ~]# ping -c 4 -q 192.168.0.1
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.

--- 192.168.0.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3007ms
rtt min/avg/max/mdev = 3.213/6.845/11.182/3.370 ms</code></pre></div>



<p class="has-border -border01">Ping単体の結果がなく統計のみ表示されています。</p>



<h3 class="wp-block-heading">Pingを終了する時間を指定する</h3>



<p>LinuxサーバーのPingコマンドはCtrl+Cで終了するか、cオプションで指定した回数が終了するまでPingします。<strong><span class="swl-inline-color has-swl-deep-01-color">wオプションで終了時間を秒数で指定</span></strong>できます。</p>



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

--- 192.168.0.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2014ms
rtt min/avg/max/mdev = 7.424/12.586/17.477/4.108 ms</code></pre></div>



<p class="has-border -border01">Pingの回数を4回と指定していますが、wオプションで3秒と指定しているので3回で終了しています。</p>



<p class="is-style-icon_info">Ping1回はデフォルト1秒なので3秒で終了している事になります。</p>



<h3 class="wp-block-heading">パターンを指定してPingパケット送信</h3>



<p><strong><span class="swl-inline-color has-swl-deep-01-color">Pingコマンドのpオプション</span></strong>で、<strong><span class="swl-inline-color has-swl-deep-01-color">指定した16進数のデータを送信する事</span></strong>が可能です。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>[root@localhost ~]# ping -c 4 -p 4F3B2A 192.168.0.1
PATTERN: 0x4f3b2a
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=11.2 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=64 time=7.50 ms
64 bytes from 192.168.0.1: icmp_seq=3 ttl=64 time=5.81 ms
64 bytes from 192.168.0.1: icmp_seq=4 ttl=64 time=3.11 ms

--- 192.168.0.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3020ms
rtt min/avg/max/mdev = 3.111/6.908/11.203/2.933 ms</code></pre></div>



<p class="has-border -border01">PATTERNの欄が追加されて、指定したデータをPingしています。</p>



<p class="is-style-icon_info">パターンの前の「0x」は16進数を表します。</p>



<h3 class="wp-block-heading">TTLを指定してPingパケット送信</h3>



<p><strong><span class="swl-inline-color has-swl-deep-01-color">Pingコマンドのtオプション</span></strong>で、<strong><span class="swl-inline-color has-swl-deep-01-color">指定したTTLでPingする事</span></strong>が可能です。</p>



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

--- 192.168.0.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2009ms
rtt min/avg/max/mdev = 5.396/9.850/15.850/4.406 ms</code></pre></div>



<p>一つ先のルータにはPingが疎通していますが、、、</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>[root@localhost ~]# ping -c 3 -t 3 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
From 10.1.193.4 icmp_seq=1 Time to live exceeded
From 10.1.193.4 icmp_seq=2 Time to live exceeded
From 10.1.193.4 icmp_seq=3 Time to live exceeded

--- 8.8.8.8 ping statistics ---
3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 2011ms</code></pre></div>



<p>グーグルのDNSには「Time to live exceeded」となり、Ping疎通できませんでした。</p>



<p class="has-border -border01">指定したTTL以上離れている機器にはPing疎通できません。TTLより下の機器にはPing疎通できました。</p>



<h2 class="wp-block-heading">pingでポートを指定して疎通確認する方法</h2>


<div class="wp-block-image is-style-photo_frame">
<figure class="aligncenter size-large"><img decoding="async" width="1024" height="633" src="https://sugublog.org/wp-content/uploads/2021/09/junp2_0907-2-1024x633.jpg" alt="ポート指定して疎通" class="wp-image-4150" srcset="https://sugublog.org/wp-content/uploads/2021/09/junp2_0907-2-1024x633.jpg 1024w, https://sugublog.org/wp-content/uploads/2021/09/junp2_0907-2-300x186.jpg 300w, https://sugublog.org/wp-content/uploads/2021/09/junp2_0907-2-768x475.jpg 768w, https://sugublog.org/wp-content/uploads/2021/09/junp2_0907-2.jpg 1200w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>

<div class="swell-block-balloon"><div class="c-balloon -bln-left" data-col="blue"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://sugublog.org/wp-content/uploads/2021/02/cropped-dog003-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://sugublog.org/wp-content/uploads/2021/02/cropped-dog003-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">疑問を持つエンジニア</span></div><div class="c-balloon__body -thinking -border-on"><div class="c-balloon__text">
<p>pingでポートを指定して送信したいです。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<p>相手先のサーバーで<strong>ポートが開いているか確認する為</strong>に、<strong><span class="swl-inline-color has-swl-deep-01-color">ポートを指定してPingを行いたい</span></strong>と思った事はないでしょうか？</p>



<p class="is-style-icon_book">自分自身のLinuxサーバーのポートが開いているか確認するやり方は以下の記事を参照してください。</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/plugin-min-e1623592189322-300x212.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-check-for-open-ports/">【Linux基礎】開いているポート番号を確認するコマンド</a>
						<span class="p-blogCard__excerpt">Linuxで何のポートが開いているか調べたい時はどうすれば良いでしょうか？ LinuxでSSHやFTPの接続ができません。調査として開いているポートを確認したいです。どうすれ&#8230;</span>					</div>
				</div>
			</div>
		</div>


<p class="is-style-icon_bad">しかしデフォルトのPingコマンドにはポート指定するオプションはないです。</p>



<p>そこでnpingコマンドを使用します。</p>



<p class="is-style-icon_book">npingコマンドがない場合は、以下の記事を参照してパッケージをインストールします。</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/10/mask10282-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-command-find-not/">【Linux】CentOSで「コマンドが見つかりません」となった時の対処法</a>
						<span class="p-blogCard__excerpt">Linuxサーバーを運用していてコマンドを打とうとしたら「コマンドが見つかりません」と表示されました。インターネットで見る限りありそうなコマンドなのですが、なぜ私&#8230;</span>					</div>
				</div>
			</div>
		</div>


<p>npingでポートを指定して疎通確認するコマンドは以下となります。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>nping --tcp 相手先IPアドレス -p ボート番号</code></pre></div>



<p>npingの実行結果です。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>[root@localhost ~]# nping --tcp 192.168.0.1 -p 8080

Starting Nping 0.6.40 ( http://nmap.org/nping ) at 2024-05-06 14:35 JST
SENT (0.0036s) TCP 192.168.0.4:51925 &gt; 192.168.0.1:8080 S ttl=64 id=423 iplen=40  seq=131012984 win=1480
RCVD (0.2058s) TCP 192.168.0.1:8080 &gt; 192.168.0.4:51925 RA ttl=64 id=38056 iplen=40  seq=0 win=0
SENT (1.0058s) TCP 192.168.0.4:51925 &gt; 192.168.0.1:8080 S ttl=64 id=423 iplen=40  seq=131012984 win=1480
RCVD (1.2119s) TCP 192.168.0.1:8080 &gt; 192.168.0.4:51925 RA ttl=64 id=38113 iplen=40  seq=0 win=0
SENT (2.0085s) TCP 192.168.0.4:51925 &gt; 192.168.0.1:8080 S ttl=64 id=423 iplen=40  seq=131012984 win=1480
RCVD (2.0209s) TCP 192.168.0.1:8080 &gt; 192.168.0.4:51925 RA ttl=64 id=38200 iplen=40  seq=0 win=0
SENT (3.0107s) TCP 192.168.0.4:51925 &gt; 192.168.0.1:8080 S ttl=64 id=423 iplen=40  seq=131012984 win=1480
RCVD (3.0293s) TCP 192.168.0.1:8080 &gt; 192.168.0.4:51925 RA ttl=64 id=38201 iplen=40  seq=0 win=0
SENT (4.0166s) TCP 192.168.0.4:51925 &gt; 192.168.0.1:8080 S ttl=64 id=423 iplen=40  seq=131012984 win=1480
RCVD (4.0369s) TCP 192.168.0.1:8080 &gt; 192.168.0.4:51925 RA ttl=64 id=38240 iplen=40  seq=0 win=0

Max rtt: 205.800ms | Min rtt: 12.204ms | Avg rtt: 91.705ms
Raw packets sent: 5 (200B) | Rcvd: 5 (230B) | Lost: 0 (0.00%)
Nping done: 1 IP address pinged in 4.04 seconds</code></pre></div>


<div class="swell-block-balloon"><div class="c-balloon -bln-left" data-col="red"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://sugublog.org/wp-content/uploads/2021/02/cropped-dog003-150x150.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://sugublog.org/wp-content/uploads/2021/02/cropped-dog003-150x150.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">疑問を持つエンジニア</span></div><div class="c-balloon__body -thinking -border-on"><div class="c-balloon__text">
<p>結果がよくわかりません。。。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<p class="has-border -border02">宛先のポートが開いているか調査したい場合は、Pingではなくnmapを使用しましょう！</p>



<p>nmapでポートが開いているか確認するコマンドは以下です。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>nmap -p ポート番号 宛先IP</code></pre></div>



<p>では実際ポートが開いているか確認してみます。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>[root@localhost ~]# nmap -p 22 192.168.0.1

Starting Nmap 6.40 ( http://nmap.org ) at 2024-05-06 14:43 JST
Nmap scan report for dsldevice.lan (192.168.0.1)
Host is up (0.0081s latency).
PORT   STATE  SERVICE
22/tcp closed ssh
MAC Address: E4:DA:DF:CE:C4:88 (Unknown)

Nmap done: 1 IP address (1 host up) scanned in 0.56 seconds</code></pre></div>



<p>22番ポートのsshは「closed」となっており、閉じています。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>[root@localhost ~]# nmap -p 80 192.168.0.1

Starting Nmap 6.40 ( http://nmap.org ) at 2024-05-06 14:44 JST
Nmap scan report for dsldevice.lan (192.168.0.1)
Host is up (0.0046s latency).
PORT   STATE SERVICE
80/tcp open  http
MAC Address: E4:DA:DF:CE:C4:88 (Unknown)

Nmap done: 1 IP address (1 host up) scanned in 0.51 seconds</code></pre></div>



<p>80番ポートのhttpは「open」となっており、開いています。</p>



<p class="has-border -border01">pingでポートを指定して疎通確認する方法はなく、nmapコマンドで代用しましょう！</p>



<h2 class="wp-block-heading">Linuxサーバーでpingが通らない時の原因と対処法</h2>


<div class="wp-block-image is-style-photo_frame">
<figure class="aligncenter size-large"><img decoding="async" width="1024" height="683" src="https://sugublog.org/wp-content/uploads/2021/06/shutterstock_1433996435-min-1024x683.jpg" alt="エラー" class="wp-image-2885"/></figure>
</div>


<p><strong><span class="swl-inline-color has-swl-deep-01-color">Pingが通らない時の原因</span></strong>はいくつかあります。</p>



<div class="swell-block-capbox cap_box is-style-onborder_ttl"><div class="cap_box_ttl"><span>Pingが通らない時の原因</span></div><div class="cap_box_content">
<ul class="wp-block-list">
<li>そもそも疎通ができていない</li>



<li>Firewallなどで止められている</li>
</ul>
</div></div>



<p>Pingが通らない時の原因でそもそも<span class="swl-bg-color has-swl-deep-01-background-color">疎通が出来ない状態の場合</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/09/code_0923-1-300x198.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-internet-connect-check/">【Linux】インターネット接続の確認方法！コマンドをご紹介</a>
						<span class="p-blogCard__excerpt">Linuxサーバーでインターネット接続の確認方法をまとめます。 Linuxサーバー構築でインターネット接続が出来ない事も多いので、確認のやり方を現役エンジニアの筆者がま&#8230;</span>					</div>
				</div>
			</div>
		</div>


<p>どこまでのルータまでは通信できているなど、<span class="swl-bg-color has-swl-deep-01-background-color">Pingの相手先までの経路を表示</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/07/pixta_77773496_M-e1626536234619-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-traceroute/">【Linux】tracerouteの使い方！オプションなどもご紹介</a>
						<span class="p-blogCard__excerpt">Linuxサーバーでtracerouteの使い方を教えて欲しいです。オプションなども含めて使い方を見てみたい そういったエンジニアの疑問に、現役エンジニアの筆者が答えます。 &#8230;</span>					</div>
				</div>
			</div>
		</div>


<p><span class="swl-bg-color has-swl-deep-01-background-color">firewallが原因の場合</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/07/security007-2-300x187.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/centos-firewall-addport-active-inactive/">【Linux】CentOSでfirewallの使い方！ポート開放や有効無効の確認方法</a>
						<span class="p-blogCard__excerpt">CentOSを立ち上げていざサービスを使って通信しようとするけど失敗してイライラすることはないでしょうか？ 早くサービス使いたいのに。。と CentOSでサービス早く使い&#8230;</span>					</div>
				</div>
			</div>
		</div>


<h2 class="wp-block-heading">まとめ：Linuxサーバーでpingの使い方</h2>


<div class="wp-block-image is-style-photo_frame">
<figure class="aligncenter size-large"><img decoding="async" width="1024" height="522" src="https://sugublog.org/wp-content/uploads/2021/11/Server_20211109-11-1024x522.jpg" alt="サーバー" class="wp-image-4418" srcset="https://sugublog.org/wp-content/uploads/2021/11/Server_20211109-11-1024x522.jpg 1024w, https://sugublog.org/wp-content/uploads/2021/11/Server_20211109-11-300x153.jpg 300w, https://sugublog.org/wp-content/uploads/2021/11/Server_20211109-11-768x392.jpg 768w, https://sugublog.org/wp-content/uploads/2021/11/Server_20211109-11.jpg 1200w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<h3 class="wp-block-heading">Linuxサーバーでpingの使い方の基礎</h3>



<p><strong><span class="swl-inline-color has-swl-deep-01-color">LinuxサーバーのPingの使い方</span></strong>については、pingコマンドの後にIPアドレスかURLを指定します。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>ping IPアドレスもしくはURL</code></pre></div>



<p class="is-style-icon_announce">停止する場合はCtrl+Cで可能です。</p>



<h3 class="wp-block-heading">Linuxサーバーでpingのオプションについて</h3>



<p><strong><span class="swl-inline-color has-swl-deep-01-color">pingのオプション</span></strong>について以下にまとめます。</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>オプション</th><th>効果</th></tr></thead><tbody><tr><td>-c 回数</td><td>指定した回数だけPingパケットを送信</td></tr><tr><td>-i 秒数</td><td>指定した秒数だけ間隔を空けてPingパケット送信</td></tr><tr><td>-s</td><td>Pingのパケットサイズを指定する</td></tr><tr><td>-q</td><td>Pingの統計のみ表示する</td></tr><tr><td>-w 秒数</td><td>Pingを終了する時間を指定する</td></tr><tr><td>-4 IPv4アドレス</td><td>IPv4でPingを行う</td></tr><tr><td>-6 IPv6アドレス</td><td>IPv6でPingを行う</td></tr><tr><td>-p</td><td>パターンを指定してPingパケット送信</td></tr><tr><td>-t</td><td>TTLを指定してPingパケット送信</td></tr></tbody></table><figcaption class="wp-element-caption">LinuxサーバでのPingコマンドオプション一覧</figcaption></figure>



<h3 class="wp-block-heading">pingでポートを指定して送信するには</h3>



<p><span class="swl-marker mark_orange"><strong><span class="swl-inline-color has-swl-deep-01-color">pingではポート指定はできない</span></strong>ので、<strong><span class="swl-inline-color has-swl-deep-01-color">npingのパッケージをインストールして送信</span></strong>する。</span></p>



<p class="has-border -border01">結果が分かりにくいので「nmap」コマンドで代用する！</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>nmap -p ポート番号 宛先IP</code></pre></div>



<h3 class="wp-block-heading">Linuxサーバーでpingが通らない時の原因と対処法</h3>



<div class="swell-block-capbox cap_box is-style-onborder_ttl"><div class="cap_box_ttl"><span>Pingが通らない時の原因</span></div><div class="cap_box_content">
<ul class="wp-block-list">
<li>そもそも疎通ができていない</li>



<li>Firewallなどで止められている</li>
</ul>
</div></div>



<p>Pingが通らない時の原因でそもそも<span class="swl-bg-color has-swl-deep-01-background-color">疎通が出来ない状態の場合</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/09/code_0923-1-300x198.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-internet-connect-check/">【Linux】インターネット接続の確認方法！コマンドをご紹介</a>
						<span class="p-blogCard__excerpt">Linuxサーバーでインターネット接続の確認方法をまとめます。 Linuxサーバー構築でインターネット接続が出来ない事も多いので、確認のやり方を現役エンジニアの筆者がま&#8230;</span>					</div>
				</div>
			</div>
		</div>


<p><span class="swl-bg-color has-swl-deep-01-background-color">firewallが原因の場合</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/07/security007-2-300x187.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/centos-firewall-addport-active-inactive/">【Linux】CentOSでfirewallの使い方！ポート開放や有効無効の確認方法</a>
						<span class="p-blogCard__excerpt">CentOSを立ち上げていざサービスを使って通信しようとするけど失敗してイライラすることはないでしょうか？ 早くサービス使いたいのに。。と CentOSでサービス早く使い&#8230;</span>					</div>
				</div>
			</div>
		</div>]]></content:encoded>
					
					<wfw:commentRss>https://sugublog.org/linux-ping/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
