Laptop Themes

Configuring dhcp and a fixed ip at the same time

The controlling files are in
/etc/network

ifconfig - configure a network interface

Get information:
ethtool -i eth0
ifconfig

ifconfig up -- activate interface
ifconfig down -- shut down

/etc/network/interfaces is the main file you need to edit.

For a complex set of /etc/network/interfaces configuration examples, see /usr/share/doc/ifupdown/examples/network-interfaces.gz

Note the init script at /etc/init.d/ifupdown

Then I started finding the dedicated programs for solving my problem:

whereami

Description: Automatically reconfigure your (laptop) system for a new location whereami is a set of useful scripts and a coordinating system for automatically re-locating your computer within the current (network) environment.
.
Typically, you would use whereami to automatically detect and re-configure your laptop when you move between a variety of diverse networks and/or docking environments.
.
Although whereami will work best if all of your networks assign addresses through dhcp, this is not a pre-requisite and the system allows any technique to be used to ascertain the new location with as little ongoing user intervention as possible.
.
Having ascertained the correct location, whereami will run appropriate (user-configured) scripts to adjust the laptop operation to suit the current environment.
.
See http://debiana.net/whereami/ for more information. You may also get useful assistance from the debian-laptop mailing list, which is frequented by several of the contributors.

The way to find the dhcp/fixed ip information was to search for 'laptop' in the Debian package name search -- there is lots:

Package: laptop-net 2.7-1
Automatically adapt laptop ethernet

Package: laptop-net-doc 2.15-1
Automatically adapt laptop ethernet - documentation

Package: laptop-netconf 0.9-1.1
network detection and configuration program for laptops

Package: whereami 0.1.12
Automatically reconfigure your (laptop) system for a new location
/etc/netenv/interfaces.in

Package: divine 0.7.2-6
Automatic IP configuration detection for laptops

Package: intuitively 0.6
Automatic IP configuration detection for laptops

Package: netenv 0.82-12
Configure your system for different network environments.

Package: switchconf 0.0.2-3
Change network config for laptops
http://packages.debian.org/unstable/utils/switchconf.html

Package: guessnet 0.14-1.1
Guess what network is connected to an ethernet device
http://packages.debian.org/unstable/net/guessnet.html

Package: laptop-net 2.15-1
Automatically adapt laptop ethernet

Note that you could have found most of these with a "apt-cache search laptop network config"!!

This is equivalent: wajig search laptop network config

ifplugd -- a configuration daemon for internet devices

Which one to choose? "There are a lot of packages for automatic network detection and reconfiguration on debian: whereami, divine, intuitively, laptop-netconf, laptop-net, netenv, and maybe others."

Laptop-net

Most of the packages assume the ethernet connection is on a pcmcia card, but laptop-net assumes onboard. It looks like the most mature package and has full documentation, so I'll try that.

Setting up laptop-net (2.15-1) ...
Writing new configuration files using debconf settings:
Writing /etc/default/laptop-net...done
Writing /etc/laptop-net/schemes...done

I need the natsemi.c driver -- I gave the wrong one while installing laptop-net and edited /etc/default/laptop-net to include
MODULE_NAME="natsemi"

In the meantime, debconf had shut eth0 down; I restarted it with ifup eth0 and it worked! ifconfig reads,

inet addr:128.97.184.97 Bcast:128.97.184.255 Mask:255.255.255.0

/etc/laptop-net/schemes is where you define the various connections.

root@sigillo:/etc# wajig list-files laptop-net-doc
/usr/share/doc/laptop-net-doc
/usr/share/doc/laptop-net-doc/laptop-net.html
/usr/share/doc/laptop-net-doc/laptop-net.pdf
/usr/share/doc/laptop-net-doc/copyright
/usr/share/doc/laptop-net-doc/changelog.gz
/usr/share/doc/laptop-net-doc/changelog.Debian.gz
/usr/share/doc-base/laptop-net
/usr/share/info/laptop-net.info.gz

Run in Opera -- file://localhost/usr/share/doc/laptop-net-doc/laptop-net.html

"the selected scheme can be printed by running the command /etc/init.d/laptop-net scheme" "A new scheme name may be selected by running the command /etc/init.d/laptop-net scheme name"

Alternatively, the scheme can be automatically selected by specifying one or more IP addresses that are associated with a particular scheme. Then, when the laptop is connected to a network, it probes the local subnet for those addresses, and if one of them is found, it selects the associated scheme.

