Hi all,
This is a problem (really a minor annoyance) that's bugged me for awhile and it's high-time to tackle it! My linux laptop travels with me pretty much everywhere: school, work, home, family and friend's houses. Usually, I manually bring up the interfaces at each location I use the laptop. All the places (and ways) I connect could be classified as follows:
- Trusted Connections (wired, trusted and secured wireless networks)
- Cautious Connections (school wired and wireless, colleges are notorious for their lack of security)
- Untrusted Connections (Starbucks, unsecured wifi etc.)
This of course begs the question of how to code this into the init process so that my laptop can automagically connect in the appropriate way. This is how I connect to each network type:
- Trusted Connections
- Wired: straight connection (dhcpcd)
- Wireless: bring up the interface, run wpa_supplicant, dhcpcd interface
- Cautious Connections
- Wired: straight connection (here I've been a bit trusting, quite possibly too much so)
- Wireless: redirect-gateway through an OpenVPN tunnel to one of my trusted connections
- Untrusted Connections
- Wired: None! (I don't plug into anything I don't trust! I suppose I could redirect-gateway here too though...)
- Wireless: redirect-gateway through an OpenVPN tunnel to one of my trusted connections
My question is this: How would I go about automating this based on the categories I've got above?
The basic flow of the init script should look like this (pseudo-bash/perl-code):
Code:
#!/bin/bash
# Check if there is a cable
if(cable_connected eth0)
dhcpcd eth0;
exit;
fi
# Else check for trusted wireless
if(found_wireless == 'Trusted')
wpa_supplicant -iath0;
dhcpcd ath0;
fi
# Else if cautious or untrusted networks found, connect and tunnel through VPN
if(found_wireless == 'Cautious' || found_wireless == 'Untrusted')
dhcpcd ath0;
Open_VPN_tunnel;
redirect_gateway;
fi
# If no networks found, just exit
PS - I apologize for the broken bash/perl attempt there, been programming in perl for so long I've forgot most of my bash... As far as distros go, I seem to bounce back and forth between Gentoo and Slackware, right now I'm on Slackware.
Thanks for your help!