How to Troubleshoot Common Network Connectivity Issues with Linux Web Servers

How to Troubleshoot Common Network Connectivity Issues with Linux Web Servers

What Do I Need?

  • A Dedicated or VPS Linux Server
  • CentOS
  • Putty

What is the Problem?

There are times when your Linux server seems to be offline or otherwise inaccessible, you should always be able to log in with your web console, using Putty. Once logged in, test your web server’s internet connection using pinc and a public IP address, such as Google’s DNS server, which is most likely to reply provided your internet connection works.

  1. Troubleshooting and Analysis
ping -c 4 8.8.8.8

How to Troubleshoot Common Network Connectivity Issues with Linux Web Servers

  1. If the server is unable to reach the destination, there may be a problem with your configuration or the physical hardware itself.
  1. Check your Network Configuration
  1. Make sure the network interfaces such as eth0 are enabled. To see all the configured interfaces, use the following command.
ip addr

How to Troubleshoot Common Network Connectivity Issues with Linux Web Servers

  1. Turn on any disabled interfaces.
sudo ifup <interface name>

  1. When all the network interfaces have been enabled, try using the ping command again.
sudo ifdown <interface name>

sudo ifup <interface name>

  1. If either of these commands fails, it’s possible that the interface is in a state unknown to the command script. Try using the ‘–force’ flag option to resolve any issues.
sudo ifdown --force <interface name>

sudo ifup <interface name>

  1. Check your Network Configuration File
  1. Linux commonly stores network settings in specific files and reads them for example at boot or when using the ifup command. To make changes to the network configuration, you’ll need to open the right file in an appropriate file editor. In Debian and Ubuntu-based distributions this can be done with:
sudo nano /etc/network/interfaces

  1. In some cases, the interfaces file should list at least the following interfaces:
auto lo

iface lo inet loopback

auto eth0

iface eth0 inet dhcp

auto eh1

iface eth1 inet dhcp

  1. In CentOS and other RedHat variants, these configurations are split into separate files for each network interface and stored in /etc/sysconfig/network-scripts/. The default interface for internet connection is usually called eth0. Open the corresponding configuration file:
sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0

  1. The configuration file for eth0 should look like this:
DEVICE=eth0

BOOTPROTO=dhcp

ONBOOT=yes

  1. If the interface’s configuration file doesn’t match the example here, edit the file specific to your system to restore the original functionality. For any changes made to these files to take any effect, you must restart the interfaces to which the changes apply with ifdown and ifup commands.
  1. Check the Server DNS Records
  1. When ping with an IP works but the regular connection still fails, try pinging a domain name instead.
ping kryotech.co.uk

How to Troubleshoot Common Network Connectivity Issues with Linux Web Servers

  1. Test the Connection Both Directions
  1. Try pinging your server over the internet. Open a terminal or command prompt on your own computer and try pinging your server’s public IP.
ping 8.8.8.8

  1. If you have a second server deployed on your account and the problem’s with the interface assigned the private IP address. Should ping fail to receive a reply, try restarting all of your server’s network services. In Debian and Ubuntu or older, use the command below:
sudo service networking restart

  1. In Ubuntu and newer you’ll need to run the command for each network interface separately. You can restart eth0 with the following command:
sudo ifdown eth0 && sudo ifup eth0

  1. After restarting the network services, try running the ping command again. If ping works in one direction and not the other then you should check your firewall settings.

Next Steps

Your internet connecting in its basic form boils down to knowing the route to take you to your destination. It’s sometimes possible for the connection to hit a dead end, which then results in a failed connection. If you’re experiencing problems run a route trace from your webserver to see through which network node the connection gets lost.

You can use the networking tool mtr for this purpose.

        tracepath 8.8.8.8

Be sure to start checking your connections in and out of your firewall. CentOS and RedHat based operating systems have strict firewall rules by default. The following commands will help you see what’s going on.

        sudo iptables -L

Conclusion

With these concepts, you’ll be now well on your way to being able to deal with whatever issues come your way in maintaining your web server.

How To Set up a VSFTPD Server on a CentOS 7 VPS or Dedicated Server

Brief Description FTP is usually insecure exposing clear-text passwords, userna
2 min read
Avi Ilinsky
Avi Ilinsky
Hosting Expert

How To Set up a VSFTPD Server on an Ubuntu 16.04 VPS or Dedicated Server

Brief Description FTP data is usually insecure since information (usernames, pa
2 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How to use phpMyAdmin to develop a website (without MySQL experience)

Brief description A web developer who is not well versed into coding websites f
2 min read
Idan Cohen
Idan Cohen
Marketing Expert

How to Install MySQL on a Windows Web Server Running Apache

This tutorial will show you how to install the MySQL database on a Windows serve
3 min read
Michael Levanduski
Michael Levanduski
Expert Hosting Writer & Tester
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top