If the company’s website cannot be opened, if it is because of network problems, how should you troubleshoot. For another example, if the remote connection tool cannot connect to the server or the mysql database, it may be due to network problems. In daily work or study, we often encounter various network problems (because computer networks are too complicated). Now let’s take a look at how to troubleshoot if there is a network problem with the linux server.
ping
First look at the ping command, which is a tool used to test whether two hosts can communicate normally. The object of ping can be either an IP address or a domain name. This command can be used in both linux and windows cmd mode. The method of use is the same.
# 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 baidu.com ...
The following is a shell script to check which IPs in the LAN can communicate
#!/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" the fi done
traceroute
This command is used to view the The network conditions of each node in between. If the speed is slow when you visit a website, you can use this command to view the network conditions of all nodes.
# 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
This command can be reversed by domain name The ip address is very simple to use.
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
. If the website cannot be accessed, the first thing we should do is ping the IP address of the server. If it can be pinged normally, then we should ping the domain name of the website to see if the dns is resolved normally. If there is no problem and the website still cannot be accessed, then you need to check whether port 80 is open to the outside world. The netstat command is used to view the monitoring status of the host port.
# 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
This command can be used to test whether the specified port of the server is open to itself.
# telnet 8.210.110.139 22 Trying 8.210.110.139... Connected to 8.210.110.139. Escape character is & # 39; ^] & # 39;. SSH-2.0-OpenSSH_7.4 # telnet 8.210.110.139 3306 Trying 8.210.110.139... <=== If it has been in this state,
If it is the first case above, it means that port 22 of 8.210.110.139 is open. If it is the second type, it has been trying, it means that this port is not open to itself.
The above is the detailed content of how to troubleshoot network failures in Linux, please pay attention to other related articles on 1024programmer.com for more information!