How To Troubleshoot Network Connectivity With Linux server?
You always want your servers and websites to be up and running all the time. Isn’t it? However, sometimes your servers and websites will go offline or become inaccessible because of network connectivity issues and even find it challenging to resolve with a Linux control panel. Thus, a control panel for managing Linux with an intuitive user interface and pre-installed, powerful tools for system administrators is essential for managing, monitoring, configuring and troubleshooting network connectivity challenges.
Are you also experiencing web server downtime due to network connectivity issues? You may have tried your best to restore the network connection but to no avail. You must read on if this is your current situation because your desired solution is here. In this article, the focus is to help you troubleshoot and resolve the network connectivity challenges you are facing without further delay.
Check if you can reach the IP address of the web server
The first thing to do is to check the availability of a network and if the host is reachable. Even when your server is down, you can always use a web console or Virtual Network Computing (VNS) connection to log in to test your server’s internet connection. You can do this by using the ping command with the web server’s public IP address or hostname, as in “$ ping [options] hostname or IP address.”
A typical example of a ping command with an IP address is shown below.
$ ping -c <server IP address>
Suppose the server cannot reach the destination or reports no connectivity after using the ping command. In that case, there may be a problem with the network configuration or firewall, which has blocked Internet Control Message Protocol (ICMP) requests.
Check your network configuration
Here, you must check if your network interfaces, such as eth0, are up or enabled. You can use the command below to make the check.
$ <ip address> show eth0
The command output will show the status of each network interface on the server with “UP” or “DOWN.” The network interface is enabled if you have ‘UP” in the command response. However, if the interface is down, you must run the command below to bring it up.
$ ip link set eth0 up
Similarly, ensure you turn on every disabled interface by replacing the eth0 in the command with other interface names like eth1 or eth2. After enabling all the network interfaces, verify that they have IP addresses assigned to them which match the information on the network section of your Linux-based control panel. After that, reuse the ping command to see if the problem is solved.
Check Firewall settings
Now, let’s verify that Firewall does not block your network connection. You have to make this check because some Linux distributions have strict Firewall rules by default. The iptables command, a Linux built-in software Firewall, will help to make this check. Thus, if you use the following iptables command, you will see the list of all server-side Firewall rules on your system in the form of a table.
$ sudo iptables -L
After the command presents you with the table, look up the table and ensure that no rules are blocking your desired connection.
Check name resolution
There is also the possibility of ping by IP address working while ping by hostname fails to work. In this case, your regular network won’t work, and you must resolve the hostname resolution problem. You need to check your server’s DNS records in the “/etc.resolv.conf” file. To do so, you should use the command below.
$ sudo cat /etc/resolv.conf
After this command, you should get a response mapping the hostname to the IP address of your web server. If that is not the case, then there is an issue with the DNS servers with the command below.
$ sudo cat /etc/resolv.conf
If the output of the command maps the hostname to the wrong IP address, then you should edit and add the correct IP address of your web server through the following command.
$ sudo cat /etc/hosts
Do note that you only need to edit the output or list if it is not empty. If it is empty, you should edit through the following command, especially on Ubuntu and some Debian systems that have resolvconf installed.
$ sudo resolvconf -u
Run a route trace
It can also happen that your connection routing hits a dead end before reaching its destination, resulting in a failed connection. To ensure this is not the case, you must run a route trace from your server to discover the network node your server connection keeps getting lost.
Running a route trace differs with different Linux distributions. Likewise, the tools and the output of these tools slightly differ. If you are using an Ubuntu server, the mtr command below will work.
$ mtr < server IP address>
The traceroute command will work instead on Debian since mtr isn’t installed on Debian by default.
$ traceroute -4 <server IP address>
Likewise, tracepath will bring out a similar output on CentOS.
$ tracepath <server IP address>
Check for incorrect initialization of your system
When your Linux machine is booting, it runs some initialization processes. The log output of all the processes running during the booting processes can be assessed through the command below.
$ sudo vim /var/log/messages
Once the log output comes up, check for any errors that could have caused network problems.
Network troubleshooting is a core and daily function for system administrators, and knowing the essential tools for troubleshooting and resolving different network connectivity challenges is necessary. The basic tools and steps you can use to troubleshoot and fix network issues have been discussed above. If these steps do not resolve the problems and everything also seems okay, don’t hesitate to ask for help from your web host service.