LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking > Linux - Wireless Networking
User Name
Password
Linux - Wireless Networking This forum is for the discussion of wireless networking in Linux.

Notices

Reply
 
Search this Thread
Old 06-02-2005, 02:53 PM   #1
quiescere
Member
 
Registered: Sep 2003
Distribution: Slackware64 13.1
Posts: 52

Rep: Reputation: 15
Automatic connection to different hotspots


Having finally found a combination of kernel and prism54 versions that works with reliably with my setup (2.6.7 with prism54 1.1 on an old toshiba satellite with a WG511), I'm now happily using my laptop all over town. However, apart from my home network, which I've set up as the default connection, all other networks require me to run through a set of iwconfig/ifconfig/dhcpcd commands manually. Is there a utility that will do this automatically?

I've both kismet and airsnort installed, and they're quite useful, but unless I've overlooked some features they are purely sniffers. I want something that will display a list of ambient networks, allow me to select from the list, and ideally store any relevant connection information (WEP keys, in particular), so I don't have to re-enter them every time I reconnect to a network I've been before.

I can write my own if necessary, but it just seems so obvious a task that someone out there must have done it before (and probably better). O, and in an ideal world, this utility would not depend on KDE or GNOME.
 
Old 06-03-2005, 04:36 PM   #2
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,790
Blog Entries: 1

Rep: Reputation: 414Reputation: 414Reputation: 414Reputation: 414Reputation: 414
You might want to check out KwifiManager, which does some of what you want. It can store up to four different configurations and despite the K moniker, it runs on pretty much any X desktop. However, it might require a KDE library or two. However, I don't think it scans for new networks.

I got tired of pretty much the same problem, so I wrote a script that stores the info for my home network, but before it configures the card it first scans for available networks and then presents a list to choose from. Since my home network is the only one I use WEP for, it doesn't store keys for other networks, but it wouldn't be hard to modify it to do so. Since I use ndiswrapper, it loads that module, but that would be easy to change to load different modules. It is also written for Slackware, so it may need some tweaking to work with other distros.

Code:
#!/usr/bin/perl
$Interface = "wlan0";
$HomeESSID = "HomeDomainName";
$WEP = "HomeWEPKey";
$Mode = "Managed";
$IWCONFIG = "/sbin/iwconfig";
$DHCP = "/sbin/dhcpcd -t 10 -d";
@APList = ();
#First load the ndiswrapper module
print("Loading ndiswrapper\n");
system("/sbin/modprobe ndiswrapper");
print("Scanning for wireless access points\n");
@ScanList = qx/iwlist wlan0 scan/;
foreach $a (@ScanList){
 if($a =~m/No scan results/){
                print("No networks detected, enabling home network\n");
                &homeNet;
        }
 if($a =~ m/$HomeESSID/){
                print("Home network detected\n");
  &homeNet;
 }
 if ($a =~m/ESSID/){
  @Temp = split(/"/,$a);
  push(@APList,$Temp[1]);
  for($x=0;$x<=$#APList;$x++){
   print("At $x is $APList[$x]\n");
  }
 }
}
&selectFrom;
sub homeNet{
 print("Setting up wlan0\n");
 system("$IWCONFIG $Interface essid $HomeESSID");
 system("$IWCONFIG $Interface mode $Mode");
	#&errorCheck('Second Mode');
	system('/sbin/iwconfig wlan0 key $WEP);
	#&errorCheck('WEP');
	print("Requesting IP from $HomeESSID\n");
	system("$DHCP $Interface");
	#&errorCheck('DHCPCD');
	system ("ifconfig $Interface up");
	#&errorCheck('Ifup');
	print("Configuration done\n");
	exit;
}
sub selectFrom{
	print("Select one of the following AP points\n");
	for($x=0;$x<=$#APList;$x++){
		print("$x - $APList[$x]\n");
	}
	print("Select by number: ");
	$SelectAP = <STDIN>;
	if((0 <= $SelectAP) and ($SelectAP<=$#APList)){
		print("Using $APList[$SelectAP]\n");
		system("$IWCONFIG $Interface essid $APList[$SelectAP]");
		print("Requesting IP from $APList[$SelectAP]");
		system("$DHCP $Interface");
		system("ifconfig $Interface up");
		exit;
	}
	else{
		print("Please select an acceptable number\n");
		&selectFrom;
	}
	exit;
}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Automatic Wireless Connection for Kubuntu combatwombat Linux - Wireless Networking 1 10-02-2005 02:42 PM
wireless hotspots zuessh Linux - Security 1 08-01-2005 12:41 PM
automatic connection to network jiante Linux - Networking 7 07-27-2005 03:37 AM
Searching for HotSpots? carlosinfl Linux - Wireless Networking 4 02-23-2005 09:17 PM
Automatic Connection & FAT32 Question Bigun Linux - General 2 09-12-2002 12:08 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration