ClientMode (Managed Mode) with WPA-Supplicant

ClientMode with WPA-Supplicant



$ ipkg install wpa-supplicant


This will also install libopenssl...

Or you use:

$ ipkg install

(Thanks to Yasha)



$ vi /etc/wpa_supplicant.conf


Here you can find some information and an example configuration file:





$ 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 }'`
while [ $wpa_connection_complete = 0 ]; do
        echo "still waiting until WPA connection is complete (sleeping for 5 seconds)..."
        sleep 5

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: (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

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

vi WGT634U_wireless_connect

chmod +x WGT634U_wireless_connect



end dacb note


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


#### VLAN configuration


vlan0ports="0 1 2 3 4 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








#### WAN configuration



# not using wan