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
Answertopia.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.6.3 Automatic network configuration using ifupdown

Interface names can be "mapped" to other names when ifup runs. How names are mapped can be made to depend on circumstances. Thus ifup can be so configured that it brings up a given physical interface as the appropriate logical interface among a set of predefined alternatives.

Logical interface name mapping occurs as follows:

  • If no logical interface name is given on the ifup command line then the physical interface name is used as the initial logical interface name.

  • If the logical interface name matches the glob-pattern of a mapping stanza then that mapping is applied to generate a new logical interface name. This is done for each mapping stanza in turn.

  • If the final logical interface name is the label of a logical interface definition in /etc/network/interfaces then the physical interface is brought up as that logical interface. Otherwise ifup prints a message that it is "Ignoring unknown interface" and exits.

The syntax of a mapping stanza is:

     mapping glob-pattern
             script script-name
             [map script input]

The script named in the mapping stanza is always run with the physical interface name as its argument and with the contents of all following "map" lines in the stanza (without the word "map" itself) provided to it on its standard input. The script prints the result of the mapping on its standard output before exiting.

For example, the following mapping stanza will cause ifup to bring up interface eth0 as the home logical interface.

     mapping eth0
             script /usr/local/sbin/echo-home

where /usr/local/sbin/echo-home is:

     #!/bin/sh
     echo home

Because mapping is done with a script it is possible to select the logical interface automatically — based on some sort of test. See Logical interface selection using guessnet, Section 10.6.3.1 for an example of this.


10.6.3.1 Logical interface selection using guessnet

Install guessnet and then add a stanza like the following to /etc/network/interfaces:

     mapping eth0
             script guessnet-ifupdown
             map home
             map work

Now when you ifup eth0, guessnet will check whether eth0 can be brought up as home or work. To do this it uses information stored in the logical interface definitions.


Debian GNU/Linux Reference Guide
Prev Home Next

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