LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 09-10-2005, 05:10 PM   #1
aeuzent
Member
 
Registered: Jan 2005
Location: Maryland, USA
Distribution: Ubuntu/Debian
Posts: 102

Rep: Reputation: 15
Wireless On Boot Connect


Alright I've been trying to get my wireless network to connect on boot. After much fiddling with the interfaces file I've given up and chosen instead to create a little shell script that just runs the basic iwconfig commands. But now I have some free time and I'm trying to figure out exactally what part of the interfaces file is wrong

Here's the file

Code:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# This is a list of hotpluggable network interfaces.
# They will be activated automatically by the hotplug subsystem.
mapping hotplug
        script grep
        map eth1
#       map eth0

# The primary network interface
iface eth1 inet dhcp
        # wireless-* options are implemented by the wireless-tools package
        wireless-mode managed
        wireless-essid ""
        wireless-key #########

# iface eth0 inet dhcp



iface eth0 inet dhcp



auto eth1
 
Old 09-11-2005, 11:00 AM   #2
PenguinPwrdBox
Member
 
Registered: Oct 2003
Posts: 568

Rep: Reputation: 31
I wrote a perl script for this. You may need to edit accordingly:
Basically, what it does, is checks for the presence of HW, and if it finds it, will connect to the network, depending on what network it is.
If I'm at home, i set it up statically...
Elsewhere - dhcp......

Code:
#!/usr/bin/perl -w

use Term::ANSIColor;

no warnings;

print "Bringing up interface ra0\:\t\t\t";

$device = `lspci | grep RaLink | awk -F ' ' '{print $6}'`;

if($device =~ /RaLink/){
	$module = `lsmod \| grep rt2500 `;
	$module =~ s/(rt2500).*/$1/;
	chomp $module;

	if($module eq "rt2500"){
	    	my $ssid =`iwlist ra0 scanning | grep -i essid | awk -F '"' '{print $2}'`;
  	    	$ssid =~ s/ESSID:"(.*)"/$1/;
    	   	chomp $ssid;

  		if($ssid =~ /belkin54b/){&static;&success;}

    		elsif($ssid =~ /.+/){&dhcp;}

    		elsif($ssid eq undef){&failed_wireless;}

  	}
	else{
		`insmod /lib/modules/2.6.11-1.1369_FC4/extra/rt2500.ko`;
		my $ssid = `iwlist ra0 scanning | grep -i essid | awk -F : '{print $2}'`;
		$ssid =~ s/ESSID:"(.*)"/$1/;
		chomp $ssid;

		if($ssid =~ /belkin54b/){&static;&success;}

  	 	elsif($ssid =~ /.+/){&dhcp;}

    		else{&failed_wireless;}

	}


}

else{&failed_hw;}





sub success{
	print "[   ";
	print color ("green"), "OK", color ("reset");
	print "   ]\n";

}

sub failed_wireless{
      	print "[ ";
      	print color ("red"), "FAILED", color ("reset");
      	print " ]\n";
      	print "No wireless networks available\n";

}

sub failed_hw{
	print "[ ";
   	print color ("red"), "FAILED", color ("reset");
      	print " ]\n";
      	print "No wireless device present\n";

}

sub static{
	system("ifconfig eth0 down");
	system("ifconfig ra0 down");
	system("ifconfig ra0 192.168.2.11 netmask 255.255.255.0 up");
	system("route add default gw 192.168.2.1");
	system("echo 'nameserver 192.168.2.1' > /etc/resolv.conf");

}

sub failed_dh_aquire{
	print "[ ";
   	print color ("red"), "FAILED", color ("reset");
      	print " ]\n";
      	print "Failed to aquire network address via DHCP\n";

}

sub failed_dh_kill{
	print "[ ";
   	print color ("red"), "FAILED", color ("reset");
      	print " ]\n";
      	print "Failed to terminate running dhclient process\n";
	exit;

}

sub dhcp{
	$dhcp_pid = `ps aux | grep dhclient | grep -v grep | awk '{print $2}'`;
	$dhcp_pid =~ s/root\s*(\d*).*/$1/;
	chomp $dhcp_pid;
	if($dhcp_pid){$kill_success = system("kill -9 $dhcp_pid");}
	if($kill_success = 0){$dhcp_status = system("dhclient -q ra0");}
	else{&failed_dh_kill;}
	if($dhcp_status == 0){&success;}
	else{&failed_dh_aquire;}

}

Last edited by PenguinPwrdBox; 09-11-2005 at 11:06 AM.
 
  


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
Connect to Wireless Network RySk8er30 Linux - Wireless Networking 8 11-19-2007 01:55 AM
wireless does not connect sheine Linux - Wireless Networking 2 11-13-2005 08:58 AM
Wireless won't connect anymore Matty-J Linux - Wireless Networking 7 06-08-2005 11:44 AM
can't connect to wireless AP Zuggy Linux - Wireless Networking 2 02-03-2005 04:13 PM
Can't connect to wireless internet! trendicoff Linux - Wireless Networking 5 11-28-2004 05:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 03:37 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