Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Controlling eth0,eth1,... assignment order?

335 views
Skip to first unread message

Svante Signell

unread,
Dec 29, 2005, 7:20:11 PM12/29/05
to
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?

Thanks,
--
Svante Signell <svante....@telia.com>


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Stefhen Hovland

unread,
Dec 29, 2005, 7:20:16 PM12/29/05
to
i think ifrename will do what you are asking, you can specify that
eth0 always be bound to x, and eth1 always bound to y, etc..


http://packages.debian.org/unstable/net/ifrename

stefhen

Lorenzo Bettini

unread,
Dec 30, 2005, 4:10:14 AM12/30/05
to
Svante Signell 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?
>
> Thanks,

there's a way to deal with this in the debian documentation (but I don't
have it with me right now).

Here's what I do in my laptop for wired and wireless interface:

http://www.lorenzobettini.it/linux/LinuxSonyVaioVGN-S5VP_B

hope this helps
Lorenzo

--
+-----------------------------------------------------+
| Lorenzo Bettini ICQ# lbetto, 16080134 |
| PhD in Computer Science |
| Dip. Sistemi e Informatica, Univ. di Firenze |
| Florence - Italy (GNU/Linux User # 158233) |
| Home Page : http://www.lorenzobettini.it |
| http://music.dsi.unifi.it XKlaim language |
| http://www.purplesucker.com Deep Purple Cover Band |
| http://www.gnu.org/software/src-highlite |
| http://www.gnu.org/software/gengetopt |
| http://www.lorenzobettini.it/software/gengen |
| http://www.lorenzobettini.it/software/doublecpp |
+-----------------------------------------------------+

Vincent Lefevre

unread,
Dec 30, 2005, 10:10:15 AM12/30/05
to
On 2005-12-29 19:13:26 -0500, Stefhen Hovland wrote:
> i think ifrename will do what you are asking, you can specify that
> eth0 always be bound to x, and eth1 always bound to y, etc..
>
> http://packages.debian.org/unstable/net/ifrename

Otherwise this can be done with a simple mapping, e.g.

auto eth0 eth1

mapping eth*
script /usr/local/sbin/map-scheme

and in the map-scheme script,

mac=$(/sbin/ifconfig "$1" | \
sed -n '/^.*HWaddr \([:[:xdigit:]]*\).*/{s//\1/;y/abcdef/ABCDEF/;p;q;}')

which contains the MAC address. The advantage is that one can put
other things, such as netenv-related ones.

--
Vincent Lefèvre <vin...@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / SPACES project at LORIA

Seeker5528

unread,
Jan 2, 2006, 6:50:13 AM1/2/06
to
On Fri, 30 Dec 2005 00:52:26 +0100
Svante Signell <svante....@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

Thomas Jollans

unread,
Jan 2, 2006, 7:00:38 AM1/2/06
to
Stefhen Hovland wrote:

>i think ifrename will do what you are asking, you can specify that
>eth0 always be bound to x, and eth1 always bound to y, etc..
>
>
>http://packages.debian.org/unstable/net/ifrename
>
>stefhen
>
>On 12/29/05, Svante Signell <svante....@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?
>>
>>

udev should work here. you can set it up. You can set up devices to have
certain names (e.g. you camera as /dev/camera) with it , and I heard
this works with network interfaces too. google is your friend if you
want more informtion, I hope.

Svante Signell

unread,
Jan 3, 2006, 7:10:32 AM1/3/06
to
Thank you for your advice and scripts. I will try both solutions, the
first on my laptop and the second on the desktop. The laptop has both
wireless and ethernet access but interface naming is not important. On
the desktop I have packet filtering and the rules are depending on the
interface names, eth0 external I/F and eth1 internal I/F.

--
Svante Signell <svante....@telia.com>

Svante Signell

unread,
Feb 27, 2006, 3:00:21 PM2/27/06
to
The solution given below has been working for some time now, until udev
0.085-1 from Feb 19 was installed. Then the behaviour is wrong again,
eth0 is associated to the 8139too driver and eth1 is associated to the
3c59x driver. What has changed in the udev functionality? The
file /etc/udev/static-nic.rules linked
to /etc/udev/rules.d/025_static-nic.rules does not seem to be run at
startup anymore :-( This issue should probably be an FAQ by now. Any
pointers??

Thanks,
Svante

On Tue, 2006-01-03 at 12:10 +0100, Svante Signell wrote:
> Thank you for your advice and scripts.

...


> On
> the desktop I have packet filtering and the rules are depending on the
> interface names, eth0 external I/F and eth1 internal I/F.
>
> > On Fri, 30 Dec 2005 00:52:26 +0100
> > Svante Signell <svante....@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.
> >

...


--

Florian Kulzer

unread,
Feb 27, 2006, 3:30:24 PM2/27/06
to
Svante Signell wrote:
> The solution given below has been working for some time now, until udev
> 0.085-1 from Feb 19 was installed. Then the behaviour is wrong again,
> eth0 is associated to the 8139too driver and eth1 is associated to the
> 3c59x driver. What has changed in the udev functionality? The
> file /etc/udev/static-nic.rules linked
> to /etc/udev/rules.d/025_static-nic.rules does not seem to be run at
> startup anymore :-( This issue should probably be an FAQ by now. Any
> pointers??

Are you sure that the rules are not read at bootup anymore, or are you
just inferring this from the incorrect assignment of the interface
names? Other people also have reported problems with the solution you
refer to, and at least in some cases the following workaround helped:
http://lists.debian.org/debian-user/2006/01/msg03434.html

(I have not used my laptop in a while, and my desktop has only one
network interface, therefore I do not know if this still works with
the newest udev. Worth a try, I hope.)

Regards,
Florian

Svante Signell

unread,
Feb 27, 2006, 4:50:12 PM2/27/06
to
> Florian Kulzer wrote:
>
> > Svante Signell wrote:
> >
> > The solution given below has been working for some time now, until udev
> > 0.085-1 from Feb 19 was installed. Then the behaviour is wrong again,
> > eth0 is associated to the 8139too driver and eth1 is associated to the
> > 3c59x driver. What has changed in the udev functionality? The
> > file /etc/udev/static-nic.rules linked
> > to /etc/udev/rules.d/025_static-nic.rules does not seem to be run at
> > startup anymore :-( This issue should probably be an FAQ by now. Any
> > pointers??

> Are you sure that the rules are not read at bootup anymore, or are you
> just inferring this from the incorrect assignment of the interface
> names? Other people also have reported problems with the solution you
> refer to, and at least in some cases the following workaround helped:
> http://lists.debian.org/debian-user/2006/01/msg03434.html

I don't really know if the rules are read at bootup since dmesg does not
catch this and the messages on the screen during bootup are scrolled to
far away to be visible. I'll try the solution indicated in the message
above and report later. Pleass Cc: me since I'm not subscribed to the
debian-user mailing list.

> (I have not used my laptop in a while, and my desktop has only one
> network interface, therefore I do not know if this still works with
> the newest udev. Worth a try, I hope.)
>
> Regards,
> Florian

Thanks,
--
Svante Signell <svante....@telia.com>


seeke...@comcast.net

unread,
Feb 28, 2006, 3:40:12 AM2/28/06
to
On Mon, 27 Feb 2006 20:36:35 +0100
Svante Signell <svante....@telia.com> wrote:

> The solution given below has been working for some time now, until udev
> 0.085-1 from Feb 19 was installed. Then the behaviour is wrong again,
> eth0 is associated to the 8139too driver and eth1 is associated to the
> 3c59x driver. What has changed in the udev functionality? The
> file /etc/udev/static-nic.rules linked
> to /etc/udev/rules.d/025_static-nic.rules does not seem to be run at
> startup anymore :-( This issue should probably be an FAQ by now. Any
> pointers??
>
> Thanks,
> Svante

Even though the old version of the script worked I think technically
the script was never correct. Maybe it was just udev being changed to
more closely match behaviour as it is expected to be applied else where?
Whatever the case I had to modify the script changing things that were
being evaluated to a == sign where before I had a single = sign which
now gets interpreted as setting a value. What I am using currently
looks like this:

# Start of udev rule for static ethernet device names.
#
# Place in /etc/udev then from the command line do 'chmod 0644' then
# 'ln -s /etc/udev/static-nic.rules /etc/udev/rules.d/025_static-nic.rules'
#
# Mapping specific MAC address to specific device names to ensure
# predictable behaviour with things that expect a specific network card
# to show up with the same name.
#
# SYSFS{address}=="MAC address" - MAC address should be the machine
# address of the network card the rule is for. Double == because this
# is a comparison


#
# 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, etc... Single =
# because we are setting the name

KERNEL=="eth*", SYSFS{address}=="00:01:02:03:04:05", NAME="wireless"
KERNEL=="eth*", SYSFS{address}=="10:11:12:13:14:15", NAME="ethernet"

# End udev rule

0 new messages