LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-07-2009, 01:30 PM   #1
c4onastick
Member
 
Registered: Aug 2006
Distribution: Slackware
Posts: 51

Rep: Reputation: 15
Lightbulb Conditionally Setting up Different Network Connections Based on Available Networks


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!
 
Old 09-07-2009, 02:23 PM   #2
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Hello c4onastick,

have you tried wicd? ftp://ftp.gwdg.de/pub/linux/slackwar....0/extra/wicd/
Maybe this tool will point you in the right direction.

Markus
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Setting up a Linux-based Open-Mesh Network, Part 1 LXer Syndicated Linux News 0 05-27-2009 06:40 AM
Two networks with two internet connections on same machine. lhrimunda Linux - Networking 4 08-21-2008 08:38 AM
2 networks and 2 internet connections on linux router seer_tenedos Linux - Networking 6 03-27-2005 07:24 AM
setting up a unix-based wireless home network name_in_use450 Linux - Wireless Networking 0 08-18-2004 07:21 PM
Need some advice on setting up a network with two internet connections e0n Linux - Networking 4 05-16-2003 09:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration