Skip navigation.
Home
Now Shipping Version 7.0

eth1 vs eth0 assignment


Posts: 19

I have two NIC cards on the PC. One boot, the onboard NIC
gets eth0 and the PCI card gets eth1. Another boot, eth1
and eth0 assignments are the opposite, swapped. How can
I tell Mepis to fixed-assign eth0 and eth1 to the cards ?

It brings my networking down when eth1/eth0 assignment happens inconsistently.

Thanks
Yakov

m_pav's picture

udev rule

You need to create a udev rule to pin the network cards to a device name at boot.

First you need to find the mac address of the card you want to be eth0.

If the that card is now eth0 , open a Konsole and use the command:
udevinfo -a -p /sys/class/net/eth0

if it's currently at eth1 instead use:
udevinfo -a -p /sys/class/net/eth1

Leave that window open so you can copy and paste in a moment.

As root open an editor (a good way is F2 kdesu kedit) and enter this:
KERNEL=="eth*", SYSFS{address}=="00:00:00:00:00:00", NAME="eth0"

In place of the SYSFS{address} line, paste in the SYSFS{address} line from the output you got from udevinfo.

Save this file in the /etc/udev/rules.d directory with the name: 11-local.rules

When you reboot this script will make sure that the card with that mac address is named eth0. The other one will end up as eth1 by default.

If for any reason, the other card tries to use eth0 ahead of the card with the pinned address, you might end up with no connected network interfaces at all. If that happens, put in a second line with the mac address of the other card.

I use this for my wireless card to get it away from the eth hardware address, otherwise I have no end of troubles with my wireless device swapping names with my wired device.

My /etc/udev/rules.d/11-local.rules contains the following, but I have changed all but the start and end characters with xx for security reasons.

KERNEL=="eth*", SYSFS{address}=="00:xx:xx:xx:xx:b3", NAME="ath0"
KERNEL=="eth*", SYSFS{address}=="00:xx:xx:xx:xx:77", NAME="eth0"

Mike P

--------------------
Life may not be the party we thought, but while we're here, we may as well dance.
Break M$'s shackles from your feet and free yourself with Mepis

Thanks

Thanks

/etc/iftab

Rather than using a direct udev rule, you could use the /etc/iftab file to assign the names to your ethernet devices.

The /etc/iftab file is used by udev.

Doing a 'man iftab' gives an explanation of how things work as well as provides a sample set of entries. I include that example below.

EXAMPLE
# This is a comment
eth0 mac 00:12:79:59:8D:38
eth1 mac 00:0B:CD:5C:9E:2A arp 1
nveth* SYSFS{device/vendor} 0x10de

So have a choice of at least methods - one more direct than the other - to solve the problem of card assignments at boot time.

Regards,

Aspidastra

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.