Issues with NIC Detection: Centos 6 on a VM
Does this ever happen to you: After provisioning a VM with Centos you discover that it has not detected the virtual NIC. It happens to me on occasion and can get annoying.
Symptoms:
- No internet access (of course)
- When you run ifconfig, you only see output for lo
This article:
- Shows how to tell if the NIC is "physically" installed correctly
- Walks through a manual configuration scenario
Notes:
- Detecting Network Card (linuxforums.org)
- Configure RHEL 5 NIC (cyberciti.biz)
How to tell if the NIC is attached:
Run these 2 commands:
- lspci | grep -i eth
- dmesg | grep eth
You should see messages listing your NIC (Make/Model and connetion status):
Configure the NIC:
- Run system-config-network and set the IP Address, Subnet and DNS settings
- Open /etc/sysconfig/network using nano / pico / vi / other text editor and setup your gateway (if you are using a Static IP Address)
- Edit /etc/sysconfig/network-scripts/ifcfg-eth0 and ensure ONBOOT=yes
If you want to setup a Static IP Address include these additional entries (Sample data: replace with values appropriate to your environment):
IPADDR=10.10.45.56
NETMASK=255.255.255.0
DNS1=10.10.45.1
Change BOOTPROTO=dhcp to BOOTPROTO=static
- Run service network restart and note that eth0 should be started:
- Validate that eth0 is up and running by by using ifconfig:
This seems to work for me- if you know a better method, let me know in the comments area.
UPDATE 24-May-2012
I ran into a couple of errors that should be noted here:
Error 1:
[root@rcarter-PhantomDebugger-Centos6-x64 /]# service network restart
Shutting down interface eth0: Error: Device 'eth0' (/org/freedesktop/NetworkManager/Devices/0) disconnecting failed: This device is not active
[FAILED]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: Error: Unknown connection: 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03.
[FAILED]
Error 2:
[root@rcarter-sspPhantomDebugger-Centos6-x64 /]# service network restartShutting down interface eth0: Error: Device 'eth0' (/org/freedesktop/NetworkManager/Devices/0) disconnecting failed: This device is not active
[FAILED]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: ipcalc: bad prefix: 255.255.255.0
RTNETLINK answers: File exists
Error adding address 192.168.6.95 for eth0.
RTNETLINK answers: File exists
[ OK ]
To get around these errors I had to make a few changes to /etc/sysconfig/network-scripts/ifcfg-eth0:
- Change PREFIX=255.255.255.0 to PREFIX=24
.. This could also be fixed by changing to NETMASK=255.255.255.0 - Change BOOTPROTO=static to BOOTPROTO=none
- Remove the UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 line