# Network Adapter Keeps Changing Identity (eth0 -> eth1...)

## Evilguru

I have recently re-formatted my Gentoo system and reinstalled Gentoo, which I did for various reasons. However I am having a problem with my network adapter---it keeps changing its identity from eth0 to eth1 and vice versa as is very annoying. I am using exactly the same kernel config and network settings (just DHCP) that I did in my last install where it worked fine with the only difference this time being that I am on an ~arch system (ACCEPT_KEYWORDS="~x86") and that I am using GCC 4.

/etc/init.d/net.eth0 and /etc/init.d/net.eth1 are both symlink'ed to /etc/init.d/net.lo. Neither net.eth0 or net.eth1 are on any of my run-levels.

This makes boot-up times very long, as it attempts to get an IP with both adapters---one will work fine and get an IP from my DHCP server, the other will (after 5+ min) timeout.

Can anyone tell me what I can do to force the system to use the same interface for the same network adapter?

Thanks for all of your help.

Regards, Freddie.

----------

## chrismortimore

Get yourself "ifrename" and config /etc/iftab to force your network adapter to a certain name.  And make sure it runs before it starts the network.

EDIT: ifrename is part of net-wireless/wireless-tools

----------

## Evilguru

My motherboard does actually have two network adapters, an nVidia one (that I use) and another one. Would it be possible to remove support in the kernel for the other one so that it is not detected?

I have taken a look at man ifrename and man iftab but really do not understand it. Would you be able to give me an example file for iftab. I am also not too sure how to add it to the default/boot run-level either so that it is before the network.

----------

## think4urs11

If both NIC use different drivers and you definately only need one of them the easiest way would be to remove the support for the second in the kernel config.

If both NIC use the same driver you could create a udev-rule to define which NIC is named how.

----------

## chrismortimore

I did mine by MAC address and driver:

I have the internal ethernet device which uses the b44 driver and I want to be called eth0

I have an internal wireless device which uses the ipw2100 driver and I want to be called wlan0

I have a PCMCIA ethernet device which uses the 8139too driver and I want to be called rtl0

My /etc/iftab:

```
[1][chris@toaster:~]$ cat /etc/iftab

eth*    mac 00:0F:1F:0B:A0:94 driver b44

wlan*   mac 00:0C:F1:29:33:0D driver ipw2100

rtl*    mac 78:06:18:29:35:30 driver 8139too

[1][chris@toaster:~]$
```

The "eth*", "wlan*" and so on just tell it to use the next available number, if you replace the "*" with a number it should work unless something conflicts.

As for the runlevel thing, do something like:

```
depend() {

        before net.eth0

}

start () {

        /sbin/ifrename

}
```

That should do the trick when added to the runlevel.

EDIT: But that udev idea is probably better  :Wink: 

----------

## Evilguru

Hokay, I use the nVidia nForce2 network adapter and not the other one. The result from lspci is:

```

00:00.0 Host bridge: nVidia Corporation nForce2 AGP (different version?) (rev c1)

00:00.1 RAM memory: nVidia Corporation nForce2 Memory Controller 1 (rev c1)

00:00.2 RAM memory: nVidia Corporation nForce2 Memory Controller 4 (rev c1)

00:00.3 RAM memory: nVidia Corporation nForce2 Memory Controller 3 (rev c1)

00:00.4 RAM memory: nVidia Corporation nForce2 Memory Controller 2 (rev c1)

00:00.5 RAM memory: nVidia Corporation nForce2 Memory Controller 5 (rev c1)

00:01.0 ISA bridge: nVidia Corporation nForce2 ISA Bridge (rev a4)

00:01.1 SMBus: nVidia Corporation nForce2 SMBus (MCP) (rev a2)

00:02.0 USB Controller: nVidia Corporation nForce2 USB Controller (rev a4)

00:02.1 USB Controller: nVidia Corporation nForce2 USB Controller (rev a4)

00:02.2 USB Controller: nVidia Corporation nForce2 USB Controller (rev a4)

00:04.0 Ethernet controller: nVidia Corporation nForce2 Ethernet Controller (rev a1)

00:05.0 Multimedia audio controller: nVidia Corporation nForce Audio Processing Unit (rev a2)

00:06.0 Multimedia audio controller: nVidia Corporation nForce2 AC97 Audio Controler (MCP) (rev a1)

00:08.0 PCI bridge: nVidia Corporation nForce2 External PCI Bridge (rev a3)

00:09.0 IDE interface: nVidia Corporation nForce2 IDE (rev a2)

00:0d.0 FireWire (IEEE 1394): nVidia Corporation nForce2 FireWire (IEEE 1394) Controller (rev a3)

00:1e.0 PCI bridge: nVidia Corporation nForce2 AGP (rev c1)

01:04.0 Ethernet controller: Marvell Technology Group Ltd. 88E8001 Gigabit Ethernet Controller (rev 13)

01:09.0 Multimedia audio controller: Creative Labs SB Audigy (rev 04)

01:09.1 Input device controller: Creative Labs SB Audigy Game Port (rev 04)

01:09.2 FireWire (IEEE 1394): Creative Labs SB Audigy FireWire Port (rev 04)

01:0b.0 RAID bus controller: Silicon Image, Inc. SiI 3112 [SATALink/SATARaid] Serial ATA Controller (rev 02)

03:00.0 VGA compatible controller: ATI Technologies Inc Radeon R350 [Radeon 9800 Pro]

03:00.1 Display controller: ATI Technologies Inc Radeon R350 [Radeon 9800 Pro] (Secondary)

```

