• If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!


ClientMode (Managed Mode) with WPA-Supplicant

Page history last edited by PBworks 18 years, 3 months ago

ClientMode with WPA-Supplicant


  • first of all you need to install wpa-supplicant, if you have not compiled in


$ ipkg install wpa-supplicant


This will also install libopenssl...

Or you use:

(Thanks to Yasha)


  • then create a configuration file for wpa-supplicant named "wpa_supplicant.conf"


$ vi /etc/wpa_supplicant.conf


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


  • let's have a look into /etc/modules.d/20-madwifi ... change "ath_pci" to "ath_pci autocreate=sta"


  • now "reboot"


  • now it's time for more input:


$ 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.


  • now run wpa-supplicant:


$ 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


  • after the connection to the ap has status COMPLETED you have to enter:


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

  • This is a wireless client mode WPA connect script that assumes no modules have been loaded nor any other initialization of ath0 performed. Once you have an /etc/wpa_supplicant.conf file, do something like:


# 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



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



Comments (0)

You don't have permission to comment on this page.