Let's say we have a TP-Link USB Wifi adapter (TL-WN321G 54Mbps) and we want to configure it to work in FreeBSD 9.x.
After attaching to one our USB port we will get:
dmesg
...
run0: <1 .0=".0"> on usbus4
run0: MAC/BBP RT3070 (rev 0x0201), RF RT2020 (MIMO 1T1R), address 54:e6:fc:94:6e:0f
run0: firmware RT2870 loaded
wlan0: Ethernet address: 54:e6:fc:94:6e:0f1>
So we notice is detected as run0 device.
To configure we wil first create a wlan interface:
ifconfig wlan0 create wlandev run0
Then we can scan for Access Points:
ifconfig wlan0 up scan
If is already up we can just scan for an Access Point:
ifconfig wlan0 scan
Now, we will use WPA-PSK which is configured for our Access Point. In order to do that create a file called /etc/wpa_supplicant.conf with the following content:
network={
ssid="ourwifi_ssid"
psk="our_password"
}
Next we will add the following lines to /etc/rc.conf:
wlans_run0="wlan0"
ifconfig_wlan0="WPA DHCP"
Note: our password should be at least 8 characters long.
Now we will try to connect to the A.P.:
wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf
If you do not want to run wpa_supplicant command you could restart your network:
/etc/rc.d/netif
Still if you have a second network connection and you do not want to
lose that when restarting then use wpa_supplicant command instead of running netif script.
If the connection is succesfully, then you should see associated status for your wlan0 when you run ifconfig.
Refer to:
http://www.freebsdonline.com/content/view/936/506/