Configuration Tools


Do you use your laptop in different network environments? At home? In the office? At a customers site?

If yes, the small package "netenv" might be useful for you. When booting your laptop it provides you with a simple interface from which you can choose the current network environment. The first time in a new environment, you can enter the basic data and save it for later reuse.

Netenv sets up a file containing variable assignments which describe the current environment. This can be used by the PCMCIA setup scheme, e.g. like the one that comes with Debian/GNU Linux and perhaps others.

The netenv data can be used for things like:

  1. Network Device: Configure the network device for different environments.

  2. Choose a proper XF86Config: Think of using your laptop standalone with touchpad vs. connected to a CRT monitor along with an external mouse. For example, a wheel mouse could be used when docked, but the driver is not compatible with the normal trackpoint or touchpad.

  3. Windowmanager: You can set up your windowmanager appropriate to the current location of your machine.

  4. Printing Environment: The netenv data can easily be used to set up the printing environment.

Netenv is available as Debian/GNU Linux package as well as tarball. It depends on dialog(1) for the menu system. It is developed by Gerd Bavendiek, you may get it at netenv home .


divine is an utility for people who use their machines in different networks all the time. "The idea is this:

The point about divine in contrast to other solutions is that other solutions normally use ping or something like that. divine can check a large number of networks instantaneously, assuming that the machines you ping answer within one second (.4 seconds are normal on Ethernets). And pinging an unknown address will do an arp request anyway, so why not do an arp request in the first place?"

Mobile IP

From the NET3-4-HOWTO: "The term IP Mobility describes the ability of a host that is able to move its network connection from one point on the Internet to another without changing its IP address or losing connectivity. Usually when an IP host changes its point of connectivity it must also change its IP address. IP Mobility overcomes this problem by allocating a fixed IP address to the mobile host and using IP encapsulation (tunneling) with automatic routing to ensure that datagrams destined for it are routed to the actual IP address it is currently using."

HUT Mobile IP is a dynamical, hierarchical Mobile IP system for Linux operating system. The implementation enables a hierarchical model for IP mobility, thus decreasing the location update times as a mobile host moves. Dynamics system has been designed Wireless LAN technology in mind, and the system has optimized functionality for mobility in WLAN. There is now a mailing list available. You can join it by sending subscribe on the subject line to <> - or you can simply check the mail archive.


DHCP and BootP are also useful for working in different environments. Please see the DHCP-HOWTO and BootP-HOWTO.

PPPD Options

The pppd command can be configured via several different files: pppd file /etc/ppp/<your_options> .


You may even choose to do your configuration by editing the /etc/init.d files manually.

PCMCIA - Schemes

How can I have separate PCMCIA device setups for home and work? This is fairly easy using PCMCIA scheme support. Use two configuration schemes, called home and work. For details please read the appropriate chapter in the PCMCIA-HOWTO by David Hinds.



From <Martin J. Evans> I have taken this recommendation: The first point to note is that init will take any arguments of the form name=value as environment variable assignments if they are not recognized as something else. This means you can set environment variables from the LILO boot prompt before your rc scripts run. I set the LOCATION environment variable depending on where I am when I boot Linux. e.g.
LILO: linux LOCATION=home
LILO: linux LOCATION=work
Or simply
LILO: linux
where failing to set LOCATION means the same as LOCATION=home (i.e. my default). Instead of typing LOCATION=place each time you boot you can add an entry to your /etc/lilo.conf file and use the append instruction. e.g.
# Linux bootable partition for booting Linux at home
image = /vmlinuz
root = /dev/hda3
label = linux
# Linux bootable partition config ends
# Linux bootable partition for booting Linux at work
image = /vmlinuz
root = /dev/hda3
label = work
# Linux bootable partition config ends
With the example above you can use "linux" for booting at home and "work" for booting at work.

Armed with the facility above, you can now edit the relevant rc scripts to test ENVIRONMENT before running ifconfig, setting up route etc.

Other Bootloaders

There are several other bootloaders which are often overlooked. Besides LILO, have a look at loadlin, CHooseOS (CHOS) (not GPL), GRand Unified Bootloader (GRUB), System Commander and take a look at The MicroSoft Windows-NT boot loader or OS/2 boot loader may even be used.


From Steve <> I got a configuration for X Windows with an external monitor: Note that I have introduced a neat trick! For my nice 17" monitor I start X11 with no options and get the default 16-bit 1152x864 display - but when using the LCD screen I specify a 15-bit display (startx -- -bpp 15) and get the correct 800x600 resolution automatically. This saves having to have two X11 config files.


A short introduction about how to setup email on a laptop used at home (dial-up) and work (ethernet) by Peter Englmaier <>:


As a laptop user, I have special demands for my email setup. The setup described below, enables me to:

  • Read my email from home using a POP email server, which is supplied by my university, but could also be setup on a work place computer.

  • Write email from home with the right return address in the email (which does not mention my computer name).

  • Read/write my email while working on a workstation without access to my laptop or the POP email server (as a backup).

  • Read my email while working on my laptop connected to the ethernet of our institut.

  • Direct email while connected via ethernet (faster than the fetchmail method).

  • Indirect email (over pop mail server) while not connected to the ethernet at work (either at home via modem or somewhere else via ethernet).

  • Use any emailer, e.g. elm or the simple mail command.

  • Sort incomming email, delete spam, split email-collections (digests) into seperate emails

The configuration is based on sendmail, fetchmail, and a remote pop account for email.

Configuration of sendmail

This is the most complicated part. Having installed the sendmail-cf package, I created a file named /usr/lib/sendmail-cf/


# here you define your domain

# there we send outgoing email

# there we send mail to users my laptop does not know

# again the domain, we want to be seen as
HACK(check_mail3,`hash -a@JUNK /etc/mail/deny')

This looks more complicated as it is. All it does is, that it redirectes outbound mail to server1 (SMART_HOST) and also mail for local users which are not known (LUSER_RELAY). That way, I can write email to my colleques without using their full email address. More important: the From line in my email points back to my MASQUARADE_AS domain and not directly to my laptop. If this where not the case, email returned with the reply button might not reach me. You must restart sendmail for changes to take effect. Note: this configuration is for Redhat 5.2 systems. You may have to change some details.

Now, all what is needed is to generate the /etc/ file m4 >/etc/ and to add all possible domain names my laptop should respond to in /etc/

# - include all aliases for your machine here.

It is important to have all aliases in this file, otherwise sendmail will not accept the mail (and will reply we don't relay to the sender). Finally, you must now test the setup by sending email, replying to mail for all possible configurations. Any missconfiguration can result in loss of email.

Configuration for fetchmail on Laptop

One method to get the email into your machine is through fetchmail. Fetchmail periodically checks for new email at one or more remote mail servers. I use the following fetchmail configuration file (in my user home directory): fetchmailrc

set postmaster "myusername"
set daemon 900
poll with proto POP3
user "mypopusername" there with password "mypoppassword" is mylaptopusername here

Fetchmail will just get the the email and send it to sendmail which will it deliver into your /var/spool/mail/$USER file.

Forward E-Mail to the Laptop

On my work station I have the following .forward file:,me@server1

Here server1 is the machine where I keep my mailbox. All email is send to the pop account to be picked up later by my laptop (using fetchmail). However, when my laptop is connected via ethernet, I want my email to go directly to the laptop, instead of pop:


In both cases, a backup of my email is send to server1 (where I also can read it, in case I cannot get my laptop). I keep/store all email on the laptop.

Switching is done by three script files and a crontab file (on the workstation):


echo ",me@server1" > ${HOME}/.forward


echo "ppe@laptop,ppe@server1" > ${HOME}/.forward
crontab ${HOME}/mycrontab


if /usr/sbin/ping -c 1 laptop  >/dev/null 2>&1 ; then
   # redirect mail to pop
   sleep 10
if /usr/sbin/ping -c 1 laptop  >/dev/null 2>&1 ; then
      # back to normal
# deactivate crontab check
/bin/crontab -l | grep -v check_laptop >${HOME}/tmp/mycrontab.tmp
      /bin/crontab ${HOME}/tmp/mycrontab.tmp
      rm -f ${HOME}/tmp/mycrontab.tmp


# mycrontab
0,10,20,30,40,50 * * * * ${HOME}/utl/check_laptop

Each time I connect the laptop to the ethernet, I have to run forward_laptop, and each time I disconnect I run forward_pop. In case I forget to run forward_pop, the crontab job runs it for me less then 10 minutes later. To do all that automatically, I change the network script files on my laptop as follows:

/sbin/ifdown (this script runs, whenever a network device is stopped, new stuff between BEGIN and END)

# BEGIN new stuff
# turn off forwarding email
mail ppe <<EOF
turning off forwarding email
device = ${DEVICE}
hostname = `hostname`
if [ "${DEVICE}" = "eth0" -a "`hostname`"
= "laptop" ]; then
su -lc "ssh -l myusername server1
utl/forward_pop" myusername >& /dev/null
# END new stuff

ifconfig ${DEVICE} down
exec /etc/sysconfig/network-scripts/ifdown-post $CONFIG

Note, that the script checks for the value of hostname. In case, I am connected to a foreign ethernet, my hostname and ip-address will be something else, e.g. guest1.

/etc/sysconfig/network-scripts/ifup-post (this script is run, whenever a network device is started)

# Notify programs that have requested notification
# BEGIN new stuff
# check for email -- I'm using fetchmail for this
if [ "${DEVICE}" = "eth0" -o "${DEVICE}"
= "ppp0" ]; then
su -lc fetchmail myusername >& /dev/null &
# set clock if connected to ethernet, redirect email
if [ "${DEVICE}" = "eth0" -a "`hostname`" = "zaphod" ]; then
( rdate -s server1 ; hwclock --systohc --utc ) >& /dev/null &
# forward email
su -lc "ssh -l myusername gradj utl/forward_laptop" myusername >& /dev/null &
# END new stuff

exit 0

Processing Incomming E-Mail with procmail

This step is completely optional. The above described sendmail configuration calls procmail for each received email, but you could have called procmail using the .forward file (see the procmail man page). Procmail is a handy tool to block spam and to sort incomming email.

You need to setup a .procmailrc file to use procmail. See the man page for procmail, procmailrc, and procmailex (examples). My setup demonstrates, how to ignore certain email messages and split email-collections (digest) into pieces:

# -- mail filtering -- procmail is called by sendmail --
# keep in mind:
# use ":0:" when writing to a file
# use ":0"  when writing to a device, e.g. /dev/null, or send email

# - make a backup of *all* incomming mail, but ignore mail tagged below -
:0 c:
*! ˆSissa-Repro

# - keep only last 50 messages
:0 ic
| cd backup && rm -f dummy `ls -t msg.* | sed -e 1,50d`

# - delete email comming through the 'postdocs' email list, when
# it is not of any interest
* ˆFrom.*postdocs
* ˆFrom.*Ernst Richter /dev/null :0
* ˆFrom.*postdocs
* ˆSubject.*card charge
# Split mailing list from the sissa preprint server into individual emails
# - this is quite complicated :(   I can flip through the list much
#   faster and ignore preprints which have uninteresting titles. Instead of
#   having to browse through the whole list, my mailer will just present a
#   list of papers.
# 1. split it in individual messages
* ˆFrom
| formail +1 -de -A "Sissa-Repro: true" -s procmail
# 2. reformat messages a bit
# 2.1. extract 'Title:' from email-Body and add to email-header
as 'Subject:'
:0 b
* ˆSissa-Repro
*! ˆSubject
TITLE=| formail -xTitle:

:0 a
|formail -A "Subject: $TITLE " -s procmail

# 2.2. store in my incomming sissa-email folder. Here, we could
#      also reject (and thereafter delete) uninteresting 'Subjects'
#      we could also mark more interesting subjects as urgend or send a copy
#      to regular mail box.
* ˆSissa-Repro
* ˆSubject
*! ˆreplaced with

By the way, there is a tk GUI tool to configure procmail (I think it is called dotfiles).

Email with UUCP

Another possible solution for Email is to use UUCP. This software was made for disconnected machines, and is by far the easiest solution if you have several users on your laptop (we are talking about UNIX, remember?), each with his/her own account.

Unlike what most people think, UUCP does not need a serial connection: it works fine over TCP/IP, so your UUCP partner can be any machine on the Internet, if it is reachable from your network attachment point. Here is the UUCP sys for a typical laptop:

system mylaptop time any chat "" \d\d\r\c ogin: \d\L word: \P address port TCP

More Info

Using a Laptop in Different Environments by Gerd Bavendiek . This article appeared in the August, 1997 issue of the Linux Gazette. This is an excellent, short technical article describing an easy way to setup your Linux notebook to boot into different network and printing configurations, especially useful for those who use their machines at home as well as other locations such as in the office, at school, or at a customer site.