[ale] Assigning NICs to ethernet devices

Daniel Kahn Gillmor dkg at fifthhorseman.net
Wed Jan 16 23:04:57 EST 2008


On Wed 2008-01-16 19:12:16 -0500, Jeffrey B. Layton wrote:

> I thought would push this out before charter blamed the snow
> for their crappy network. But I was wondering how people
> assign NICs to ethernet devices during installation (and even
> after installation)?  Pick whatever distro you like, I would like
> the ability to assign eth0 to a certain NIC, eth1 to another, and
> so on. I've not had any trouble with FC8 or CentOS, but I'm
> having trouble with a different distro that I'm testing (I don't
> want to say anything since the distro is not really "out" yet).

on modern (>= etch) debian systems running udev, the easiest way to
permanently assign nic's to names is by modifying
/etc/udev/rules.d/z25_persistent-net.rules.  That file is
automagically populated with a MAC-address-matching line upon first
recognition of any ethernet device.  It's simple enough to modify that
line, but then getting udev to re-recognize the device without a
reboot is trickier:

if you only have one device of that class, the simplest thing is to
unload and reload the associated module.  For example, if the device
uses the e100 module, and no other devices that you care about on that
system do:

  modprobe -v -r e100
  modprobe -v e100

udev will name the device with your preferred name as soon as the
module is re-loaded.

But what if you have two e100 devices, say, and you're currently
connected via ssh via one of them which you don't want to get
deconfigured while you're working on this?  In that case, you'll want
to use sysfs-style device unbinding/binding to keep the module loaded,
but make the device show up anew:

 http://lwn.net/Articles/143397/

> Also, is there a nice simple tool that allows you to move NICs and
> device names that also allows you to configure the interface (IP,
> netmask, gateway, etc.) and will fix up the routing table for you?

You're probably looking for /bin/ip, which is part of the iproute (or
iproute2, depending on your distro) package.

For example:

  ip link set eth0 name fubar
  ip link set fubar up
  ip addr add 10.11.12.13/24 dev fubar
  ip route add default via 10.11.12.1 dev fubar

It is well worth your while to learn this tool, even if you already
feel comfortble with netstat, ifconfig, and route.  Not only is
iproute becoming the recommended network configuration suite on
GNU/Linux, but it logically and clearly breaks apart the different
layers of the modern networking stack, which can help to understand
it.

hth,

        --dkg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 826 bytes
Desc: not available




More information about the Ale mailing list