【命令】5个网络排查常用命令
2014年07月12日 21:47:00 作者:Jiaozn 分类:网络 评论(0)网络排查常用命令:ping、traceroute、nslookup、dig、netstat,Linux命令举例
1、ping测试连通性,命令使用技巧,依次检查本地回环、本地IP、网关IP、外网IP
ping 127.0.0.1 ping回环,测试本地网络协议是否正常
[jiaozn@itman ~]$ ping 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.075 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.074 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.074 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.066 ms
64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.062 ms
^C
--- 127.0.0.1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4025ms
rtt min/avg/max/mdev = 0.062/0.070/0.075/0.007 ms
2、traceroute路由跟踪 默认UDP封装跟中包,加-I选项使用ICMP封装
[root@itman ~]# traceroute -I www.jiaozn.com
traceroute to www.jiaozn.com (114.215.132.189), 30 hops max, 60 byte packets
1 172.16.1.1 (172.16.1.1) 2.952 ms 2.939 ms 5.514 ms
2 * * *
3 * * *
4 * * *
5 * * *
6 * * *
7 * * *
8 * * *
9 * * *
10 ip215.hichina.com (114.215.132.189) 168.283 ms 168.311 ms 168.303 ms
3、nslookup测试本地设置的DNS服务器是否正常,查询域名与IP地址之间的对应关系
[root@itman ~]# nslookup www.d7it.com
Server: 172.16.1.1
Address: 172.16.1.1#53
Non-authoritative answer:
Name: www.d7it.com
Address: 114.215.132.189
4、dig查询更多关于DNS记录的信息,查看MX(邮件记录)、NS(域名服务器记录)等信息
[root@itman ~]# dig www.jiaozn.com
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6 <<>> www.jiaozn.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7236
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 8
;; QUESTION SECTION:
;www.jiaozn.com. IN A
;; ANSWER SECTION:
www.jiaozn.com. 31 IN A 114.215.132.189
;; AUTHORITY SECTION:
jiaozn.com. 31 IN NS f1g1ns1.dnspod.net.
jiaozn.com. 31 IN NS f1g1ns2.dnspod.net.
;; ADDITIONAL SECTION:
f1g1ns1.dnspod.net. 124617 IN A 182.140.167.166
f1g1ns1.dnspod.net. 124617 IN A 183.60.52.217
f1g1ns1.dnspod.net. 124617 IN A 119.167.195.3
f1g1ns1.dnspod.net. 124617 IN A 122.225.217.192
f1g1ns2.dnspod.net. 124617 IN A 182.140.167.188
f1g1ns2.dnspod.net. 124617 IN A 112.90.143.29
f1g1ns2.dnspod.net. 124617 IN A 122.225.217.191
f1g1ns2.dnspod.net. 124617 IN A 180.153.162.150
;; Query time: 37 msec
;; SERVER: 172.16.1.1#53(172.16.1.1)
;; WHEN: Sat Jul 12 22:25:35 2014
;; MSG SIZE rcvd: 230
[root@itman ~]# dig www.itq.im MX #查看itq.im的邮件记录
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6 <<>> www.itq.im MX
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 61505
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;www.itq.im. IN MX
;; AUTHORITY SECTION:
itq.im. 31 IN SOA f1g1ns1.dnspod.net. freednsadmin.dnspod.com. 1404882498 3600 180 1209600 180
;; Query time: 22 msec
;; SERVER: 172.16.1.1#53(172.16.1.1)
;; WHEN: Sat Jul 12 22:45:00 2014
;; MSG SIZE rcvd: 105
5、netstat查看网络链接状态、端口
netstat -an #查看网络链接状态
netstat -nutlp #查看当前系统开启的端口信息
评论
发表评论