Networking is probably the most essential service on any server. If it fails, so does everything else. Administrators...
use ping to help get networking up on Linux servers when it goes down.
The mother of all network troubleshooting tools is the ping utility. You're probably familiar with this utility from other operating systems, where it verifies connectivity with other machines. If you're new to administering Linux systems, there are some tips for working with the ping utility tool.
Before starting to use the ping utility, know what you want to ping. The all-inclusive ping test goes toward a server on the Internet by using its domain name server (DNS) name. For example, you can ping www.google.com to verify that you can reach the Google website. This reply is proof that DNS name resolution is working, the default gateway is operational, and your local network configuration is operational. If there is no reply, use ping to eliminate all possible errors one by one.
On Linux servers, the ping utility doesn't stop by itself, so make sure that after starting a ping test to a specific machine, you stop it as well, using the Ctrl-C key sequence.
Identifying DNS issues with the ping utility
Start with the command ping 126.96.36.199. This command tries to connect to the Google DNS server by using its IP address and not DNS. If this command is successful, you have identified a DNS issue. This normally means that you have a configuration error in the file /etc/resolv.conf, which contains a list of all DNS name servers that should be contacted (see Listing 1).
Listing 1. Linux administrators can verify DNS configuration in /etc/resolv.conf.
[root@ipa ~]# cat /etc/resolv.conf
# Generated by NetworkManager
If you can ping the DNS server by IP address, but cannot ping hosts by name, you have verified that there is a problem with the nameserver entry that you're using. You should first verify that there is no error in that IP address, and then check that there is no firewall blocking DNS requests. If the configuration has always worked and you haven't changed anything recently, the problem is probably related to a change in firewall rules. If not, it's a good idea to verify that you're really using the right DNS server. On some sites you cannot use just any DNS server, but are required to use the internal DNS server for that site.
If you're learning Linux server administration and need to configure a network, start with the ip command.
Identifying router issues via pings
If you cannot successfully ping a random IP address on the Internet, you're probably dealing with a router issue in the data center. One likely cause is a misconfigured default gateway. To analyze this problem, start by identifying which IP address is used as the default gateway. On Linux servers, use the command ip route show. You can see sample output of this command in listing 2.
Listing 2. Linux admins verify the default gateway configuration via ip route show.
[root@ipa ~]# ip route show
default via 192.168.4.2 dev eno16777736 proto static metric 100
192.168.4.0/24 dev eno16777736 proto kernel scope link src 192.168.4.200 metric 100
Check that you correctly input the IP address of the default gateway. Also verify that the default gateway is in the same network as your local IP address by comparing its IP address with your local IP address configuration, which displays via the ip addr show command. If neither of them seems wrong, try contacting the default gateway, using the ping utility. This gateway might be temporarily down.
On some occasions, the problem is not in the default gateway, but somewhere behind it. If the default gateway address is correct and you're able to ping it, yet you cannot reach any host on the Internet, it is likely there is a routing problem somewhere else along the route. To confirm this is the case, ping a router that is closer to your location, such as the provider router. This helps to confirm that the problem is further on in the chain. In that case, you can't do much except wait.
Get started with Linux servers
Take command of Linux systems
How to mount Linux file systems
Shut down Linux processes safely
Access storage devices on Linux systems