Laptop Themes Configuring dhcp and a fixed ip at the same time
/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:
The way to find the dhcp/fixed ip information was to search for 'laptop' in the Debian package name search -- there is lots:
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
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.
I need the natsemi.c driver -- I gave the wrong one while installing
laptop-net and edited /etc/default/laptop-net to include In the meantime, debconf had shut eth0 down; I restarted it with ifup eth0 and it worked! ifconfig reads,
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.
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.
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:
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
Similarly, a grep "laptop-net" /etc -r found this:
I reread the manual and found I can issue
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. |
|
|
|
|||||
Maintained by Francis F. Steen, Communication Studies, University of California Los Angeles |