linux的ping命令設(shè)置時(shí)間間隔
Linux下ping命令可以設(shè)置每次ping的時(shí)間間隔。下面由學(xué)習(xí)啦小編為大家整理了linux下ping命令設(shè)置時(shí)間間隔的相關(guān)知識(shí),希望對(duì)大家有幫助!
linux的ping命令設(shè)置時(shí)間間隔詳解
ping命令用來(lái)測(cè)試主機(jī)之間網(wǎng)絡(luò)的連通性。
(1)用法:
用法: ping [參數(shù)] [主機(jī)名或IP地址]
(2)功能:
功能: 確定網(wǎng)絡(luò)和各外部主機(jī)的狀態(tài);跟蹤和隔離硬件和軟件問(wèn)題;測(cè)試、評(píng)估和管理網(wǎng)絡(luò)。
細(xì)節(jié): 執(zhí)行ping指令會(huì)使用ICMP傳輸協(xié)議,發(fā)出要求回應(yīng)的信息,若遠(yuǎn)端主機(jī)的網(wǎng)絡(luò)功能沒有問(wèn)題,就會(huì)回應(yīng)該信息,因而得知該主機(jī)運(yùn)作正常。例如: “ping一下某機(jī)器,看是不是開著”、不能打開網(wǎng)頁(yè)時(shí)“先ping網(wǎng)關(guān)地址192.168.1.1試試”。ping 命令每秒發(fā)送一個(gè)數(shù)據(jù)報(bào)并且為每個(gè)接收到的響應(yīng)打印一行輸出。ping 命令計(jì)算信號(hào)往返時(shí)間和(信息)包丟失情況的統(tǒng)計(jì)信息,并且在完成之后顯示一個(gè)簡(jiǎn)要總結(jié)。ping 命令在程序超時(shí)或當(dāng)接收到 SIGINT 信號(hào)時(shí)結(jié)束。Host 參數(shù)或者是一個(gè)有效的主機(jī)名或者是因特網(wǎng)地址。
注意: 有些服務(wù)器為了防止通過(guò)ping探測(cè)到,通過(guò)防火墻設(shè)置了禁止ping或者在內(nèi)核參數(shù)中禁止ping,這樣就不能通過(guò)ping確定該主機(jī)是否還處于開啟狀態(tài)。
(3)選項(xiàng)參數(shù):
1) -b n: 測(cè)試與網(wǎng)關(guān)IP的連通性
2) -c n: 執(zhí)行指定次數(shù) n的ping命令
3) -i n: 設(shè)定間隔幾秒送一個(gè)網(wǎng)絡(luò)封包給一臺(tái)機(jī)器,預(yù)設(shè)值是一秒送一次。
4) -s 字節(jié)數(shù): 指定發(fā)送的數(shù)據(jù)字節(jié)數(shù),預(yù)設(shè)值是56,加上8字節(jié)的ICMP頭,一共是64ICMP數(shù)據(jù)字節(jié)。
5) -t 存活數(shù)值: 設(shè)置存活數(shù)值TTL的大小。
linux的ping命令設(shè)置時(shí)間間隔和參數(shù)限制實(shí)例
1)[root@localhost ~]# ping -c 10 -i 0.5 192.168.120.206
[root@localhost ~]# ping -c 10 -i 0.5 192.168.120.206
PING 192.168.120.206 (192.168.120.206) 56(84) bytes of data.
bytes from 192.168.120.206: icmp_seq=1 ttl=64 time=1.24 ms
bytes from 192.168.120.206: icmp_seq=2 ttl=64 time=0.235 ms
bytes from 192.168.120.206: icmp_seq=3 ttl=64 time=0.244 ms
bytes from 192.168.120.206: icmp_seq=4 ttl=64 time=0.300 ms
bytes from 192.168.120.206: icmp_seq=5 ttl=64 time=0.255 ms
bytes from 192.168.120.206: icmp_seq=6 ttl=64 time=0.264 ms
bytes from 192.168.120.206: icmp_seq=7 ttl=64 time=0.263 ms
bytes from 192.168.120.206: icmp_seq=8 ttl=64 time=0.331 ms
bytes from 192.168.120.206: icmp_seq=9 ttl=64 time=0.247 ms
bytes from 192.168.120.206: icmp_seq=10 ttl=64 time=0.244 ms
--- 192.168.120.206 ping statistics ---
packets transmitted, 10 received, 0% packet loss, time 4499ms
rtt min/avg/max/mdev = 0.235/0.362/1.241/0.294 ms
[root@localhost ~]# ping -c 10 -i 0.01 192.168.120.206
PING 192.168.120.206 (192.168.120.206) 56(84) bytes of data.
bytes from 192.168.120.206: icmp_seq=1 ttl=64 time=0.244 ms
bytes from 192.168.120.206: icmp_seq=2 ttl=64 time=0.195 ms
bytes from 192.168.120.206: icmp_seq=3 ttl=64 time=0.219 ms
bytes from 192.168.120.206: icmp_seq=4 ttl=64 time=0.204 ms
bytes from 192.168.120.206: icmp_seq=5 ttl=64 time=3.56 ms
bytes from 192.168.120.206: icmp_seq=6 ttl=64 time=1.93 ms
bytes from 192.168.120.206: icmp_seq=7 ttl=64 time=0.193 ms
bytes from 192.168.120.206: icmp_seq=8 ttl=64 time=0.193 ms
bytes from 192.168.120.206: icmp_seq=9 ttl=64 time=0.202 ms
bytes from 192.168.120.206: icmp_seq=10 ttl=64 time=0.211 ms
--- 192.168.120.206 ping statistics ---
packets transmitted, 10 received, 0% packet loss, time 90ms
rtt min/avg/max/mdev = 0.193/0.716/3.564/1.080 ms
[root@localhost ~]#