[SATLUG] wifi question

Jon Mark Allen jm at allensonthe.net
Wed Dec 29 11:52:13 CST 2010


I don't have my laptop so I don't have my sample wpa_supplicant conf
file, but here is my sample wpa setup script:

************** BEGIN *************
!/bin/bash

if [ "`id -u`" -ne 0 ]; then
        echo "You must be root to run this script";
        exit;
fi

# Change this to match your wireless card
DEV=wlan0

# Ubuntu's Network Manager tends to get in the way...
/etc/init.d/network-manager stop

# Reset the wireless card if it's already up
if [[ $(ifconfig ${DEV} | grep -c UP) -eq 1 ]]; then { echo -e
"\r\nWireless card ${DEV} already up - shutting down...\r\n" &&
ifconfig $DEV down; }; fi

echo -e "\r\nStopping any previous wpa_supplicant instances...\r\n"
killall wpa_supplicant

echo -e "\r\nBringing up ${DEV}...\r\n"
ifconfig ${DEV} up

# You may need to adjust the driver here for your card.  I'm using the
wext generic driver.
wpa_supplicant -Dwext -i${DEV} -B -c/etc/wpa_supplicant/wpa_supplicant.conf

dhclient ${DEV}

************** END *************

Save this file as "wifi" somewhere in your path, and call it with:

sudo wifi

wpa_supplicant scans for the available wireless networks and
automatically associates with any that are configured in my .conf
file.

I'm sure it could be improved but it works for me.

I can get my wpa_supplicant.conf file tonight if you want to take a look.

-- 
JM

/* If you haven't found something strange during the day, it hasn't
been much of a day.
-- John A. Wheeler */

On Wed, Dec 29, 2010 at 11:27, mark <mark at kandm-solutions.com> wrote:
> I believe iwlist scan (you can add the interface name to reduce the
> output) will give you the encryption method. WEP takes the key
> arguement, WPA required wpa_supplicant. wpa_passphrase which is part of
> wpa_supplicant will generate a configuration file for the network.Then
> you run wpa_supplicant to associate with the access point.
>
> At least in debian you can add some lines to /etc/interfaces  (you must
> still have wpa_supplicant installed) and it will connect automatically.
> That isn't really efficient if its a laptop that connects to different
> access points.
>
> manual cli steps for wpa
>
> tell iwconfig what interface and network to connect to
>        iwconfig wlan0 essid myssid
> use wpa_passphrase to generate a configuration file
>        wpa_passphrase myssid mypassphrase > myssid.conf
> use wpa_supplicant to associate with the access point
>        wpa_supplicant -B -iwlan0 -cmyssid.conf -Dwext
> use dhclient to get an address
>        dhclient wlan0
>
> the driver for wpa_supplicant depends on your wireless card. the options
> are listed in the wpa_supplicant man page. I have a card that supports
> wpa but the linux driver I'm using for it does not. Hopefully you don't
> run into that issue. If you connect to the network alot it would
> probably be easiest to generate the config file with wpa_passphrase and
> then make a script that does the rest.
>


More information about the SATLUG mailing list