[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Controlling eth0,eth1,... assignment order?



On Fri, 30 Dec 2005 00:52:26 +0100
Svante Signell <svante.signell@telia.com> wrote:

> With the new way of device creation and module loading (udev, discover
> etc) my ethernet modules (3c59x,8139too) are loaded in different order
> with kernels 2.6.12 and 2.6.14. For 2.6.14 3c59x is loaded first
> corresponding to eth0 and then 8139too corresponding to eth1. With
> kernel 2.6.12 they are loaded in reverse order, giving the wrong names
> on my interfaces, and the interfaces defined in /etc/network/interfaces
> becomes wrong. How to bind modules to eth interface numbers? Any hints
> on which of the /etc/modules, /etc/modules.conf etc should be used, and
> which are obsolete?

An explanation I saw in another post explained that with newer kernels
in Debian hardware is initialized asynchronously so you never know which
card will become eth0 and which eth1 and this matches what I
experienced with my cards. 

If all you need to do is apply the correct configuration to the correct
interface and don't have a reason to care which card is designated eth0
and which is designated eth1 then you could copy the script
get-mac-address.sh from /usr/share/doc/ifupdown/examples
into /etc/network and map the configuration to the mac address of each
card with some text in /etc/network/interfaces like:

auto eth0 eth1
mapping eth0 eth1
        script /etc/network/get-mac-address.sh
        map 00:00:00:00:00:00 wireless
        map 11:11:11:11:11:11 ethernet

: In this example you would then create interface entries for wireless
and ethernet the same as you would have otherwise done for eth0 and
eth1:

iface wireless inet static
         name Wireless LAN card
	 address 192.168.1.10
         netmask 255.255.255.0
         gateway 192.168.1.1
         dns-nameservers 204.127.198.4 63.240.76.4
         wireless_essid your_essid
         wireless_key1 your_128_or_64_bit_encryption_key
         broadcast 192.168.1.255
         network 192.168.1.0
         multicast 192.168.1.0 255.255.255.0

iface ethernet inet static
         address 192.168.2.1
         netmask 255.255.255.0
         name Ethernet LAN card
         broadcast 192.168.2.255
         network 192.168.2.0
 
: This worked for me. If I booted one time and my wireless interface
was designated eth0 it got the correct configuration and if it got
designated eth1 it still got the correct configuration.

If you need a specific card to be eth0 or eth1 (in my case firestarter
requires this) then instead of the above you would create a udev rule.

Based on previous posts on the list I created a file in /etc/udev/
named static-nic.rules with the contents:

# /etc/udev/static-nic.rules
#
# Set permission to 0644  'chmod 0644 static-nic.rules', then symlink
#'ln -s static-nic.rules rules.d/025_static-nic.rules'
#
# Purpose:
# Mapping specific MAC address to specific device names for cases where
#  that is expected.
#
# SYSFS{address}="MAC address" - MAC address should be the machine
# address of the network card the rule is for.
#
# NAME="name" - name is the device name you want used for the interface.
# These could be standard names eth0, wlan0, etc... or if you prefer
# something more descriptive lan, internet, wireless, whatever...

KERNEL="eth*", SYSFS{address}="00:00:00:00:00:00", NAME="eth0"
KERNEL="eth*", SYSFS{address}="11:11:11:11:11:11", NAME="eth1"

#end

: This way eth0 is always mapped to my wireless card and eth1 is always
mapped to my ethernet card.

Later, Seeker



Reply to: