What Do I Need?
- A Dedicated or VPS Linux Server
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.
- Troubleshooting and Analysis
ping -c 4 22.214.171.124
- If the server is unable to reach the destination, there may be a problem with your configuration or the physical hardware itself.
- Check your Network Configuration
- Make sure the network interfaces such as eth0 are enabled. To see all the configured interfaces, use the following command.
- Turn on any disabled interfaces.
sudo ifup <interface name>
- When all the network interfaces have been enabled, try using the ping command again.
sudo ifdown <interface name> sudo ifup <interface name>
- 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>
- Check your Network Configuration File
- 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
- 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
- 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
- The configuration file for eth0 should look like this:
DEVICE=eth0 BOOTPROTO=dhcp ONBOOT=yes
- 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.
- Check the Server DNS Records
- When ping with an IP works but the regular connection still fails, try pinging a domain name instead.
- Test the Connection Both Directions
- 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.
- 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
- 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
- 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.
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.
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
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.
- Looking for Top web hosting? Clicking on this link can be the solution.