No outbound internet connection after restarting CentOS 6.3

After restarting a headless CentOS 6.3 machine, it lost outbound internet connectivity, i.e. I can still connect to the server via SSH (ssh root@**.126.18.56), but stuff such as ping google.com gives google.com: unknown host, and yum list some_package gives a lot of network errors.

This is what ifconfig gives:

eth0      Link encap:Ethernet  HWaddr 00:25:90:78:2D:5D  
          inet addr:**.126.18.56  Bcast:**.126.18.255  Mask:255.255.255.0
          inet6 addr: fe80::225:90ff:fe78:2d5d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:75594 errors:0 dropped:0 overruns:0 frame:0
          TX packets:787 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:7074741 (6.7 MiB)  TX bytes:144391 (141.0 KiB)
          Interrupt:20 Memory:f7a00000-f7a20000 

eth1      Link encap:Ethernet  HWaddr 00:25:90:78:2D:5C  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
          Interrupt:16 Memory:f7900000-f7920000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:504 (504.0 b)  TX bytes:504 (504.0 b)

I have absolutely no clue how to debug this, and I find it very strange since I can still connect via ssh.

EDIT: Weirdly, /etc/resolv.conf does not contain any entries, or none that I can make sense of:

# Generated by NetworkManager
search sui-inter.net


# No nameservers found; try putting DNS servers into your
# ifcfg files in /etc/sysconfig/network-scripts like so:
#
# DNS1=xxx.xxx.xxx.xxx
# DNS2=xxx.xxx.xxx.xxx
# DOMAIN=lab.foo.com bar.foo.com

So is it possible that rebooting the server erased that file? It worked before at least! And how do I solve this?

By the way, pinging an IP address works.


Ok You can edit the below file to prevent from overwriting resolv.conf

file name is /etc/sysconfig/network-scripts/ifcfg-eth0

Value to set is PEERDNS=no


I think your file /etc/resolv.conf is not present or no entries in that. Generally it contains the nameserver address which is nothing but DNS server address. All domain names like google.com etc will be resolved by using that DNS server.

Incase of ssh root@**.126.18.56, it is working because here you are giving direct IP address instead of name.


I seems that CentOS rebuilds /etc/resolv.conf on boot, using values found in the scripts in /etc/sysconfig/network-scripts. Those are probably missing, simply not set or maybe corrupt.

So is it possible that rebooting the server erased that file? It worked before at least!

It recreated it with new, up to date values. Except that something went wrong. (e.g. because it had no values to set)

And how do I solve this?

Quick workaround: echo "nameservers 8.8.8.8" > /etc/resolv.conf

Proper solution: Configure the network properly. Start by looking at the Networkmanager. ( I can not go in detail here since I have no CentOS experience. )


Don't allow NetworkManager to manage your server's NIC.

Edit /etc/sysconfig/network-scripts/ifcfg-eth0. Find the line:

NM_CONTROLLED=yes

Change it to read:

NM_CONTROLLED=no

If the line doesn't exist, just add it.