ClientMode (Managed Mode) with WPA-Supplicant


ClientMode with WPA-Supplicant

 

 

$ ipkg install wpa-supplicant

 

This will also install libopenssl...

Or you use:

$ ipkg install http://flyashi.dyndns.org:81/packages/libopenssl_0.9.8a-2_mipsel.ipk http://flyashi.dyndns.org:81/packages/wpa-supplicant_0.4.7-1_mipsel.ipk

(Thanks to Yasha)

 

 

$ vi /etc/wpa_supplicant.conf

 

Here you can find some information and an example configuration file: http://hostap.epitest.fi/wpa_supplicant/

 

 

 

 

$ iwconfig ath0 essid <ap-ssid> channel <ch#> ap xx:xx:xx:xx:xx:xx

 

 

ap-ssid = ssid of the ap you want to connect to

ch# = channel number of the ap

xx:xx:xx:xx:xx:xx = mac of the ap you want to connect to

 

To enhance the connection you can also activate some additional features

 

$ iwpriv ath0 turbo 1

$ iwpriv ath0 xr 1

$ iwpriv ath0 burst 1

 

These settings can be added to /etc/init.d/S20madwifi to automate this.

 

 

$ wpa_supplicant -c /etc/wpa_supplicant.conf -iath0 -B -Dmadwifi

 

Now wait a bit to get the connection completed.

You can controll this running "wpa_cli" (status).

 

dacb note: in a shell script, to block until this has completed, you can use:

# check status with wpa_cli status
# do not continue until the network is connected
echo "waiting until WPA connection is complete (may take up to a minute)..."
check_wpa_connection() {
wpa_connection_complete=`wpa_cli status | grep ^wpa_stat | awk -F= 'BEGIN { complete=0; } { if ($2 == "COMPLETED") complete=1; } END { print complete }'`
}
check_wpa_connection
while [ $wpa_connection_complete = 0 ]; do
        echo "still waiting until WPA connection is complete (sleeping for 5 seconds)..."
        sleep 5
        check_wpa_connection
done

end dacb note

 

 

$ iwpriv ath0 wds 1

$ brctl addif br0 ath0

 

This will enable bridging mode and will add the wireless device to the bridge.

It is important, that you make this after the connection is completed, otherwise the connection will timeout and fail.

 

Now the router works as a wireless bridge an you can connect some clients to the lan side of the wgt634u.

 

If somebody has a sollution to automate the process, please let me know.

mail: holzinet_at_web.de (Tino)

 

dacb note:

Here is one approach:

 

# get the script (assumes you have wget installed - which is the default, iirc)

wget -O WGT634U_wireless_connect http://openwrt.pbwiki.com/f/WGT634U_wireless_connect

# now, edit the values for wifi_essid , wifi_channel , wifi_ap_mac

vi WGT634U_wireless_connect

chmod +x WGT634U_wireless_connect

./WGT634U_wireless_connect

 

end dacb note

 

Here is my /etc/config/network as an example:

 

#### VLAN configuration

vlan0hwname=et0

vlan0ports="0 1 2 3 4 5*"

vlan1hwname=et0

vlan1ports="5"

# I don't need the wan port, because the wgt is only client...

# so I have added the wan port to vlan0

 

#### LAN configuration

lan_proto="static"

lan_ifname="vlan0"

lan_ifnames="vlan0"

lan_ipaddr="192.168.1.2"

lan_dns="192.168.1.1"

lan_gateway="192.168.1.1"

 

#### WAN configuration

wan_proto=none

wan_ifname=""

# not using wan

#wan_device="vlan1"

#wan_dns=""