[CentOS] Nic order detection

Thu Jan 10 13:55:50 UTC 2008
Barry Brimer <lists at brimer.org>

> MatsK wrote:
>> Les Mikesell wrote:
>>> I have a number of machines that have 4 NICs, two of which are actually in 
>>> use, running Centos 5.  When they are rebooted, they seem to change the 
>>> eth interface names, assigning them in different orders.  I'm a little 
>>> fuzzy on the details because they are at a remote location and I can't 
>>> access them easily - especially after the network breaks.  Shouldn't:
>>> alias eth0 bnx2
>>> alias eth1 bnx2
>>> alias eth2 e1000
>>> alias eth3 e1000
>>> in /etc/modprobe.conf always make the intel cards eth2 and 3?
>> 
>> Noop, this is done with ifcfg-ethX where X is the if number.
>> 
>> Create a /etc/sysconfig/network/ifcfg-eth0 that look like this example:
>> 
>> DEVICE=eth0
>> HWADDR=00:01:23:45:67:89
>> ONBOOT=yes
>> TYPE=Ethernet
>> NETMASK=255.255.255.0
>> IPADDR=192.168.1.154
>> GATEWAY=192.168.1.1
>> 
>> and then create ifcfg-eth1, ifcfg-eth2, ifcfg-eth3
>> 
>> then do a "service network restart" to activate the settings.
>
> I do have the ifcfg-ethX files for the 2 interfaces that are currently 
> active, but since the machines were built by image copies of a master disk, 
> they do not have HWADDR address entries.  A person on-site with access to the 
> console adjusted them if they didn't come up right the first time, but they 
> seem to shift around on each reboot.  Will adding the HWADDR entry nail them 
> down even if it doesn't match the nic type specified in modprobe.conf?  Can 
> someone point me to the code where this happens?  Until recently the machines 
> were running centos 3.x and this seems to be a difference in behavior.

In my experience, adding the HWADDR line to your ifcfg-ethX files will tie 
the network interface to the right card, regardless of modprobe.conf 
entries.  I usually remove HWADDR lines when anaconda provides them at 
install time because if I replace a nic (which obviously has a different 
MAC address) without updating the HWADDR line, the interface fails to 
start.  In cases where modprobe.conf is unable to order the interfaces as 
I want it to, I add HWADDR lines.  Works every time.

Hope this helps.

Barry