Wednesday, October 24, 2012

Troubleshooting eth0 in Oracle Linux

A few days ago I installed Oracle Linux in an Oracle VirtualBox VM. Once it was installed I found that eth0 interface wasn't starting upon boot.

That was unusual. I am myself a Linux enthusiast, and I regularly download and install lots of distributions, and, by and large, network works in them out of the box.

Today I finally got around to troubleshooting this problem. It took me a couple of hours digging through the scripts, setting trace points, and reading logs; and here's what I found.

For the reference, this was my configuration:

Oracle VM VirtualBox 4.1.22 r80657

Host: Windows 7 64-bit

Linux: Oracle Linux Server release 6.3

Kernel 2.6.39-200.24.1.el6uek.x86_64 on x86_64

As I said, upon boot eth0 was down. If I tried to bring it up with "ifconfig eth0 up"
it came up in IPV6 mode only, no IPV4:

Hm, weird. What was even more weird was that if I brought it up with "ifup eth0" instead of "ifconfig eth0 up", IPV4 network started succesfully:

Obviously, these 2 were are different. The reason "ifup" worked was because it called dhclient to obtain an IP address from a DHCP server.

Whereas ifconfig didn’t make that call. And because the network interface did not have an IP address, it stayed down.

So, what is the difference between "ifup" and "ifconfig up"?

Well, "ifup" is actually a script located in/etc/sysconfig/network-scripts

During the system boot the network subsystem is brought up via startup script/etc/rc2.d/S10network

That script goes through all the network interfaces it can find and brings them up during the boot.
What’s interesting, I found that it uses a set of configuration files/etc/sysconfig/network-scripts/ifcfg-<interface_name>

to determine if a particular interface needs to be brought up during the boot time. There is one config file for each interface. I’m not sure when they are created, maybe at install time.

In my case I found that one of the parameters in "ifcfg-eth0" file was "ONBOOT=no".
Turned out the network startup script uses that parameter to determine if the particular interface should be brought up at the boot time.

So, I changed it to "ONBOOT=yes", and everything worked.
Now when the system starts, eth0 is up and running.

Problem solved!

Update:

So, the mystery is finally solved. There is "Connect automatically" checkbox on the installer's network configuration screen (item 10 here). If this checkbox is unchecked, network interfaces do not come up at system start-up.

Many thanks to the Oracle Linix team for helping me in this investigation.

HiI have encountered a problem as you discribed in your blog in Mininet.i installed ubuntu 12.0 and instaal virtual box 4.3 on it.in virtual box I install mininet (ubunto 64).The eth0 is allocated to NAT in Mininet and has a certain IP address(10.0.2.15).I defined a host only adaptorwhich must be the IPv4, and when I add host only adaptor the IPv6 field is empty of any value and IPv6 Network Mask length is 0.but after I click on the OK button and open it again the ipv6 have a value!!!but I don't need it to be set.the most important problem is when I add a host-only adapter to Mininet, and do the command “ ifconfig -a” it didn't allocate any IP address to it (eth1) and it is written UP BROADCAST RUNNING MULTICAST. but I need and ip address to communicate with remote controller.When I want to do “dhclient eth1” for allocating the IP address the mininet did not worked.when I also did "ifup eth1" it said : "ifup:failed to open statefile /run/network/ifstate: permission denied"