FreeBSD wireless config for Ralink NICs

Update January 2016: I installed FreeBSD 10.2 on this old box and tried to revisit the configuration. I had to fix some mistakes in this post with respect to spelling, but otherwise, nothing has changed with this process nearly 5 years later. Gotta love FreeBSD!

The adapter can be identified by looking in the messages during the boot process, which are logged to /var/run/dmesg.boot.  I have a D-Link PCI wireless NIC, and the chipset is by Ralink and thus uses the ral0 driver.  I also found my wired Ethernet NIC card too, represented by vr0, which I have hooked up on a private network with no access to the Internet.

ral0: <Ralink Technology RT2561S> mem 0xf0000000-0xf0007fff irq 5 at device 15.0 on pci0
ral0: MAC/BBP RT2561C, RF RT2527
vr0: <VIA VT3043 Rhine I 10/100BaseTX> port 0x1080-0x10ff mem 0xf0008000-0xf000807f irq 9 at device 16.0 on pci0
vr0: Quirks: 0x1
vr0: Revision: 0x6

Seeing ral0 during the boot process means that the kernel has recognized the hardware and loaded the proper driver module.  You can verify this with ifconfig:

root@bsdbox# ifconfig ral0
ral0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 2290
ether 00:25:9c:a8:4f:16
media: IEEE 802.11 Wireless Ethernet autoselect mode 11g
status: no carrier

I did not perform the wireless configuration during installation of FreeBSD. I tried, but it failed for some reason, so I gave up and decided I would debug later. As such, this machine is not configured for wireless access, and thought there is an entry for ral0 in the ifconfig output, the  status is ‘no carrier’ indicating that I am not connected to the wireless access point.

For WPA, wpa_supplicant handles the encryption, where we must provide the SSID of the access point as well as the access point passphrase, which gets encrypted as a PSK.  Since I am using WPA Personal, I need to use wpa_passphrase to generate a config file that I can provide to the wpa_supplicant module with the proper SSID and PSK.  The file should be stored as /etc/wpa_supplicant.conf.

wpa_passphrase [ssid] [passphrase] > /root/wpa.conf      # keep a backup
cp  /root/wpa.conf /etc/wap_supplicant.conf

One can also directly edit /etc/wpa_supplicant.conf file and modify the SSID and PSK.

root@bsdbox# less /etc/wpa_supplicant.conf


With the security out of the way, we only have to configure the wlan module.  It would appear that in the past you could try to bring up the interface via the driver name, but the 802.11 system has changed and you now must create a wlanX device for use with ifconfig rather than the actual device itself.  This is not as hard as it sounds.  Add the following to your /etc/rc.conf file.

root@bodbox# /etc/rc.conf
ifconfig_wlan0=”WPA SYNCDHCP”

The device ral0 is now mapped to wlan0 through the wlan module, and ifconfig is told that wlan0 expects WPA authentication and should use SYNCDHCP to obtain an IP address for the interface wlan0.  After restarting the networking services I checked on the wlan0 interface:

root@bsdbox# ifconfig wlan0
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 00:25:9c:a8:4f:16
inet netmask 0xffffff00 broadcast
media: IEEE 802.11 Wireless Ethernet OFDM/48Mbps mode 11g
status: associated
ssid ….. channel 1 (2412 MHz 11g) bssid 00:7f:28:11:a3:34
country US authmode WPA2/802.11i privacy ON deftxkey UNDEF
AES-CCM 2:128-bit AES-CCM 3:128-bit txpower 0 bmiss 7 scanvalid 60
bgscan bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5
protmode CTS roaming MANUAL

root@bsdbox# ifconfig ral0
ral0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 2290
ether 00:25:9c:a8:4f:16
media: IEEE 802.11 Wireless Ethernet autoselect mode 11g
status: associated

Now the status for the interface card ral0 should say ‘associated’ rather than ‘no carrier’, and you should have an IP address for wlan0 as well.  Try to connect to an outside source to verify the wireless link is working, such as pinging

And that is all there is to it, much easier than I thought!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s