So as far as I can tell they use totally different drivers/modules. Is there any way to find out what module is providing support for a device? As lsmod is not being all that helpful.

----------

## chrismortimore

So you don't want to use the marvell card?  Disable (under "Ethernet (1000Mbit)") "New SysKonnect GigaEthernet support", and it should do it for you, I'm pretty sure thats the one you want.

----------

## cyrillic

 *Evilguru wrote:*   

> /etc/init.d/net.eth0 and /etc/init.d/net.eth1 are both symlink'ed to /etc/init.d/net.lo. Neither net.eth0 or net.eth1 are on any of my run-levels.
> 
> This makes boot-up times very long, as it attempts to get an IP with both adapters---one will work fine and get an IP from my DHCP server, the other will (after 5+ min) timeout. 

 

Emerge sys-apps/ifplugd

You won't have to configure anything, because support for ifplugd is already builtin to the Gentoo networking scripts.

What will happen is the net.ethx scripts will go into the background (so you won't have to wait during boot), and then DHCP will be attempted only when a cable is plugged into the NIC (and it doesn't matter if the NICs swap names either).

----------

## Evilguru

 *cyrillic wrote:*   

>  *Evilguru wrote:*   /etc/init.d/net.eth0 and /etc/init.d/net.eth1 are both symlink'ed to /etc/init.d/net.lo. Neither net.eth0 or net.eth1 are on any of my run-levels.
> 
> This makes boot-up times very long, as it attempts to get an IP with both adapters---one will work fine and get an IP from my DHCP server, the other will (after 5+ min) timeout.  
> 
> Emerge sys-apps/ifplugd
> ...

 Yep! That did the trick, thanks!

----------

## carpenike

Or just go into your bios and disable the second NIC interface that you aren't using...

Shouldn't even get picked up by lspci I don't think..

----------

## Evilguru

Does anyone know why sys-apps/ifplugd is not included by default, as it seems like a win-win situation for most people: faster boot-ups and smarter when it comes to bringing up interfaces.

----------

## Monkeh

Because it's not a win-win. It doesn't work perfectly with all hardware, it can just get in the way with some setups..

----------

## NeddySeagoon

Evilguru,

Cut your losses and write some udev rules. I have a file called  /etc/udev/rules.d/03-local-net.rules that contains 

```
# Name the eth interfaces correctly

KERNEL=="eth*", SYSFS{address}=="00:26:54:0b:c6:c6", NAME="eth_lan"

KERNEL=="eth*", SYSFS{address}=="00:0c:6e:14:c8:e7", NAME="eth_spare"
```

You cannot use the kernel names eth0 and eth1, since you cannot rename to an existing interface.

*Important* get the MAC addresses for your cards from ifconfig but use lowercase hex letters in the rules because thats what comes out of /sys.

Change your /etc/init.d/ networking symlinks to use the names defined in your rules.

Fix rc-upate and /etc/conf.d/net to use the new names too.  Now it just works.

The name of the rules file is not important, as long as it starts with a number lower than 50, so its used before the defualt rules file provided with udev.

----------

## Monkeh

Neddy, if you use nameif, you can force adapters to use eth0 or eth1 quite easily. A quick search will bring up the init script..

----------

