How Do You Troubleshoot a CentOS Server Not Being Able to Reach the Internet or outside Your Network?

Problem scenario:  From a CentOS server, you try to ping an IP address outside of your network (e.g.,  You get "connect: Network is unreachable" as the response.  Your server has an IP address and subnet mask.  What is wrong?

1.  Ensure that the network has a default gateway.  If the network equipment that connects the server to the network has no gateway to outside the network, these directions will not be able to help.  If you know the server is on a network that has access to other networks (e.g., there is a router that can route traffic to the Internet), proceed to the next step.

2.  If you are using CentOS, go to /etc/sysconfig/network-scripts/ and find the relevant interface file (e.g., ifcfg-enp0s3). If you are not sure of which file governs the interface for the server's default gateway, see these directions.

3.  Ensure that this file as a gateway value.  For example, a stanza with the word "GATEWAY=" is needed.  Here is an example (but remember your IP address will likely be different)


Ask your network administrator what the default gateway's IP address should be.  If you have another server on the network, you could potentially find the default gateway of that server to learn what it is.

If you happen to be using Oracle VirtualBox on a Windows host, three potential IP addresses may work as a default gateway.  This assumes that you have a CentOS 7.3 guest that has its Network Adapter configured to be attached to "NAT" with  the "Cable Connected" option box being checked.

These three working default gateways can be,, and

4.  Once the GATEWAY stanza is configured properly in the interface file (in /etc/sysconfig/network-scripts/), run this command:

service network restart

Now you should be able to ping an IP address outside of your network (e.g., on the Internet).

Leave a comment

Your email address will not be published. Required fields are marked *