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








沒有留言:

Eazy way to install OpenWrt

這個方法網路要通,直接抓 image 寫入硬碟 隨便找一片 Linux ISO 開到 rescue 模式 fdisk -l 看一下硬碟位置,如果是 /dev/sda curl https://repo.jing.rocks/openwrt/releases/23.05.3/tar...