Experimental package available: ifupdown-roaming
Abstract: Debian does not contain an adequate automagical
network configurer at present. So I have begun writing
one and have packaged it as "iupdown-roaming". Try it out!
========================================================
I have been looking for software that will automagically
configure network interfaces with as little user intervention
as possible, and with as little need for configuration as
possible. The following packages already exist in Debian.
(If there are any others, please let me know.)
* ifupdown: Configure or deconfigure network
(These are the standard Debian tools for
configuring and deconfiguring a network
interface.)
* netenv: At boot time, set environment variables to
manually selected values. This can be used
to switch between network configurations.
* switchconf: Manually select configuration files.
This can be used to switch between network
configurations.
* divine: (replaced by intuitively)
* intuitively: Select network configuration for
current environment
* laptop-netconf: Select network configuration for
current environment
* ifplugd: Continually enable or disable Ethernet
interface according to presence of link beat
* laptop-net: Continually select network configuration
for current environment
* whereami: On boot, APM event, pcmcia event, or
execution, clock state machine. Tests and actions
are furnished that are useful for testing current
environment and for configuring the network
* guessnet: Report current network environment. This
can be used as an ifupdown "mapping" script to
select configuration for current environment.
ifupdown does not work correctly if other utilities
independently futz with network configuration. Therefore,
any adequate solution must be one that either replaces
ifupdown entirely or else cooperates with it somehow.
intuitively and laptop-netconf are network configuration
switchers that automatically select the right configuration
for the current environment by scouting for hosts on the
network (using tools such as ping and arping). ifplugd is
a daemon that monitors an Ethernet interface for link beat
starting or ending and runs scripts. This can be used to
run one of the preceding utilities or ifup/ifdown. With
further hook scripts inserted in /etc/init.d and /etc/rc*.d
and in /etc/apm/event.d to run the configurer on bootup and
on APM events, this would add up to a fairly well automated
configurer. To make this work with the PCMCIA subsystem,
one would replace the default start_fn() and stop_fn() in
/etc/pcmcia/network.opts (which call ifup and ifdown) with
calls to the configurer. laptop-net is like laptop-netconf
plus ifplugd combined with well written documentation in a
well thought out package. Unfortunately, none of the above
cooperates with ifupdown. whereami is also flawed in that
respect, and, although it is highly configurable, it is
more of a toolkit than an application. It requires a lot
of configuration and its hooks haven't been thought out
properly. To make this work with the PCMCIA subsystem,
one would delete the default start_fn() and stop_fn() in
/etc/pcmcia/network.opts (which call ifup and ifdown) and
set WHEREAMI=y. guessnet, on the other hand, is designed
to integrate into ifupdown: it is a script that "maps" the
specified "physical interface" to the first "logical
interface that it finds by scouting around. When using
guessnet, ifplugd and boot and APM hook scripts can be
configured to run ifdown and ifup, which calls guessnet.
The disadvantage of guessnet is that it is not very
configurable.
I think it is possible to make something better than
guessnet, so I have started work on a package of utilities
that will provide more fully automatic network configuration
by cooperating with ifupdown. I have cooked up a package
called "ifupdown-roaming". Its key component is a script
called "ifscout". Like guessnet, ifscout is a mapping
script for ifupdown. Unlike guessnet, ifscout uses
ifupdown's /etc/network/interfaces file to store all its
configuration information. This makes ifscout easier to
set up.
To see how it works, let us define two logical interfaces,
"home" and "work", for eth0. /etc/network/interfaces might
look something like the following.
auto lo
iface lo inet loopback
mapping eth0
script /usr/local/sbin/ifscout
map office home
iface home inet static
address 192.168.0.1
netmask 255.255.255.0
gateway 192.168.0.254
up cp -a /an/important/file /my/backup/directory
up set-mail-relay 192.168.0.10
down set-mail-relay queue
up set-named-forwarders 192.168.0.20
iface office inet dhcp
up set-mail-relay 163.18.25.22
down set-mail-relay queue
Note that ifscout is named as the mapping script for eth0
and the office and home logical interfaces are listed on
the following "map" line. This means that when "ifup eth0"
is executed, ifscout will first try the "office"
configuration (by attempting to obtain a dhcp lease) then
the "home" configuration (by setting the indicated address
and netmask and trying to ping the gateway). It returns
the name of the first logical interface it detects, and
ifup proceeds to configure that using the appropriate
values and to run the appropriate "up" scripts.
(The set-mail-relay and set-named-forwarders scripts are
cribbed from the whereami package.) The scouting procedure
for a statically configured logical interface can be
modified by adding lines like these:
peer 192.168.0.99 ma:ca:dd:re:ss
which will make ifscout ping 192.168.0.99 instead of the
gateway and will compare the MAC address it reports (in
response to an ARP request) with ma:ca:dd:re:ss.
Alternatively, an arbitrary test script can be specified
for any logical interface:
test mycustomscript --option1=val2
Whatever is specified here should return success (status 0)
if this logical interface is to be used; otherwise failure.
There is no limit to the number of logical interfaces that
can be specified. Thus, a /etc/network/interfaces file for
a system that roams more networks might look like this:
auto lo
#pm-auto eth0
iface lo inet loopback
mapping eth0
script /usr/local/sbin/ifscout
map office0 office1 home
mapping eth1
script /usr/local/sbin/ifscout
map office2 bruces
iface home inet static
address 192.168.0.1
netmask 255.255.255.0
gateway 192.168.0.254
peer 192.168.0.4 03:a3:93:02:93:18
up cp -a /an/important/file /my/backup/directory
up set-mail-relay 192.168.0.10
down set-mail-relay queue
up set-named-forwarders 192.168.0.20
iface bruces inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
test /usr/local/sbin/niftyscript --option1=3
iface office0 inet dhcp
up set-mail-relay 163.18.25.22
down set-mail-relay queue
iface office1 inet dhcp
test mycustomscript --option1=val2
up set-mail-relay 211.180.10.19
down set-mail-relay queue
iface office2 inet static
address 10.0.20.3
netmask 255.255.0.0
gateway 10.0.1.1
up set-named-forwarders 10.0.2.1
up set-mail-relay 10.0.2.1
down set-mail-relay queue
With such a setup one's interface will be reconfigured every
time it is upped with ifup. To increase automation, one
wants ifup to be run on events such as (1) boot, (2) APM
resume, (3) PCMCIA network card insertion, (4) restoration
of Ethernet cable, etc.
(1) ifup is already run at boot time by /etc/init.d/ifupdown.
(2) The ifupdown-roaming package includes a hook script in
/etc/apm/event.d which downs interfaces before suspend and
ups them again on resume. The line beginning with
"#pm-auto" in /etc/network/interfaces names the physical
interfaces to which this should be done. (For now this
keyword has to start with a "#" so that ifup and ifdown
won't gag on it.) (3) The default settings in
/etc/pcmcia/network.opts will cause the inserted interface
to be configured by ifup and deconfigured by ifdown.
Be sure not to set any of WHEREAMI, DHCLIENT, PUMP, BOOTP
or DHCP to "y". (4) This package can be used with the
ifplugd package. The ifplugd daemon will call ifup when
the Ethernet adapter detects a link beat (presence of
active network cable) and ifdown when the link beat
disappears (cable disconnected). Note that ifplugd uses
its own configuration files: set INTERFACES=eth0 in
/etc/ifplugd/ifplugd.conf to monitor eth0, and make sure
that /etc/ifplugd/ifplugd.action is set up to call ifup
and ifdown. For interfaces on PCMCIA cards, ifplugd
should not call ifup or ifdown directly but should signal
cardmgr by means of such commands as "cardctl suspend";
cardmgr will in turn run ifup or ifdown as appropriate
(if the pcmcia-cs package is set up correctly, natch).
Current Linux kernels run the hot-plugging script
/sbin/hotplug when a network card is hot-plugged. The
current default configuration of the hotplug package will
cause ifup to be called whenever a new network card is
found. This happens even if the card is a PCMCIA card.
Since this duplicates what the pcmcia-cs package already
does, this part of hotplug had better be disabled. If
required, edit /etc/hotplug/net.agent to delete the calls
to ifup and ifdown.
Also, do not install whereami; or if you do install it,
remove the file /etc/network/if-pre-up.d/whereami
which is a brain-damaged attempt to hook whereami into
ifup, even though it is not compatible with ifup.
Also make sure that whereami is not called at boot or
on APM events. If you want to make use of the nifty
scripts in the whereami package then the safest thing to
do is install the package, copy the scripts and then
purge the package.
I would like to know which scripts from other packages
(whereami, etc.) you would like to see included in
ifupdown-roaming. This includes both custom detection
scripts and action scripts such as set-named-forwarders
and set-mail-relay.
ifupdown-roaming is little more than a proof of concept
at the moment, even though it Works For Me (tm). The
ifscout script parses /etc/network/interfaces and isn't
won't be very tolerant of non-standard formatting at
present. You are welcome to try it by downloading the deb:
http://panopticon.csustan.edu/thood/ifupdown-roaming.html
provided you forgive me for the abominable awk script in
ifscout and resolve to send me all and only constructive
criticisms (which could includes the criticism "This was
a big waste of time, because yadda yadda yadda.").
--
Thomas Hood
jdthood@yahoo.co.uk
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
Reply to: