linux中涌现网络故障该怎样排除-linux运维
ping
第一来看ping下令,这个下令是用来测试两台主机之间能否进行正常通信的工具。ping的对象既可以是ip地址,也可以是域名。该下令在linux以及windows的cmd模式下都可以运用。运用办法都是同样的。
# ping -c 4 8.210.247.5 PING 8.210.247.5 (8.210.247.5) 56(84) bytes of data. 64 bytes from 8.210.247.5: icmp_seq=1 ttl=64 time=1.54 ms 64 bytes from 8.210.247.5: icmp_seq=2 ttl=64 time=1.48 ms 64 bytes from 8.210.247.5: icmp_seq=3 ttl=64 time=1.46 ms 64 bytes from 8.210.247.5: icmp_seq=4 ttl=64 time=1.48 ms --- 8.210.247.5 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3004ms rtt min/avg/max/mdev = 1.460/1.494/1.548/0.042 ms # ping -c 1 百度.com ……
下面,是一个shell足本,用来查看局域网是什么ip可以进行通信
#!/bin/bash net='192.168.2.' seqs=`seq 1 254` for seq in $seqs do ip=$net$seq /usr/bin/ping -c 1 -W 1 $ip >/dev/null 2>&1 if [ "$?" == "0" ];then echo "$ip is UP" fi done
traceroute
该下令是用来查看两台主机之间的各个节点的网络状况。要是当你拜访一个网站的时候,速度较慢,那么可以用该下令来查看所有节点的网络状况。
# traceroute -n google.com traceroute to google.com (172.217.163.238), 30 hops max, 60 byte packets 1 * * * 2 11.109.220.61 1.444 ms 1.577 ms 11.109.216.189 1.500 ms 3 11.109.220.190 5.512 ms * 11.109.220.174 5.382 ms 4 11.131.180.222 1.660 ms 11.131.180.218 1.519 ms 11.131.180.250 1.365 ms ……
nslookup
该下令是可以通过域名来反查ip地址的,运用非常简略。
nslookup 5iqm.com Server: 100.100.2.136 Address: 100.100.2.136#53 Non-authoritative answer: Name: 5iqm.com Address: 121.196.12.64
netstat
。要是网站拜访不了,我们第一做的应当是ping办事器的ip地址,要是能够正常ping通,接下来应当ping网站域名,看dns可否正常解析。要是都没有题目,网站还是拜访不了,那就需要去看看80端口可否对外开放了。netstat下令就是用来查看主机端口监听状况。
# netstat -tlunp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 30721/nginx: master tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 1275/pure-ftpd (SER tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1167/sshd tcp 0 0 0.0.0.0:888 0.0.0.0:* LISTEN 30721/nginx: master tcp 0 0 0.0.0.0:8888 0.0.0.0:* LISTEN 2068/python
telnet
该下令可以用来测试办事器的指定端口可否对本人开放。
# telnet 8.210.110.139 22 Trying 8.210.110.139... Connected to 8.210.110.139. Escape character is '^]'. SSH-2.0-OpenSSH_7.4 # telnet 8.210.110.139 3306 Trying 8.210.110.139... <=== 一直是这样的状态则
要是是上述的首先种状况,则注明8.210.110.139的22端口是开放的。要是是第二种的话,不断在trying,则注明此端口没有对本人开放。
以上就是linux中涌现网络故障该怎样排除的细致内容,更多请关注 百分百源码网 其它相干文章!