I established three schemes: office, class, and offline. You can use /etc/laptop-net/ip-map to help laptop-net identify various locations by ip-address; I left it blank.

You could use the /etc/laptop-net/profiles to select features in each environment. For instance, you could select the /etc/XF86Config-4.Projectors file for the class scheme, and the /etc/XF86Config-4.nVidia file for the default scheme.

I created three profile directories, class, office, and * (for offline).

Under class, I created /files.d/etc/X11/ -- files to be copied into the filesystem in this scheme.

I copied /etc/X11/XF86Config-4.Projectors to /etc/laptop-net/profiles/class/files.d/etc/X11/XF86Config-4

Under office, I created /files.d/etc/X11/ and moved /etc/X11/XF86Config-4.nVidia into it, calling it just XF86Config-4.

I did the same under offline. Note that you could also prepare customized fstab files. You can also start and stop the appropriate system v services; see file://localhost/usr/share/doc/laptop-net-doc/laptop-net.html#SEC6

The patterns file is used to identify the location by matching the ip address found.

Under /profile/office, I created the file patterns with the content 128.97.184.*
Under /profile/offline, I created the file patterns with the content down unknown
Under /profile/zclass, I created the file patterns with the content *

This should let the setup detect whether I'm at the office or in class, or neither.

Laptop-net also supports link beat if the NIC does, and natsemi does. It will let you unplug the system and plug it in somewhere else, and laptop-net figures out where you are. You need to watch that you're not leaving connections dangling, however. Use netstat-t to check before you disconnect.

For instance, you could mount vc on sigillo. Use netstat-t to check if it's still mounted.

root@sigillo:/etc/laptop-net# mount steen2:/mnt/vc /mnt/vc
root@sigillo:/etc/laptop-net# netstat -t
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 steen1.ucla.edu:719 steen2.ucla.edu:sunrpc TIME_WAIT

This could even be useful for maintaining a campus connection, keeping it from timing out.

Note that the script /usr/share/laptop-net/shared.sh -- which looks like one of the main scripts for laptop-net -- has a routine for shutting down all NFS connections, so you probably won't need to do this manually. Question is, how is it triggered -- as it should be triggered *before* you discunnect!!

On 7 January 2003, laptop-net is still not working -- the scripts are not copying the correct XF86Config-4 file from /etc/laptop-net to /etc/X11, and I don't know where or how to debug it.

Here are the files that were installed with the package:

root@sigillo:/home/steen# wajig list-files laptop-net

/etc/laptop-net
/etc/laptop-net/profiles
/etc/laptop-net/ip-map

/usr/lib/laptop-net
/usr/lib/laptop-net/ifd
/usr/lib/laptop-net/get-addr
/usr/lib/laptop-net/linkup
/usr/lib/laptop-net/mktone
/usr/lib/laptop-net/arp-discovery
/usr/lib/laptop-net/get-ip-addresses

/usr/share/doc/laptop-net
/usr/share/doc/laptop-net/copyright
/usr/share/doc/laptop-net/changelog.gz
/usr/share/doc/laptop-net/changelog.Debian.gz

/usr/share/laptop-net
/usr/share/laptop-net/laptop-net.conf
/usr/share/laptop-net/schemes.conf
/usr/share/laptop-net/shared.sh
/usr/share/laptop-net/link-change
/usr/share/laptop-net/profile-change

/var/lib/laptop-net
/var/lib/laptop-net/schemes

/var/state
/var/state/laptop-net

/etc/apm/event.d/30laptop-net
/etc/init.d/laptop-net

Now, a probe of /var/state/laptop-net/state shows that the connection is up, and /var/state/laptop-net/scheme shows that the "default" scheme has been used -- not "office" as it should have done. No profile is activated.

I did a grep "laptop-net" /var -r and found that messages are logged in

/var/log/daemon.log
/var/log/syslog

Similarly, a grep "laptop-net" /etc -r found this:

