Tag Archives: wpa_supplicant

WiFi configuration in FreeBSD (including WPA/WPA2)

Ok, once you have your drivers installed for your WiFi in FreeBSD, you’re ready to setup your WiFi.  I’m using an NDIS driver (see my post on Project Evil for more info) – so my wireless device is called ndis0.

I’m going to assume that you are using WPA/WPA2 and DHCP (the most common setup for WiFi) in this document.

To configure your wireless interface, add the following lines into /etc/rc.conf:

wlans_ndis0=”wlan0″
ifconfig_wlan0=”WPA DHCP”

Now we need to configure the WPA/WPA2 settings.  I will assume we have 2 wireless networks for this – “wifi1” and “wifi2” which have the WPA/WPA2 keys of “one” and “two” respectively.  We will prefer to connect to “wifi1” when possible.

To setup WPA/WPA, edit (or create) the file /etc/wpa_supplicant.conf and add the following:

network={
priority=1
ssid=”wifi1″
psk=”one”
}

network={
priority=2
ssid=”wifi2″
psk=”two”
}

Next time you restart your computer, you will have a ‘wlan0’ interface which will attempt to connect to the listed networks (in order of priority).  You can confirm it is associated with ifconfig wlan0 – in my case, i get:

wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether xx:xx:xx:xx:xx:xx
inet 172.31.0.100 netmask 0xffffff00 broadcast 172.31.0.255
media: IEEE 802.11 Wireless Ethernet autoselect mode 11g
status: associated
ssid wlan1 channel 7 (2442 Mhz 11g) bssid yy:yy:yy:yy:yy:yy
country US authmode WPA2/802.11i privacy OFF txpower 0 bmiss 7
mcastrate 0.5 mgmtrate 0.5 scanvalid 60 protmode CTS roaming MANUAL
bintval 0

Now, although it says “11g”, it actually achieves 802.11n speeds so you can ignore this.