OpenBSD: Configure Ralink USB IEEE 802.11a/g/n Wireless Network Adapter

I brought a USB 2.0 wireless adapters based on the Ralink RT2700U, RT2800U and RT3000U chipsets. How do I configure and use it under OpenBSD operating systems?

Tutorial details
Difficulty level Intermediate
Root privileges Yes
Requirements OpenBSD with run driver
Est. reading time N/A
This usb wireless adapter works out of box under OpenBSD and Linux operating systems. Under OpenBSD you need to use run driver. From the man page:

The run driver can be configured to use Wired Equivalent Privacy (WEP) or Wi-Fi Protected Access (WPA-PSK and WPA2-PSK). WPA is the de facto encryption standard for wireless networks. It is strongly recommended that WEP not be used as the sole mechanism to secure wireless communication, due to serious weaknesses in it. The run driver offloads both encryption and decryption of data frames to the hardware for the WEP40, WEP104, TKIP(+MIC) and CCMP ciphers.

Step #1: Make sure device is detected by OpenBSD

Type the following command:
# dmesg | egrep -i 'wlan|usb|run'
Sample outputs:

ohci0 at pci0 dev 19 function 0 "Compaq USB OpenHost" rev 0x08: irq 5, version 1.0, legacy support
usb0 at ohci0: USB revision 1.0
uhub0 at usb0 "Compaq OHCI root hub" rev 1.00/1.00 addr 1
run0 at uhub0 port 1 "Ralink 802.11 n WLAN" rev 2.00/0.01 addr 2
run0: MAC/BBP RT2872 (rev 0x0202), RF RT2820 (MIMO 2T2R), address 00:aa:xx:yy:e4:6e

You can use usbdevs comamnd to see USB devices connected to the system:
# usbdevs
Sample outputs:

addr 1: OHCI root hub, Compaq
 addr 2: 802.11 n WLAN, Ralink

You can also use the ifconfig command:
# ifconfig run0

Step #2: Connect to the wireless router

Type the following command:

ifconfig run0 nwid {YOUR-SSID-NETWORK} wpa wpakey {YOUR-PASSHPRASE}

In this example, connect the nixcraft network ID (ESSID) with wpa security password (passphrase) called foobar:

ifconfig run0 nwid nixcraft wpa wpakey foobar

Finally, use the dhclient utility to configuring network interfaces using DHCP to get an IP address from the wireless router / access point:
# dhclient run0
Sample outputs:

DHCPREQUEST on run0 to port 67
DHCPACK from (74:ad:01:xx:yy:zz)
bound to -- renewal in 43200 seconds.

Verify your connectivity:
# ping
# ping
# netstat -nr
# cat /etc/resolv.conf

You can use ifconfig command to scan wireless network:
# ifconfig run0 scan
Sample outputs:

run0: flags=8843 mtu 1500
        lladdr 00:1d:xx:yy:zz:dd
        priority: 4
        groups: wlan egress
        media: IEEE802.11 autoselect (OFDM54 mode 11g)
        status: active
        ieee80211: nwid nixcraft chan 1 bssid 74:44:xx:yy:zz:dd 50dB wpakey 0x20c356ae19610381977a7d0d9ebd9ee279 wpaprotos wpa1,wpa2 wpaakms psk wpaciphers tkip,ccmp wpagroupcipher tkip
                nwid dd-wrt chan 6 bssid 00:0f:xx:yy:zz:dd 54dB 54M privacy,short_slottime 
                nwid asusap chan 6 bssid 00:24:xx:yy:zz:dd 56dB 54M privacy,short_preamble,short_slottime 
                nwid testloop chan 1 bssid 74:44:xx:yy:zz:dd 50dB 54M privacy,short_slottime 
                nwid seema chan 6 bssid 80:a1:xx:yy:zz:dd 64dB 54M privacy,short_slottime 
                nwid bbcafe chan 6 bssid 80:a1:xx:yy:zz:dd 64dB 54M privacy,short_slottime 
        inet netmask 0xffffff00 broadcast

Step #3: Persistent network configuration

Add the following entry to /etc/hostname.run0 file that configures run0 to join nixcraft network available on boot, using WPA key ‘SOMEPASSWORD’, channel 1, obtaining an IP address using DHCP:
echo 'dhcp nwid nixcraft wpa wpakey SOMEPASSWORD chan 1' > /etc/hostname.run0
Reboot the system to test changes or type the following command to restart networking under OpenBSD:
# ifconfig run0 down
# sh /etc/netstart

Recommend readings
  1. man pages: run, hostname.if, and ifconfig
  2. List: Linux Compatible USB Wireless Adapter (WUSB)

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 3 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
3 comments… add one
  • rickster Jan 8, 2013 @ 10:47

    Yes but “who” makes it and sells it. Model# please ?
    “…”brought a USB 2.0 wireless adapters based on the Ralink RT2700U, RT2800U and RT3000U chipsets…”.

    and thanks for the howto, but any chance you could be a little more specific in the exact Name/Model… of the item you bought in the store.?

    I would very much like to purchase, one of these, since obviously the “Atheros AR9485” that is presently built-in to my new Laptop can NOT be configured in OpenBSD.
    Sadly, bad, bad “Atheros”(lately) will NOT even supply the firmware/docs for *BSD !?. :(

    • 🐧 nixCraft Jan 8, 2013 @ 11:37

      Personallu, I am using “Buffalo WLI-UC-G300N Wireless LAN Adapter” with OpenBSD v5.3.

      Pro tip: read the man page of the following to see exact make and models for various USB WLAN devices:

      man 4 ral
      man 4 ural  
      man 4 rum 
      man 4 run 
      man 4 uath 
      man 4 upgt 
      man 4 urtw 
      man 4 zyd 
      man 4 atu


      • rickster Jan 9, 2013 @ 7:36


Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum