Package: ifupdown
Version: 0.6.4-4.10


This is not a bug report but an appendix to the existing documentation
that I wrote.  I think it should go to

   /usr/share/doc/ifupdown/contrib/dirty-mini-howto.txt

or similar.  Even if it doesn't qualify as a HOWTO due to its
structure, I am sure it will be more useful than harmful.  Also,
seeing my text in the debian might make me want to improve on it.  (-:





A FEW BASICS ON THE /etc/network/interfaces FILE
================================================
(by Matthias Fischmann <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>)
(thanks to Joey Hess <[EMAIL PROTECTED]> for the ifupdown manpage)



The interfaces file consists of three types of blocks: 'auto',
'iface', and 'mapping'.  Each block starts with a line in the first
column and potentially continues with more lines that all start with
whitespace.  blocks are separated with empty lines.  additional empty
lines and lines starting with a '#' are ignored.

'iface' is relatively straight-forward.  three examples:

----------------------------------------------------------------------
iface lo inet loopback

iface eth0 inet static
   address 10.0.0.5
   netmask 255.255.255.0
   gateway 10.0.0.1

iface wlan0 inet dhcp
   wireless-mode managed
   wireless-essid any
   wireless-key open
----------------------------------------------------------------------

The first block declares the loopback interface, the second gives a
static IP address to eth0 in a local class-C network with gateway
10.0.0.1, and the third gives a dynamic IP address to wlan0 via dhcp.

The parameters 'address', ... and 'wireless-mode', ... are passed
through to lower levels (in this case, ifconfig and iwconfig,
respectively).  Not much processing by ifup or ifdown here.

'auto' is even easier to understand:

----------------------------------------------------------------------
auto lo
auto eth0
----------------------------------------------------------------------

Now, if 'ifup -a' (or 'ifdown -a') is called, lo and eth0 are switched
on (or off).

'lo', 'eth0' and wlan0' are called PHYSICAL DEVICES.  You may have
several different settings in which you want to use the same physical
device.  For example, you connect your laptop to wlan in several
offices, at home, and in internet cafes.  This is what LOGICAL DEVICES
are for.  Another example:

----------------------------------------------------------------------
iface wlan0-any inet dhcp
        wireless-mode managed
        wireless-essid any
        wireless-key open
        
iface wlan0-home inet dhcp
        wireless-mode managed
        wireless-essid Welcome Neighbour
        wireless-key open

iface wlan0-university inet dhcp
        wireless-mode managed
        wireless-essid Wireless Campus Network FUT
        wireless-key restricted 12-34-56-67-91
        # Key1: 4857928758
        # Key2: 1234566791
----------------------------------------------------------------------

If you want to start a physical device using a specific logical
device, you simply type:

----------------------------------------------------------------------
ifup wlan0=wlan0-home
----------------------------------------------------------------------

In fact, 'ifup wlan0' is only a shortcut for 'ifup wlan0=wlan0'.
Knowing this will make some error messages much easier to understand,
and thus much less scary.

Note that logical device names are arbitrary.  It is not required that
you call your logical devices after the physical device.  This just
makes it easier to understand the configuration file.

These features should help you use ifupdown in many cases already.
Only for advanced hotplugging and autodetection needs you need the
third type of blocks, called 'mapping'.  I cannot say that I have
fully understood it, or how to use it together with hotplug(8), but
here is what I have figured out:

----------------------------------------------------------------------
mapping eth0
   script /usr/local/sbin/map-scheme
   map HOME eth0-home
   map WORK eth0-work
----------------------------------------------------------------------

The script /usr/local/bin/map-scheme can figure out where you are,
ideally without user intervention.  In the above example, the physical
device 'eth0' is mapped on either one of the logical devices
'eth0-home' or 'eth0-work'.

The script takes as command line parameter the logical interface and
the lines starting with 'map' (but with the 'map' removed) on standard
input.  It only outputs one word on stdout, which is interpreted as
the name of the chosen logical interface.

The reason why the lines starting with 'map' are listed in the
interfaces file instead of in the script are a little opaque to me (as
are the potential useful things the script can figure out on its own).
I just figure that it is a way to separate individual network
configurations from code.  This way, it is easier to write scripts
that can be reused in many different settings.

Open questions concering mappings: What happens if we write
'eth0=HOME'?  Is 'eth0' in the mapping in fact a logical device, and
only implicitly linked to the physical device of the same name?  Does
it have to be a prefix of the logical devices 'eth0-home', 'eth0-work'
that it maps to?  Can mappings be stacked?  But most importantly: What
are they good for, really?

But 'iface' and 'auto' really work, are intuitive (once you understood
it), and make your life a lot easier.

Attachment: signature.asc
Description: Digital signature

Reply via email to