Sep 7

VMWare Networking (eth0 vs eth1)

Tags:

———————————————————————
– OVERVIEW / THOUGHT PROCESS –
———————————————————————

One of the best and most efficient ways to have a test network is to use VMWare (or any virtual machine) software to create test computers. In this particular case, I was creating a CentOS 6.4 machine similar to my active webserver to test against.

As is my routine, the Linux install was minimal with the exception of some development software such as compilers. With this minimal install, the vmware tools package was not installed leaving me without network connectivity.

The first part of this article will briefly show how I installed the vmware tools package. After that, we’ll go into the issue that I ran into after a reboot. Specifically, that my device was renamed ‘eth1’ instead of ‘eth0’ and my prior configurations now working because of this.

———————————————————————
– VMWARE TOOLS INSTALL –
———————————————————————

After the few minutes it took to install CentOS using an .iso file in Fusion 6, I ran the ‘ifconfig -a’ command to see what sort of connectivity I had. the result was:

[root@CentOS64 ~]# ifconfig -a
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:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

Knowing that I wasn’t going to be able to test this server with no connectivity, I went ahead and installed VMWare Tools.

1. From the menu bar in your Fusion 6 toolbar (not in CentOS), select ‘Virtual Machine‘ and scroll down and till you see ‘Install VMware Tools‘ and select it.

2. Allow the new VMware Tools package to download onto your local machine. This download will be viewed by your new CentOS installation as a CD inserted into your virtual CD-ROM drive on the machine (/dev/cdrom).

3. Once the download is complete, mount the new download to your mount directory (/mnt/cdrom). To do this, I created a folder in the mount directory, then mounted to that folder:

# sudo mkdir /mnt/cdrom
# sudo mount /dev/cdrom /mnt/cdrom

4. Create a temporary folder to hold the new installation files. I used the /tmp directory to do this:

# sudo mkdir /tmp/vmware-install

5. Unzip the new files from the VMware Tools download:

# cd /tmp/vmware-install
# sudo tar zxf /mnt/cdrom/VMwareTools-.tar.gz

6. Run the install script:

# cd vmware-tools-distrib
# ./vmware-install.pl
### NOTE: I simply hit to select the default configurations

7. Reboot the machine:
# sudo shutdown -r now

As soon as the machine came back up, I had connectivity and was able to do a ‘yum update’ to bring my system up to date.

———————————————————————
– THE PROBLEM WITH ETH0 AND ETH1 –
———————————————————————

After finishing all of my updates, I gave in for the night and shutdown the virtual computer. When I restarted it again in the morning, to my surprise, the network was down again. So I started my troubleshooting from scratch…

# sudo ifconfig -a

This revealed the same thing as before I installed VMware Tools; there was only a loopback address active on the system. So I went ahead and checked my configuration for the adapter that I was using last night, eth0. (in this example, the ‘x’ has replace the actual value)

# cat /etc/sysconfig/network-scripts/chkcfg-eth0

### chkcfg-eth0 file:
DEVICE=eth0
TYPE=Ethernet
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
HWADDR=xx:xx:xx:xx:xx:xx
IPADDR=10.0.x.x
PREFIX=24
GATEWAY=10.0.x.x
DNS1=8.8.8.8
DOMAIN=8.8.4.4
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=”System eth0″

Unfortunately, everything lookied fine and how I expected… so why not, I went ahead and restarted the network service:

# sudo service network restart
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: Device eth0 does not seem to be present, delaying initialization.

This shows me that there is no eth0 device, even though I’ve made sure the configurations are fine. So what happened?!?

Thanks to NixCraft, I was able to see that there’s a small flaw with the naming convention due to the MAC address. Eth0 was renamed eth1, and if there was an eth1, it would now be eth2, etc. The suggested fix was to delete a file automatically created during boot which defines the naming convention. Instead, I decided simply to go with the now existing ‘eth1’ and create a new configuration file for it.

# cd /etc/sysconfig/network-scripts/
# sudo cp chkcfg-eth0 chkcfg-eth1

Now I restarted the network service thinking that it would simply use the new configuration file… but here’s what I got:

# sudo service network restart
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth1: Device eth1 has different MAC address than expected, ignoring.

I may be able to remedy this by rebooting, but I wanted to see if I could give eth1 a new ‘expected’ MAC address based on what was working yesterday. So I went ahead and changed the chkcfg-eth1 file again with the new MAC address and restarted the service:

# sudo service network restart
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth1: [ OK ]

VOILA!! It worked.

Now, when I reboot and check out the network settings, everything looks correct and here’s what I get:

# sudo shutdown -r now
[root@CentOS64 ~]# ifconfig
eth1 Link encap:Ethernet HWaddr xx:xx:xx:xx:xx:xx
inet addr:10.0.x.x Bcast:10.0.x.255 Mask:255.255.255.0
inet6 addr: xxxx::xxxx:xxxx:xxxx:xxxx/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:51 errors:0 dropped:0 overruns:0 frame:0
TX packets:47 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:6179 (6.0 KiB) TX bytes:5885 (5.7 KiB)

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:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

 

—————————————–

Always remember… WHAT IF AND WHY NOT?!?