I want to use a WGT634U box with FreeWRT as wifi client and with DHCP support (no encryption - ssh/rsync only), so I configured /etc/network/interfaces as described in the user-handbook:
$ grep -A 14 "^auto ath0" /etc/network/interfaces
auto ath0
iface ath0 inet dhcp
# address 192.168.10.1
# netmask 255.255.255.0
# broadcast +
wireless-type atheros
wireless-country DE
wireless-mode sta
wireless-ssid ap@majes.de
# wireless-channel 11
wireless-security none
# wireless-authorization psk psk2
# wireless-encryption aes+tkip
# wireless-wpa-key MyWlanSecret
Since the network interface isn't set to "up" the wifi driver won't associate and DHCP fails:
# ifdown ath0
# ifup ath0
wireless-country is a module option.
See http://madwifi.org/wiki/UserDocs/CountryCode
ath0
info, udhcpc (v0.9.9-pre) started
debug, Sending discover...
debug, Sending discover...
debug, Sending discover...
info, No lease, forking to background.
I quick and dirty workaround is to run an up-script after setting the wifi parameters:
$ cat /etc/network/if-pre-up.d/wireless-up
#!/bin/sh
#
# check SSID
#
[ "$IF_WIRELESS_SSID" ] || exit 1
# set the wireless interface to "up"
# (so the driver will associate to the ap)
ip link set $IFACE up