[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Handling several network locations [Was: wireless lan config]



[ I'm Cc: debian-laptop as it's more a laptop issue than a powerpc one. ]

On Wed, Aug 15, 2001 at 05:09:51PM -0400, J. Steinbachs wrote:

> On Wed, 15 Aug 2001, NeilFred Picciotto wrote:
> 
> > > Here's a version of what's in my /etc/network/interfaces. You can
> > > basically put anything after "up" -- see man interfaces(5).
> >
> > this is a pretty slick way of doing it.  but does anyone have a convenient
> > way of switching between multiple locations (with different network
> > passwords, and so on)?
> 
> Check out QuickSwitch http://www.muthanna.com/quickswitch/Docs/docs.html
> 
> -jennifer

Since January 2000 (with slink on Intel laptop), I study this problem and I
had a good solution that handles different ISPs thru PPP and different
SCHEMEs thru PCMCIA ethernet card.

Today, my laptop has a builtin ethernet card so I am studying again how to
switch between different network locations.  In fact, I am studying only
the glue on top of the following tools: dnrd, masqmail and wwwoffle.

- dnrd Domain Name Relay Daemon allow all your running programs to use new
  nameservers.  Setup 127.0.0.1 as primary nameserver and dnrd will
  forward requests to real nameservers.

- masqmail is a MTA (mail transport agent).  It has special support for
  connections to different ISPs.

- wwwoffle is a simple proxy server with special features for use with
  dial-up internet links.  In fact I had need it only because I can't
  direct use HTTP at work.  You need to use a perl script that's not in
  debian package but in upstream tarball.

I discover today package noffle ``It does for NNTP what wwwoffle does
for HTTP'' but I have not try it yet.


With woody, /etc/network/interfaces can be setup to auto detect current
location with special mapping read examples in file
/usr/share/doc/ifupdown/examples/network-interfaces.gz

I use the following basic glue in /etc/network/interfaces:

#auto eth0
mapping eth0
	script /etc/network/map-scheme.sh
	map Work eth0-work
	map Home eth0-home

iface eth0-work inet static
        address 172.16.100.164
        netmask 255.255.0.0
        network 172.16.0.0
        broadcast 172.16.255.255
        gateway 172.16.1.254
        up /bin/echo Work > /tmp/connect_route || true
        down /bin/rm /tmp/connect_route || true
        up /usr/sbin/dnrd -s 172.16.15.130 -s 172.16.15.129 || true
        down /usr/sbin/dnrd || true


The script /etc/network/map-scheme.sh use content of file
/etc/network/scheme to select current location.

#!/bin/sh

iface="$1"
which=""

[ -f /etc/network/scheme ] || exit 1

lookup=$(cat /etc/network/scheme)

while read testval scheme; do
	if [ "$which" ]; then continue; fi
	if [ "$lookup" = "$testval" ]; then which="$scheme"; fi
done

if [ "$which" ]; then echo $which; exit 0; fi
exit 1


Switching location is then done by the small script:

#!/bin/sh

SCHEME=${1:-"none"}
DEVICE=${2:-"eth0"}

echo "$SCHEME" > /etc/network/scheme
egrep -q "^$DEVICE=" /etc/network/ifstate && /sbin/ifdown $DEVICE
/sbin/ifup $DEVICE


My .02 euro cents
-- 
Edouard G. Parmelan
http://egp.free.fr



Reply to: