appaji ([info]appaji) wrote,
  • Mood: geeky
  • Music: background score from peacemaker

Not all those who wander are lost

I keep moving between various work/home locations and [sub-]networks where I use wired or wireless access.

- Two wired networks at work where I have a static IP address assigned.
- There are a few other subnets at work where I can get a DHCP lease.
- A wireless network at work which I use in case I am in a meeting room.
- My tiny wired / wireless network at home with three machines.
- Other arbitrary locations where I can find a wireless access point.

I use guessnet, ifplugd, waproamd and resolvconf in Debian to handle this diversity rather nicely after a one time configuration.

As soon as a I power-on my laptop or plug-in my laptop somewhere, ifplugd detects the link pulse if any on the ethernet and waproamd configures the appropriate WEP keys according to wireless networks found. It is guessnet that performs some tests in parallel and parks me to the first found configuration. resolvconf manages /etc/resolv.conf based on the directives in the network configuration. All these play neatly with each other. Fantabulous!

[majuli ~]
[majuli ~]$ sudo apt-get install guessnet ifplugd waproamd resolvconf

[majuli ~]
[majuli ~]$ cat /etc/network/interfaces

auto lo

iface lo inet loopback

auto eth0

mapping eth?
    script /usr/sbin/get-mac-address.sh
    map 00:11:25:D5:35:A0 wired
    map 00:12:F0:E9:82:9E wireless

mapping wired
    script guessnet-ifupdown
    map eth-home-static
    map eth-home-dhcp
    map eth-work-static8
    map eth-work-static11
    map default: eth-work-dhcp
    map timeout: 9
    map verbose: true

# Static / DHCP profiles for home LAN

iface eth-home-static inet static
    address 192.168.1.3
    netmask 255.255.255.0
    gateway 192.168.1.1
    dns-nameservers 61.1.96.69 61.1.96.71 61.1.128.65 61.1.128.5
    test1 peer address 192.168.1.1 mac 00:0F:A3:1F:82:AC source 192.168.1.3
    test2 peer address 192.168.1.2 mac 00:05:5D:4A:55:FD source 192.168.1.3

iface eth-home-dhcp inet dhcp
    dns-nameservers 61.1.96.69 61.1.96.71 61.1.128.65 61.1.128.5
    test1 peer address 192.168.1.1 mac 00:0f:A3:1F:82:AC source 192.168.1.3
    test2 peer address 192.168.1.2 mac 00:05:5D:4A:55:FD source 192.168.1.3

# Two possible subnets at work (Desktop LAN/Lab LAN) where I have a static IP

iface eth-work-static8 inet static
    address 10.72.8.42
    netmask 255.255.255.0
    gateway 10.72.8.1
    dns-search lan.work.com lab.work.com wan.work.com corp.work.com
    dns-nameservers 10.72.128.21 10.72.144.21 10.10.20.241 10.72.6.14
    test peer address 10.72.8.1 mac 00:00:0C:07:AC:65 source 10.72.8.42

iface eth-work-static11 inet static
    address 10.72.11.45
    netmask 255.255.255.0
    gateway 10.72.11.1
    dns-search lan.work.com lab.work.com wan.work.com corp.work.com
    dns-nameservers 10.72.128.21 10.72.144.21 10.10.20.241 10.72.6.14
    test peer address 10.72.11.1 mac 00:00:0C:07:AC:67 source 10.72.11.45

# DHCP lease in case I am on some other subnet at work

iface eth-work-dhcp inet dhcp
    dns-search lan.work.com lab.work.com wan.work.com corp.work.com
    dns-nameservers 10.72.128.21 10.72.144.21 10.10.20.241 10.72.6.14
    test1 peer address 10.72.9.1 mac 00:00:0C:07:AC:68 source 10.72.9.42
    test2 peer address 10.72.10.1 mac 00:00:0C:07:AC:69 source 10.72.10.45

mapping wireless
    script guessnet-ifupdown
    map wlan-home-static
    map wlan-home-dhcp
    map wlan-work-dhcp
    map default: wlan-dhcp
    map timeout: 9
    map verbose: true

# Static / DHCP profiles for home wireless network

iface wlan-home-static inet static
    address 192.168.1.4
    netmask 255.255.255.0
    gateway 192.168.1.1
    dns-nameservers 61.1.96.69 61.1.96.71 61.1.128.65 61.1.128.5
    test wireless essid essidhome

iface wlan-home-dhcp inet dhcp
    dns-nameservers 61.1.96.69 61.1.96.71 61.1.128.65 61.1.128.5
    test wireless essid essidhome

# Work wireless network doesn't have a public essid to test against

iface wlan-work-dhcp inet dhcp
    wireless-essid essidwork
    dns-search lan.work.com lab.work.com wan.work.com corp.work.com
    dns-nameservers 10.72.128.21 10.72.144.21 10.10.20.241 10.72.6.14
    test peer address 10.72.5.1 mac 00:00:0C:07:AC:05 source 10.72.5.3

# When I am at a barista or the airport

iface wlan-dhcp inet dhcp
    test wireless

[majuli ~]
[majuli ~]$ cat /usr/sbin/get-mac-address.sh

#!/bin/sh

set -e

export LANG=C

iface="$1"
mac=$(/sbin/ifconfig "$iface" | sed -n -e '/^.*HWaddr \([:[:xdigit:]]*\).*/{s//\1/;y/ABCDEF/abcdef/;p;q;}')
which=""

while read testmac scheme; do
    if [ "$which" ]; then continue; fi
    if [ "$mac" = "$(echo "$testmac" | sed -e 'y/ABCDEF/abcdef/')" ]; then which="$scheme"; fi
done

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

[majuli ~]
[majuli ~]$ cat /etc/default/ifplugd

# sourced by /etc/init.d/ifplugd and
# the hotplug script /etc/hotplug.d/net/ifplugd.hotplug

INTERFACES="eth0"
HOTPLUG_INTERFACES="eth0"
ARGS="-q -f -u0 -d10 -w -I"
SUSPEND_ACTION="stop"

[majuli ~]
[majuli ~]$ cat /etc/default/waproamd

# sourced by /etc/init.d/waproamd and
# the hotplug script /etc/hotplug.d/net/waproamd.hotplug

INTERFACES="eth1"
HOTPLUG_INTERFACES="eth1"
ARGS="-w"
SUSPEND_ACTION="stop"


More on how I manage my email, NIS, NFS mounts later :-)
Tags: debian, laptop, linux, tech

  • Post a new comment

    Error

    Your reply will be screened

    Your IP address will be recorded 

  • 18 comments

[info]cosmodoc

November 23 2005, 16:42:36 UTC 6 years ago

OMG such a hi-tech home LOL

[info]appaji

November 23 2005, 16:47:25 UTC 6 years ago

Well, not as "relative" hitech as the gadgets at the homes of certain doctors though :-"

[info]knutties

November 24 2005, 03:49:18 UTC 6 years ago

My laptop, wireless router are lying unused at home. I am so very comfortable with my Desktop alone.

Thanks for the post, I might just have bits flying all over my house soon.

[info]appaji

November 24 2005, 12:37:13 UTC 6 years ago

Unless your laptop isn't as powerful, I say it is mighty convinient with some other add-ons, like a docking station at work and a good KVM switch at home :-)

[info]knutties

November 24 2005, 12:51:00 UTC 6 years ago

The KVM switch is a nice idea. Should try it out. Thanks a lot. All this, only after I increase my usage of the laptop :)

[info]appaji

November 24 2005, 23:29:02 UTC 6 years ago

An extra 'puter is always good if you want to do development that can destroy stuff. Do you run unstable that is frequently upgraded?

[info]knutties

November 25 2005, 03:41:55 UTC 6 years ago

Do you run unstable that is frequently upgraded?

I am on dialup (thats the only viable option at Hosur). So, I run only stable at home :(. But as you said another 'puter is handy in case you do destructive stuff.

At office the situation is better, I have access to local Ubuntu and Debian stable repositories. But I can't get my personal laptop in :(

[info]sajith

November 24 2005, 14:03:51 UTC 6 years ago

I don't have a laptop and wireless router, being poor and penniless and all that. You don't mind donating those to a poor impoverished programmer, do you? ;)

[info]appaji

November 24 2005, 15:20:37 UTC 6 years ago

If he does mind donating those to poor impoverished programmers, I think I'll ask him if he doesn't mind donating it to a not-too-poor not-so-impoverished programmer like me ;)

[info]knutties

November 25 2005, 03:45:31 UTC 6 years ago

I am a poor impoverished programmer myself, unaware of my strengths hitherto (just like Hanuman) :)

[info]deepix

November 24 2005, 05:18:59 UTC 6 years ago

Thanks for the details - will wait for the other posts too.

[info]appaji

November 24 2005, 14:28:44 UTC 6 years ago

These nifty little scripts and configurations. I made this post specifically to highlight the usefulness of resolvconf (automagiconfig of /etc/resolv.conf is always a pain in the butt) and guessnet.

[info]sajith

November 24 2005, 14:05:33 UTC 6 years ago

Thanks for posting this. Now I know where to look when I get a laptop and wireless router :)

(Nono, I was joking to Natarajan.)

[info]appaji

November 24 2005, 23:20:01 UTC 6 years ago

Actually there is other software out there that does laptop config etc., but it was a post by martin f krafft that prompted me to try guessnet first. No regrets ;). I'll do a compare one of these days but I might not post anything about it (I'm too lazy :D)/

[info]thinkspecs

November 27 2005, 12:38:11 UTC 6 years ago

Yeyyy you did it :) It must be a real relief and not to mention the satisfaction :)

[info]appaji

November 27 2005, 13:40:54 UTC 6 years ago

Peace! Do they have reliable internet in palakollu (or wherever you are now)? ;) Reliable enough to prompt you to logon to LJ?

Anonymous

October 10 2007, 22:55:56 UTC 4 years ago

Great work

.

[info]appaji

December 4 2007, 03:57:30 UTC 4 years ago

Re: Great work

Thanks!
Create an Account
Forgot your login or password?
Facebook Twitter More login options
English • Español • Deutsch • Русский…