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?

  • [tool]A Dedicated or VPS Linux Server[/tool]
  • [tool]CentOS[/tool]
  • [tool]Putty[/tool]

What is the Problem?

[openingText]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.[/openingText]

  1. [stepName]Troubleshooting and Analysis[/stepName]
    [step]
ping -c 4 8.8.8.8

[stepImage]How to Troubleshoot Common Network Connectivity Issues with Linux Web Servers[/stepImage]

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

[stepImage]How to Troubleshoot Common Network Connectivity Issues with Linux Web Servers[/stepImage]

[/howToDirection]

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

[/howToDirection]

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

sudo ifup <interface name>

[/howToDirection]

  1. [howToDirection]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>

[/howToDirection]

[/step]

  1. [stepName]Check your Network Configuration File[/stepName]
    [step]
  1. [howToDirection]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

[/howToDirection]

  1. [howToDirection]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

[/howToDirection]

  1. [howToDirection]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

[/howToDirection]

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

BOOTPROTO=dhcp

ONBOOT=yes

[/howToDirection]

  1. [howToDirection]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.[/howToDirection]
    [/step]
  1. [stepName]Check the Server DNS Records[/stepName]
    [step]
  1. [howToDirection]When ping with an IP works but the regular connection still fails, try pinging a domain name instead.
ping kryotech.co.uk

[stepImage]How to Troubleshoot Common Network Connectivity Issues with Linux Web Servers[/stepImage]
[/howToDirection]
[/step]

  1. [stepName]Test the Connection Both Directions[/stepName]
    [step]
  1. [howToDirection]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

[/howToDirection]

  1. [howToDirection]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

[/howToDirection]

  1. [howToDirection]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

[/howToDirection]

  1. [howToDirection]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.[/howToDirection][/step]

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 Examine And Repair A Database in PhpMyAdmin

Over the period of time, database can be corrupted and needs to repaired. This t
less than a minute
Elizabeth Grom
Elizabeth Grom
Hosting Expert

How To Find and Install A New Theme in Drupal 8

This tutorial will help you replace the default Drupal theme with your preferred
less than a minute
Elizabeth Grom
Elizabeth Grom
Hosting Expert

How To Create Views in Drupal 8

This tutorial is compiled to help you create a view in your Drupal 8 platform.
less than a minute
Elizabeth Grom
Elizabeth Grom
Hosting Expert

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, usernam
less than a minute
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert
Click to go to the top of the page
Go To Top
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.