Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Debian GNU/Linux Reference Guide
Prev Home Next

10.7 Dealing with inconsistent naming of interfaces by the kernel

The names eth0, eth1, etc. are assigned by the kernel in the order that the kernel creates the interfaces that go by those names. While adapters that are detected at boot time are usually detected in the same order every time, and are therefore assigned the same names every time, the same is not true of adapters that are hot plugged. These can be detected in any order and end up getting assigned different names by the kernel on different occasions.

Because of this fact, on a system into which network adapters are hot plugged it won't always do to define logical interfaces in /etc/network/interfaces with names eth0, eth1, etc., and to rely on the default mapping. Instead you must give distinct names to the logical interfaces and use one of the following two methods to restrict which logical interfaces can be assigned to which adapters.

One method is to use either the nameif utility (in the net-tools package) or the more flexible ifrename utility (in the ifrename package) to make the kernel assign names to interfaces according to properties of the underlying adapters. With this naming scheme in effect, the physical interface name can be used to infer which adapter underlies it.

Another method is to use ifup's mapping mechanism in such a way that a logical interface is chosen for a physical interface being brought up according to some property of the adapter that underlies it.

Suppose, for example, you have two different network adapters which you use with networks net1 and net2, respectively. The /usr/share/doc/ifupdown/examples/ directory contains a mapping script that can be used to select a logical interface based on the Media Access Controller address (MAC address) of the adapter. First install the script to an appropriate directory.

     # install -m770 /usr/share/doc/ifupdown/examples/get-mac-address.sh \
        /usr/local/sbin/

Then add a stanza like the following to /etc/network/interfaces:

     mapping eth0
             script /usr/local/sbin/get-mac-address.sh
             map 02:23:45:3C:45:3C net1
             map 00:A3:03:63:26:93 net2

See Multi-stage mapping, Section 10.9 for a more complex example.

In applying either method the property that is most commonly used to identify the adapter is the MAC address.


Debian GNU/Linux Reference Guide
Prev Home Next

 
 
  Published under the terms of the GNU General Public License Design by Interspire