On Tue, Nov 13, 2007 at 10:22:58AM -0800, ispmarin wrote: > On Nov 13, 3:50 pm, Andrew Sackville-West > <and...@farwestbilliards.com> wrote: > > On Tue, Nov 13, 2007 at 03:08:01AM -0800, ispmarin wrote: > > > Hello all. > > > > > I´ve just installed debian lenny (amd64) on my macbook, and since this > > > is my first time as a notebook user, I would like to hear your ways to > > > control connectivity. ... > > the wireless part is (remarkably) fairly easy to work out. I use a > > 'mapping' interface stanza in my /etc/network/interfaces that hooks to > > a simple script. This script greps through an 'iwlist <interface> > > scan' call looking for particular strings. the script then sets the > > iwconfig parameters based on those results, changes some symlinks for > > /etc/hosts and /etc/apt/sources.list and then echoes out an > > appropriate string to return to the 'mapping' so that the right > > address gets assigned. ... > > Can you post the script that script? > andrew@delappy:~$ sudo cat /etc/network/interfaces # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). ... auto eth2 mapping eth2 script /usr/local/sbin/wireless-detection.sh map HOME eth2home map AWAY eth2away iface eth2home inet static address 192.168.5.2 netmask 255.255.255.0 gateway 192.168.5.1 up /usr/local/sbin/home-hosts.sh iface eth2away inet dhcp up /usr/local/sbin/away-hosts.sh It took me a while to figure that out, but apparently the HOME and AWAY are just comments or identifiers and don't actually do anything. What's pertinent is that the eth2home, eth2away stuff matchup with the output of the script below. andrew@delappy:~$ cat /usr/local/sbin/wireless-detection.sh #!/bin/bash # # attempt to determine where we are and setup up wireless appropriately HOME_ID=2702s if [ `iwlist eth2 scan | grep $HOME_ID` ]; then iwconfig eth2 essid $HOME_ID iwconfig eth2 key restricted s:xxxxxxxxx iwconfig eth2 mode ad-hoc LOCATION="eth2home" else iwconfig eth2 essid off iwconfig eth2 ap any iwconfig eth2 key off iwconfig eth2 mode auto LOCATION="eth2away" fi if [ "$LOCATION" ]; then echo $LOCATION exit 0 fi exit 1 The above is using wep not wpa, due to restictions in the firmware for my cheap old card. You should be able to work out something similar for wpa. Simple enough. The 'up' scripts /usr/local/sbin/{home,away}-hosts.sh just rm /etc/hosts and then ln -s /etc/{home,away}-hosts /etc/hosts so that I get different hosts fiels depending on whether I'm inside or outside my LAN. hth A
Attachment:
signature.asc
Description: Digital signature