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?

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)

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Previous Post

How to Make Website WCAG Compliant?

Next Post

Link download Kali Linux 2020.1 (ISO + Torrent)

Related Posts