网络故障排查命令
- ping #檢測目標主機是否暢通
- traceroute #追蹤路由
- mtr #檢查到目標主機之間是否有數據包丟失
- nslookup #查看域名并解析,獲取IP地址
- telnet #檢查端口鏈接狀態
- tcpdump #細致分析數據包發送接收 的詳細內容
- netstat #查看網絡端口連接狀態
- ss #另外一種各式的查看網絡端口連接狀態
檢測過程:
-
ping www.baidu.com#檢測設備是否能夠上網[root@node1 test]# ping www.baidu.com PING www.a.shifen.com (180.101.49.12) 56(84) bytes of data. 64 bytes from 180.101.49.12: icmp_seq=1 ttl=46 time=24.8 ms 64 bytes from 180.101.49.12: icmp_seq=2 ttl=46 time=24.6 ms 64 bytes from 180.101.49.12: icmp_seq=3 ttl=46 time=24.1 ms 64 bytes from 180.101.49.12: icmp_seq=4 ttl=46 time=24.0 ms 64 bytes from 180.101.49.12: icmp_seq=5 ttl=46 time=24.8 ms 64 bytes from 180.101.49.12: icmp_seq=6 ttl=46 time=24.6 ms 64 bytes from 180.101.49.12: icmp_seq=7 ttl=46 time=24.0 ms ^C --- www.a.shifen.com ping statistics --- 7 packets transmitted, 7 received, 0% packet loss, time 6009ms rtt min/avg/max/mdev = 24.081/24.457/24.833/0.376 ms -
traceroute -w 1 www.baidu.com#追蹤到達目標主機的路由,如果沒有響應則最多等等1秒[root@node1 test]# traceroute -w 1 www.baidu.com traceroute to www.baidu.com (180.101.49.12), 30 hops max, 60 byte packets1 * * *2 * * *3 * * *4 49.5.11.113 (49.5.11.113) 6.228 ms 9.228 ms 9.215 ms5 219.232.44.1 (219.232.44.1) 2.188 ms 2.191 ms 2.194 ms6 172.16.243.237 (172.16.243.237) 3.103 ms 3.921 ms 3.904 ms7 172.16.243.1 (172.16.243.1) 6.231 ms 5.990 ms 6.988 ms8 59.108.164.113 (59.108.164.113) 10.963 ms 10.928 ms 10.268 ms9 106.38.64.33 (106.38.64.33) 2.667 ms 3.659 ms 3.698 ms 10 * * * 11 bj141-152-73.bjtelecom.net (219.141.152.73) 4.960 ms 4.988 ms^C -
mtr直接執行即可,會實時顯示網絡數據包情況 -
nslookup www.baidu.com#某一些服務器僅支持IP訪問,則需要通過該命令獲取域名對應的IP地址[root@node1 test]# nslookup www.baidu.com Server: 10.1.7.88 #域名對用的IP Address: 10.1.7.88#53Non-authoritative answer: www.baidu.com canonical name = www.a.shifen.com. #別名 Name: www.a.shifen.com Address: 180.101.49.11 Name: www.a.shifen.com Address: 180.101.49.12 -
telnet#當IP以及域名連接暢通,但網絡連接仍然有問題,則需要進一步確認底層端口連接情況如果沒有telnet命令,則直接執行
yum install telnet -y[root@node1 test]# telnet www.baidu.com 80 Trying 180.101.49.12... Connected to www.baidu.com. #表示端口可達 Escape character is '^]'. ^] telnet> quite^H ?Invalid command telnet> quit Connection closed. -
如果端口沒有問題,則使用
tcpdump進行具體抓包[root@node1 test]# tcpdump -i any -n host 10.192.55.179 and port 80 -w /tmp/test.txt #抓取任意網口,從10.192.55.179發送到80端口的數據包,并保存到/tmp/test.txt -
netstat -ntpl#查看系統活躍的端口以及對應的控制程序[root@node1 RPMS]# netstat -ntpl Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 10.193.55.179:6840 0.0.0.0:* LISTEN 1955633/ceph-osd-yz tcp 0 0 10.193.55.179:6808 0.0.0.0:* LISTEN 2381937/ceph-osd tcp 0 0 10.193.55.179:6841 0.0.0.0:* LISTEN 66963/ceph-osd tcp 0 0 10.193.55.179:6809 0.0.0.0:* LISTEN 2397198/ceph-osd tcp 0 0 0.0.0.0:7481 0.0.0.0:* LISTEN 129358/svr-rgw tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 22873/master -
ss -ntpl[root@node1 RPMS]# ss -ntpl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 512 10.193.55.179:6840 *:* users:(("ceph-osd-yz-nos",1955633,55)) LISTEN 0 512 10.193.55.179:6808 *:* users:(("ceph-osd",2381937,56)) LISTEN 0 512 10.193.55.179:6841 *:* users:(("ceph-osd",66963,53)) LISTEN 0 512 10.193.55.179:6809 *:* users:(("ceph-osd",2397198,53))
總結
- 上一篇: C语言 #ifndef 引起的redef
- 下一篇: shell --- trap 抓取信号