2024年3月29日 星期五

Linux ping report no answer

Linux ping 預設不會印出無回應的狀況,只要加上 -O 就可以了,就跟 Windows ping 差不多
有掉包的話比較清楚

# ping -O 192.168.1.8
PING 192.168.1.8 (192.168.1.8) 56(84) bytes of data.
64 bytes from 192.168.1.8: icmp_seq=1 ttl=64 time=0.347 ms
64 bytes from 192.168.1.8: icmp_seq=2 ttl=64 time=0.237 ms
no answer yet for icmp_seq=3
no answer yet for icmp_seq=4
64 bytes from 192.168.1.8: icmp_seq=5 ttl=64 time=0.224 ms
64 bytes from 192.168.1.8: icmp_seq=6 ttl=64 time=0.213 ms

再加 -D 參數可以在前面印出時間,可惜是 UNIX timestamp 格式,不方便直接讀取

# ping -DO 192.168.1.8
PING 192.168.1.8 (192.168.1.8) 56(84) bytes of data.
[1711724576.274247] 64 bytes from 192.168.1.8: icmp_seq=1 ttl=64 time=0.254 ms
[1711724577.288744] 64 bytes from 192.168.1.8: icmp_seq=2 ttl=64 time=0.225 ms
[1711724578.312747] 64 bytes from 192.168.1.8: icmp_seq=3 ttl=64 time=0.220 ms

若要在前面加入時間,推薦用 ts,在 moreutils 套件內,它是個 Perl 腳本,可搭配任何程式使用

# ping -O 192.168.1.8 | ts
Mar 29 23:08:25 PING 192.168.1.8 (192.168.1.8) 56(84) bytes of data.
Mar 29 23:08:25 64 bytes from 192.168.1.8: icmp_seq=1 ttl=64 time=0.257 ms
Mar 29 23:08:26 64 bytes from 192.168.1.8: icmp_seq=2 ttl=64 time=0.239 ms
Mar 29 23:08:27 64 bytes from 192.168.1.8: icmp_seq=3 ttl=64 time=0.240 ms








沒有留言:

OpenVPN disconnect after 3.4.0

如果 OpenVPN 本來都連線正常,Server 也沒動,OpenVPN Client 升版到 3.4.0 以後的版本,就不能連了, 狀況是連上又斷線,一直重複 (repeat connect and disconnect) 我的環境 RouterOS 6.49.14 及 7....