/etc/apm/event.d/30laptop-net:SCRIPT="/etc/init.d/laptop-net"
/etc/default/laptop-net:# $Id: laptop-net.conf,v 1.9 2002/10/18 21:17:48 cph Exp $
/etc/rc0.d/K88laptop-net:IFD="/usr/lib/laptop-net/ifd"
/etc/rc0.d/K88laptop-net:LINK_CHANGE="/usr/share/laptop-net/link-change"
/etc/rc0.d/K88laptop-net:. /usr/share/laptop-net/shared.sh
/etc/rc1.d/K88laptop-net:IFD="/usr/lib/laptop-net/ifd"
/etc/rc1.d/K88laptop-net:LINK_CHANGE="/usr/share/laptop-net/link-change"
/etc/rc1.d/K88laptop-net:. /usr/share/laptop-net/shared.sh
/etc/rc2.d/S12laptop-net:IFD="/usr/lib/laptop-net/ifd"
/etc/rc2.d/S12laptop-net:LINK_CHANGE="/usr/share/laptop-net/link-change"
/etc/rc2.d/S12laptop-net:. /usr/share/laptop-net/shared.sh
/etc/rc3.d/S12laptop-net:IFD="/usr/lib/laptop-net/ifd"
/etc/rc3.d/S12laptop-net:LINK_CHANGE="/usr/share/laptop-net/link-change"
/etc/rc3.d/S12laptop-net:. /usr/share/laptop-net/shared.sh
/etc/rc4.d/S12laptop-net:IFD="/usr/lib/laptop-net/ifd"
/etc/rc4.d/S12laptop-net:LINK_CHANGE="/usr/share/laptop-net/link-change"
/etc/rc4.d/S12laptop-net:. /usr/share/laptop-net/shared.sh
/etc/rc5.d/S12laptop-net:IFD="/usr/lib/laptop-net/ifd"
/etc/rc5.d/S12laptop-net:LINK_CHANGE="/usr/share/laptop-net/link-change"
/etc/rc5.d/S12laptop-net:. /usr/share/laptop-net/shared.sh
/etc/rc6.d/K88laptop-net:IFD="/usr/lib/laptop-net/ifd"
/etc/rc6.d/K88laptop-net:LINK_CHANGE="/usr/share/laptop-net/link-change"
/etc/rc6.d/K88laptop-net:. /usr/share/laptop-net/shared.sh
/etc/init.d/laptop-net:IFD="/usr/lib/laptop-net/ifd"
/etc/init.d/laptop-net:LINK_CHANGE="/usr/share/laptop-net/link-change"
/etc/init.d/laptop-net:. /usr/share/laptop-net/shared.sh

I reread the manual and found I can issue

/etc/init.d/laptop-net scheme office

to switch on the office scheme. I had to unplug the ethernet cable to make it run (it said eth0 is already configured), but then it did run, and copied the right files to the right places! So this is sort of working -- I have control of how to activate a certain scheme. The way to run this would be to boot up without being connected...

I get a nice loud beep when I disconnect the ethernet cable. However, trying to switch to the class scheme while I'm in the office doesn't work -- I'm still successfully connecting, where I should be failing. var/state/laptop-net/profile shows I'm still using the office profile -- which is triggered when the office IP address is detected. However, I'm supposedly (according to var/state/laptop-net/scheme) using the class scheme, which specifies DHCP.

Now, it's correct that the class profile should not be triggered if eth0 connects to the 184 subnet -- in that case, the office profile should trigger.

However, selecting network scheme "class" should force dhcp, which it's apparently not doing. In addition, there is the question of why the office profile was not triggered automatically; surely it should have been.

OK -- I may have figured it out. In an older laptop-net manual, I read that "The configuration file is named `/etc/default/laptop-net'." I had put it in /etc/laptop-net, which is apparently just used for profiles, not for the schemes -- so my /etc/laptop-net/schemes file never got read? That's entirely possible -- that is to say, consistent with the behavior of the system as I can recall it. I'll try rebooting, after copying my schemes file to /etc/default/laptop-net.

But no -- the current manual at file://localhost/usr/share/doc/laptop-net-doc/laptop-net.html says that "Schemes are defined by editing a configuration file named `/etc/laptop-net/schemes'" where I had put it. So I still don't know why this doesn't work.

In the end I gave up on laptop-net as being too complicated -- it wasn't working out of the box, and customizing it was more complex than just customizing without it.

I set up /root/.class (/usr/bin/class) and .office (/usr/bin/office) to switch between my two environments as user root. This is simple and easy to control -- the dhcp isn't tested yet, however.

 

 

top
Debate
Evolution
CogSci

Maintained by Francis F. Steen, Communication Studies, University of California Los Angeles


CogWeb