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. If you are the first time in an environment, you can enter the basic data 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, RedHat and SuSe). If you have a Network Interface Card (often simpy called NIC) onboard, you can use the same mechanism.
Have a look at netenv's chooser box:
Besides the basic functionality of configuring the NIC, the netenv data can be used for thinks like:
Think of using your laptop standalone with touchpad vs. connected to a CRT monitor along with an external wheel mouse.
You create the appropriate /etc/resolv.conf.
Assigning a proper value for e.g. PRINTER defines a default printer.
So it's possible to avoid network timeouts, when working not connected to the net and viewing only local files.
Having a permanent connection to my mailserver I use netenv to call fetchmail as a daemon which fetches mail periodically.
If you use a palm, you may link /dev/pilot to a serial device when a cradle is connected and to the IRDA-port if you are on the road.
Netenv is available prepackaged for Debian and Redhat Linux as well as tarball. Mandrake- and SuSe-Users may use the RedHat-RPM. netenv depends on dialog(1) resp. gdialog (which comes with the mentionend distributions).
A word to all gurus: In this docu I try to explain things with Linux novices in mind, so be patient.
But you may know this already ...
You will find there the tar-file as well as the RedHat-RPM. The latter should be useable in Mandrake and Suse too.
Debian-User
Netenv has been available for Debian quite a while. Look at http://www.debian.org/distrib/packages.
rpm -i netenv-0.94-1.i386.rpmIn Debian e.g.:
dpkg -i netenv-0.92-2.i386.debor simply
apt-get install netenvIn all other cases:
tar xvf netenv-0.94-2.tarThis installs a shellscript called netenv, a little helper utility trpnc, configuration examples and these docs. Depending on the distribution a little handwork may be necessary.
The netenv-RPM has been packaged under RedHat 6.1. So it should be possible to install in all distributions using RPM.
The postinstall-script puts
lulu:/home/bav> tail -2 /etc/rc.d/rc.sysinit # Added by package netenv on 06.03.2000 19:53:10 /usr/sbin/netenvAdditionally /etc/sysconfig/network-scripts/ifcfg-eth0 will be changed. Just after first installing Redhat this file looks like:
lulu:/etc/sysconfig/network-scripts>>> cat ifcfg-eth0 DEVICE=eth0 BROADCAST=192.168.200.255 IPADDR=192.168.200.201 NETMASK=255.255.255.0 NETWORK=192.168.200.0 ONBOOT=yesInstalling netenv adds two lines:
lulu:/etc/sysconfig/network-scripts>>> tail -3 ifcfg-eth0 ONBOOT=yes # Added by package netenv on 06.03.2000 19:53:10 if [ -r /tmp/netenv ]; then . /tmp/netenv; fi
lulu:/etc/init.d> tail -3 boot.local # # Added by package netenv on 06.12.2002 10:45:10 /usr/sbin/netenvThis way netenv is called during boot. netenv assumes the NIC to be configured is eth0, so the line
if [ -r /tmp/netenv ]; then . /tmp/netenv; fiis appended to the file
/etc/sysconfig/network/ifcfg-eth0It then looks like:
lulu:/etc/sysconfig/network> cat ifcfg-eth0 FIREWALL="YES" BOOTPROTO='static' BROADCAST='nn.nn.nn.nn' IPADDR='nn.nn.nn.nn' NETMASK='nn.nn.nn.nn' NETWORK='nn.nn.nn.nn' REMOTE_IPADDR='' STARTMODE='onboot' UNIQUE='oxTw.yHaVEFCrUXE' WIRELESS='no' if [ -r /tmp/netenv ]; then . /tmp/netenv; fiThe entries IPADDR, NETMASK etc. spring from the basic installation. There is no need to delete them as they are superseded by the assignments in /tmp/netenv[1]. In this example I assume that the NIC is not a PCMCIA-NIC. Otherwise the line
STARTMODE='onboot'must read
STARTMODE='hotplug'
mweb@guru:/etc/rc.d > tail -3 boot.local # before we're going to the first run level. # # Added by package netenv on 06.02.2001 20:28:10 /usr/sbin/netenvFor PCMCIA-Cards an entry in /etc/pcmcia/network.opts is done:
mweb@guru:/etc/pcmcia > tail -2 network.opts esac # Added by package netenv on 06.02.2001 20:28:10 if [ -r /tmp/netenv ]; then . /tmp/netenv; fiIf the laptop has a builtin NIC and PCMCIA must not be used, you may override the values defined by YAST as follows:
mweb@guru:/etc/rc.d > head -16 network #! /bin/sh # Copyright (c) 1996 SuSE GmbH Nuernberg, Germany. All rights reserved. # # Author: Florian La Roche, 1996 # Werner Fink , 1996 # Burchard Steinbild , 1996 # Rolf Haberrecker , 1998 # Werner Fink (based on a patch of Andries Brouwer) 1999 # # /sbin/init.d/network # . /etc/rc.status . /etc/rc.config if [ -r /tmp/netenv ] ; then . /tmp/netenv; fi
tar zxvf netenv-0.94-2.tar.gz cd netenv-0.94-2 make make install # must be user root from now on ! make configDepending on the distribution the last step make config may eventually have to be done manually.
netenv must be called before the normal network- or PCMCIA-start. Check for /etc/init.d/boot.local or the equivalent. See the SuSE 8.1 paragraph for further details.
After you have ensured that netenv is called during boot, the configuration data must be read by the network scripts. Modern distributions seem to use ifup to start a preconfigured net interface. Then the SuSE 8.1 paragraph should contain the details.
A common issue is to confuse eth0 and eth1 if there is an onboard NIC and a PCMCIA NIC. Chances are that eth0 is the onboard and eth1 is the PCMCIA NIC. Verify with dmesg | grep eth and lspci.
Netenv checks for eth1, but depending on the configuration at the time of installation this cannot be waterproof.
This is done using dialog(1), a simple menu interface, well known to most users. Booting is continued after the user has done his selection. For a default environment this may be as simple as just pressing RETURN.
If "lilo" is used as bootmanager, you may alternatively input after the lilo-prompt:
linux NETENV=officeThis defines a shell variable "NETENV" with the value "office". This means for me: I am with my laptop named lulu in the office. The file containing the values for IP-address etc. is /etc/netenv/lulu-lavie. The Linuxkernel starts the init-process with the variable NETENV as part of its environment. The same does init with the so called rc-scripts.
The netenv-script tests for NETENV beeing defined. If it is, netenv carries out further actions without popping up the manu.
After having selected the current environment, netenv copies the actual file to /tmp/netenv[1].
This file has modes 644, so being readable by any user for further user dependent configuration tasks.
netenvThis will fire up a menu with only one choice:
new Set_up_new_environmentThese parameters will be asked for:
Enter the current IP-Address or the keyword dhcp ... Enter the netmask of the current subnet ... Enter the IP-Address of the current network ... Enter the Broadcast-Address of the current network ... Enter the Gateway-Address of the current network ... Enter the IP-address of the current nameserver ...If in a network with DHCP-Server, input dhcp instead of an IP-Address. Then a /tmp/netenv[1] is generated containing only
BOOTPROTO='dhcp' STARTMODE='hotplug'All other values will be derived according to the DHCP-configuration. If the NIC is onboard, netenv should have written
STARTMODE='onboot'In case of a static IP-address there will be a default entry for the other items, which will be sufficient in many situations.
Finally you will be asked if you want to save this configuration for further use:
Do you want to save this configuration ?Please do not use spaces in this name !
Depending on the Distribution netenv offers to restart the network and to activate the changes this way.
If this is not applicable, take out your PCMCIA-NIC (if it's PCMCIA you use ...) and stick it in again (cardmgr will ring the bell). The same result may be achieved doing
/etc/init.d/pcmcia restartIn any case cardmanager from the PCMCIA-package should configure the interface.
Ping your gateway-address and you will know !
Didn't work ? Is the link-LED green ? Check the output of
ifconfig eth0
The procedure just described may be also be used, wenn you want to switch from one network environment to another while your laptop stays up and running. There is no need to reboot - it's Linux ...
Those, who use a NIC onboard instead of a PCMCIA-NIC have to restart their network.
In RedHat or SuSE e.g.:
/etc/init.d/network restartNetenv does this according to your input.
/etc/netenv/<NODE-NAME>-<VALUE-OF-VARIABLE-NETENV>The filename identical to the laptop's hostname is the first item in the selection menu. You simply may press RETURN and booting is continued. You should put the most frequently used environment into this file.
All files contain assignments in shell syntax, e.g.
netenv_id=At_Home_LCD_WheelMouse_pcmcia ... IPADDR=123.456.78.9 ... NETSCAPE_PROXY_TYPE=2Spaces will cause trouble. For a well configured NIC you will have to define at least
IPADDR NETMASK NETWORK BROADCASTDepending on the situation you may additionally have to define
GATEWAY DNS_1You may stick any variableassignment into the file - as long as everything is syntactically right. There is something special with an assignment like
NETENV_SCRIPT=/etc/netenv/netenv_setupIf the file pointed to is readable, netenv will execute this file (to be precise: it will source it) after the current network environment has been choosen.
Pay Attention ! This will be in a very early stage of boot. No network will be active ! NETENV_SCRIPT will be executed with root privileges !
With the help of this script you may do quite useful things. More on this in the example section.
The examples are described step by step. So please read them one after the other !
lulu:/etc/netenv>>> cat lulu-touch-pad netenv_id=StandAlone_Touchpad_no_eth STARTMODE=manual export XF86CONFIG_FILE=/etc/X11/XF86Config-4-lcd-touch NETENV_SCRIPT=/etc/netenv/netenv_setup # This may be used to edit ~/.netscape/preferences.js NETSCAPE_PROXY_TYPE=3I use this one when my laptop has no network connection.
The value of the variable netenv_id (as I said earlier: Please without spaces) will be used as decription in the chooser box.
There is no IP-address defined. By setting STARTMODE=manual there will no NIC be configured during boot. I assign NETENV_SCRIPT=/etc/netenv/netenv_setup. This is a file containing shell commands. It is attached to this documentation here.
This sample is written in a simple manner to get you started. Relevant code section here is:
lulu:/etc/netenv>>> cat netenv_setup ... # Simple way to configure the X-Server if [ -r $XF86CONFIG_FILE ]; then echo $XF86CONFIG_FILE will be used for configuring the X-Server ... mv /etc/X11/XF86Config /etc/X11/XF86Config.old ln -s $XF86CONFIG_FILE /etc/X11/XF86Config fi fi ...As I defined XF86CONFIG_FILE the code creates a link. Right now it is pointing to the configuration file, which I created for my laptop with touchpad.
Typically netenv_setup does everything the root user is needed for and the whole system is concerned with. Personal settings are done via .xinitrc. Here is an example:
In my private configuration I use NETSCAPE_PROXY_TYPE:
lulu:/home/bav> cat .xinitrc #!/bin/sh ... if [ -r /tmp/netenv ]; then . /tmp/netenv fi if [ -n "$NETSCAPE_PROXY_TYPE" ]; then ~/tools/edit-ns-preferences $NETSCAPE_PROXY_TYPE fi ...You will find the script edit-ns-preferences in the netenv-documentation. It will avoid nasty network-timeouts, when starting the browser.
lulu:/etc/netenv>>> cat lulu-lavie # Networkenvironment: netask netenv_id="lavie_pcmcia_dhcp" export BOOTPROTO=dhcp export STARTMODE=hotplug export PRINTER=cc_hp NETSCAPE_PROXY_TYPE=2 FETCHMAIL_POLL_INTERVALL=900In the office I get my network configuration from a DHCP-Server. STARTMODE=hotplug is set, because my laptop has no onboard-NIC and therefore the PCMCIA-NIC has to be used.
PRINTER=cc_hp sets the defaultprinter to the printer in the office. NETSCAPE_PROXY_TYPE=2 activates automatic proxyconfiguration in Netscape.
When I am in the office, mail shall be fetched periodically. For this I use FETCHMAIL_POLL_INTERVALL. The following snippet from my ~/.xinitrc starts fetchmail as daemon, which will became active every 15 min and carry out things defined in ~/.fetchmailrc:
if [ -n "$FETCHMAIL_POLL_INTERVALL" ]; then fetchmail -d $FETCHMAIL_POLL_INTERVALL fi
netenv_id=At_Home_Docking_LCD_WheelMouse_onboard_VPN IPADDR=nnn.nn.nnn.nnn NETMASK=nnn.nnn.nnn.nnn NETWORK=nnn.nn.nnn.nnn BROADCAST=nnn.nn.nnn.nnn GATEWAY=nnn.nn.nnn.nnn SEARCH=foo.bar.com DNS_1=nnn.nn.nn.nn DNS_2=nnn.nn.nn.nn FETCHMAIL_POLL_INTERVALL=900 # If the variable NETENV_SCRIPT points to an readable file, # it will be run when netenv is executed NETENV_SCRIPT=/etc/netenv/netenv_setup ICEWM_INCLUDE_FILE=home # This defines my CRT with 1024x768 and a wheelmouse XF86CONFIG_FILE=/etc/X11/XF86Config-4-lcd-wheel # This may be used to edit ~/.netscape/preferences.js NETSCAPE_PROXY_TYPE=2 # This may be used to edit ~/.opera/opera6.ini OPERA_PROXY_FILE=proxy-fsc.ini # NIC is in the docking unit - like it were onboard STARTMODE='onboot'Relevant portion from my netenv_setup is this:
lulu:/etc/netenv>>> cat netenv_setup ... PROFILE=$1 ... if [ "$PROFILE" = "default" ]; then print_action linking /dev/pilot rm -f /dev/pilot; ln -s /dev/ttyS0 /dev/pilot print_status print_action calling ptal-init start /usr/sbin/ptal-init start print_status else # When there is no docking station, start irattach appropiately and # link /dev/pilot to ircomm0. print_action running irattach /usr/sbin/irattach /dev/ttyS3 -s print_status print_status linking /dev/pilot rm -f /dev/pilot; ln -s /dev/ircomm0 /dev/pilot print_status fi ...netenv_setup is called with the parameter PROFILE, which equals "default" here (in all other cases it is the filename of the descriptionfile minus hostname portion).
At home I use a cradle for my palm. So /dev/pilot must point to the appropriate serial device. Additionally the software for my HP Officejet has to be started. In all other environments the palm can be reached only via IRDA. ptal must not be started then.
At home my laptop is in a docking-unit. This has a NIC. In order to use this NIC
STARTMODE='onboot'has to be set.
If you don't like to edit your /etc/hosts manually, the following idea may help. For me it is useful, as I find computers with identical names but different IP-addresses in different environments.
I put marks in my /etc/hosts like this:
lulu:/home/bav> cat /etc/hosts ... # netenv hosts begin # netenv hosts end ...Now I define nodes with their IP-addresses, which I want to connect to in the current environments:
NETENV_HOST_ENTRIES="192.168.10.11 abba:192.168.10.12 bebe:192.168.10.3 alfa-sw:\ 192.168.10.4 beta-sw:192.168.10.13 coca:192.168.10.14 cola"This code in my /etc/netenv/netenv_setup will care for editing /etc/hosts after choosing the environment:
if [ -n "$NETENV_HOST_ENTRIES" ]; then if egrep '^# netenv hosts begin$' /etc/hosts > /dev/null 2>&1; then ( awk 'NR==1,/^# netenv hosts begin$/' /etc/hosts echo $NETENV_HOST_ENTRIES | awk -F'\:' '{ for ( j=1; j<=NF; j++ ) print $j }' awk '/^# netenv hosts end$/,/*/' /etc/hosts ) > /etc/hosts.netenv mv /etc/hosts.netenv /etc/hosts chmod 644 /etc/hosts echo netenv_setup: /etc/hosts was modified ... fi else if egrep '^# netenv hosts begin$' /etc/hosts > /dev/null 2>&1; then ( awk 'NR==1,/^# netenv hosts begin$/' /etc/hosts awk '/^# netenv hosts end$/,/*/' /etc/hosts ) > /etc/hosts.netenv mv /etc/hosts.netenv /etc/hosts chmod 644 /etc/hosts echo netenv_setup: /etc/hosts was cleaned up ... fi fiNow /etc/hosts looks like this:
... # netenv hosts begin 192.168.10.11 abba 192.168.10.12 bebe 192.168.10.3 alfa-sw 192.168.10.4 beta-sw 192.168.10.13 coca 192.168.10.14 cola # netenv hosts end ...All these nodes are trusted, so I use the mechanism in my ~/.xinitrc and call xhost appropriate:
XHOST_PLUS_LISTE=`awk '/^# netenv hosts begin$/,/^# netenv hosts end$/' /etc/hosts | awk '!/^#/ {print $2}'` xhost $XHOST_PLUS_LISTExhost gives me:
lulu:/home/bav> xhost access control enabled, only authorized clients can connect INET:cola INET:coca INET:beta-sw INET:alfa-sw INET:bebe INET:abba
I always felt the mechanism, which David Hinds implemented in his PCMCIA-package, being sufficient (Script network). This snippet shows what is happening there:
# Update DNS stuff cp /etc/resolv.conf /etc/resolv.new echo "# $DEVICE begin" >> /etc/resolv.new test "$DOMAIN" && echo "domain $DOMAIN" >> /etc/resolv.new if [ "$DNSSRVS $DNS_1 $DNS_2 $DNS_3" != " " ] ; then for DNS in $DNSSRVS $DNS_1 $DNS_2 $DNS_3 ; do echo "nameserver $DNS" >> /etc/resolv.new done fi echo "# $DEVICE end" >> /etc/resolv.new mv /etc/resolv.new /etc/resolv.confThe file /etc/resolv.conf is copied to a temporary file. If one of the variables DOMAIN, DNSSRVS, DNS_1, DNS_2 or DNS_3 are defined, appropiate commands are issued. This new section starts e.g. with # eth0 begin and ends with e.g # eth0 end. These makes are used, to clear the section, when PCMCIA is shut down. Afterwards /etc/resolv.conf will be in the original state.
So defining e.g. DNS_1 makes this thing work.
If you want to use netenv for this task, you may put following code in /etc/netenv/netenv_setup:
if [ ! -z "$DNS_1" ]; then ( echo "# resolv.conf autogenerated by netenv "`date` if [ ! -z "$DOMAIN" ]; then echo domain $DOMAIN; fi if [ ! -z "$SEARCH" ]; then echo search $SEARCH; fi echo nameserver $DNS_1 if [ ! -z "$DNS_2" ]; then echo nameserver $DNS_2; fi ) > /etc/resolv.conf chmod 644 /etc/resolv.conf echo netenv: /etc/resolv.conf was set up ... fi
IFCONFIG_0="172.25.64.130 broadcast 172.25.64.255 netmask 255.255.255.0 up"If you want to use DHCP, the entry must read
IFCONFIG_0="dhcpclient"Using netenv you may do this as follows:
At first the appropriate profile:
elli:/etc/netenv> cat elli-ht # Networkenvironment: DHCP export USE_DHCP=yes NETENV_SCRIPT=/etc/netenv/netenv_setupFurthermore you need a netenv_setup script with at least following contents:
elli:/etc/netenv> cat netenv_setup edit_rc_config() { if [ ! -r /etc/rc.config ]; then echo No /etc/rc.config, probably not a SuSE-System, giving up ... return 1 fi VARIABLE_TO_CHANGE=$1 shift echo ${VARIABLE_TO_CHANGE}'="'$*'"' > /tmp/.netenv.tmp.$$ LINE=`awk '/^'$VARIABLE_TO_CHANGE'=/ {LINE=NR} END {print LINE}' /etc/rc.config` awk -v LINE=$LINE 'NR /tmp/.rc.config.netenv cat /tmp/.netenv.tmp.$$ >> /tmp/.rc.config.netenv awk -v LINE=$LINE 'NR>LINE' /etc/rc.config >> /tmp/.rc.config.netenv cat /tmp/.rc.config.netenv > /etc/rc.config rm -f /tmp/.rc.config.netenv /tmp/.netenv.tmp.$$ echo netenv_setup: rc.config edited, Variable $VARIABLE_TO_CHANGE set to $* } if [ "$USE_DHCP" = yes ]; then edit_rc_config IFCONFIG_0 dhcpclient else edit_rc_config IFCONFIG_0 "$IPADDR broadcast $BROADCAST netmask $NETMASK up" fi
SuSe uses the files /etc/route.conf for describing static routing. The default-route looks like this:
default 172.246.2.1Using the example where netenv edits /etc/hosts you may use e.g.:
if grep SuSE /etc/issue 1>/dev/null; then if [ ! -z "$GATEWAY" ]; then ( echo "# route.conf autogenerated by netenv "`date` echo default $GATEWAY 0.0.0.0 eth0 ) > /etc/route.conf echo netenv_setup: /etc/route.conf was modified ... fi fiBack to Table of Contents
Additional features with Debian
netenv and the offline-http-proxy wwwoffle
Upon installation of the Debian package it tries to set up a network configuration that corresponds to your current settings. Unfortunately, network setup is done quite differently in Debian, compared to other distributions. Additionally, there are two possibilities for the network setup. Therefore you have to do some things manually, either for installation or when you want to create new network configurations.
If netenv cannot parse the current configuration, it will not be called upon boot, and the computer will behave as it was before the installation. In this case you have to set up a working configuration as described below and then create the necessary startup link to the init-script with the command
update-rc.d netenv start 40 S
The following paragraphs describe which user changes are required: If the network settings are stored in /etc/network/interfaces so far, then netenv will work at once - however creating a new configuration for the network chooser box is somewhat complicated. In Debian, this method is in use with built-in network cards ("on-board") and sometimes with PCMCIA-cards. The second method, where the network settings are in /etc/pcmcia/network.opts, can only be used with PCMCIA-cards.
The installation routine detects which method is used and sets up a sample configuration accordingly. With both methods, however, the user has to make some changes to make things work! If network settings are found in both files - or in none of them -, no configuration is generated so far, and netenv is not called upon booting. The same will happen if it found network settings in /etc/network/interfaces, but this file is yet a symbolic link (see below).
The syntax of interfaces is fundamentally different compared to netenv's expectations - i.e. no variable assignments are used. Consequently there is no possibility to simply "supersede" the information from this file. Instead, netenv is instructed to execute a script after you chose a network environment. This script redirects symbolic links. The outcome looks like the following:
ls -l /etc/network/interfaces* /etc/network/interfaces -> /etc/network/interfaces.work /etc/network/interfaces.home /etc/network/interfaces.work /etc/network/interfaces.offline /etc/network/interfaces.old -> /etc/network/interfaces.offline
This means that no files are changed, it is only the symbolic link /etc/network/interfaces which is redirected to the appropriate target. The file /etc/resolv.conf must be treated in the same way. Note that for offline use, you need to set up a lo device in interfaces.
The commands that redirect these links could, in principle, be put directly in the configuration files for the respective network environment. On a computer named lulu they would, e.g., be in /etc/netenv/lulu-home, /etc/netenv/lulu-office etc. However, the author of netenv recommends to keep only variable assignments in these files. Specifically, one can define the variable NETENV_SCRIPT. This script is then automatically executed and makes the desired links.
An example configuration on machine lulu could look like this: In /etc/netenv/ we have the following files:
lulu lulu-customer lulu-offline setup-customer setup-offline lulu-work lulu-home netenv.conf setup-work setup-home(It is required to have one file (or symbolic link) with the computer name and no -somewhere. I usually us this as my default configuration.) lulu-work, for example, contains:
netenv_id=Arbeit export NETENV_SCRIPT=/etc/netenv/setup-work # you can set any variable here. export it!
The variable netenv_id is used in the chooser dialog box of netenv, the script setup-work is executed (sourced, to be exact) after lulu-work has been read. It looks like this:
#!/bin/sh if [ -r /etc/network/interfaces.work ]; then mv /etc/network/interfaces /etc/network/interfaces.old ln -s /etc/network/interfaces.work /etc/network/interfaces fi if [ -r /etc/resolv.conf.work ]; then mv /etc/resolv.conf /etc/resolv.conf.old ln -s /etc/resolv.conf.work /etc/resolv.conf fi if [ -r /etc/exim/exim.conf.work ]; then mv /etc/exim/exim.conf /etc/exim/exim.conf.old ln -s /etc/exim/exim.conf.work /etc/exim/exim.conf fi
As you can see, also other files can handily be customized like this. Once a configuration is set up - which is usually done by the package setup - it should be easy to add more of them.
However, you cannot use the menu option "new" in the chooser box of netenv to create a new configuration. This is because it will only write variable assignments into a new lulu-file, but not create the necessary script. Instead, you have to manually create and and edit files in /etc/netenv/ with contents analogous to the files described above: $computername-$networkname defines the NETENV_SCRIPT, which in turn redirects the symbolic links. The Debian setup will create these files with the names $computername (configuration file) and setup-default (NETENV_SCRIPT), respectively.
There are even more possibilities to configure netnev if the network settings are stored in /etc/network/interfaces. Especially the "mapping" mechanism, as described in the manpage interfaces(5) is very interesting. An other way is outlined in the file netenv_setup_debian_example.
If your network settings are stored in /etc/pcmcia/network.opts, you have one big advantage: This file uses variable assignments, for example
IPADDR="123.456.789.12"
This is exactly the method that netenv was originally built for. Consequently, you can simply use the menu option "new" (Set_up_new_environment) in its chooser dialog box to create a new network environment.
However, in order that these variables are in effect when a network card ist started, they need to be read in in /etc/pcmcia/network.opts. Since this file belongs to the package pcmcia-cs, netenv is not allowed to change it during setup. However, you as a user (or rather administrator) may and should do it. The simplest way would be to add the line
. /var/tmp/netenv
to the end of the file (yes, with the leading dot!). Somewhat more sophisticated would be to apply the following patch (also included as netenv-network.opts.patch):
--- etc/network.opts.orig Sat Nov 8 12:10:56 2003 +++ etc/network.opts Sat Nov 8 12:42:27 2003 @@ -21,6 +21,8 @@ PPPOE="n" # Use WHEREAMI (via the whereami package)? [y/n] WHEREAMI="n" + # Use NETENV (via the netenv package)? [y/n] + USE_NETENV="y" # Host's IP address, netmask, network address, broadcast address IPADDR="" NETMASK="255.255.255.0" @@ -55,5 +57,13 @@ # Card eject policy options NO_CHECK=n NO_FUSER=n + if [ $USE_NETENV = y ]; then + if [ -r /var/tmp/netenv ]; then + . /var/tmp/netenv + else + echo "/var/tmp/netenv unreadable. Perhaps you should set" + echo "USE_NETENV=n in /etc/pcmcia/network.opts" + fi + fi ;; esac
This has several effects. First, it allows for easy deactivation of netenv. Second, the first pair of lines is added near the place where also wherami, a program with similar functionality, is configured - anybody will easily find out that netenv is used. This might be interesting in case of a bug report. Third and last there is an additional check for existence and readability of the file where netenv stores the information to be used this time.
NETENV_RUN_INIT_SCRIPTS="chrony myinitscript"/etc/init.d/networking will be executed in any case.
As described above it is possible to tell netenv to restart some daemons using their init scripts. Unfortunately this does not work with wwwoffle. The reason is that wwwoffle remembers its status (online or offline) before stopping the service, and restores it after starting again. This is reasonable under some circumstances (e.g. if the wwwoffle package is updated while being online). However, it has the unwanted result that
/etc/init.d/wwwoffle restartcannot be used if one is about to change from an offline to an online configuration, or vice versa.
Therefore there is an other variable for wwwoffle (and possibly other scripts with similar behavior), NETENV_START_STOP_SCRIPTS. Scripts in this space-separated list will not be called with restart, instead first with stop and afterwards with start.
The Debian maintainer of netenv thinks this behavior of the wwwoffle package is a bug, see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=224937.
Back to Table of ContentsThose I had a closer look at, try to find out the network environment by sending arp requests. SuSe recently came up with System Configuration Profile Management scpm, which is quite powerful but lacks an user interface during boot which I feel to be important.