Configuring Wireless

For instructions on how to install firmware not included in the default install, please see the OpenBSD FAQ.

First, find your wireless device with dmesg:

# dmesg
...
athn0 at uhub0 port 3 configuration 1 interface 0 "VIA TECH VIA USB2.0 WLAN" rev 2.00/1.08 addr 3
athn0: AR9271 rev 1 (1T1R), ROM rev 15, address 00:12:7b:20:54:07
...

The laptop above uses the AR9271 chip and the athn(4) driver. In the examples below, we use if0 as a placeholder for your specific wireless driver. Replace if0 with your driver.

Next, we bring the interface up and scan for nearby wireless access points:

# ifconfig if0 up
# ifconfig if0 scan
...
ieee80211: nwid MYWIFI chan 1 bssid aa:bb:cc:dd:ee:01 -61dBm wpakey wpaprotos wpa2 wpaakms psk wpaciphers ccmp wpagroupcipher ccmp
        nwid MYWIFI chan 1 bssid aa:bb:cc:dd:ee:01 -63dBm HT-MCS31 privacy,short_slottime,radio_measurement,wpa2,wpa1
        nwid "ANOTHERWIFI" chan 6 bssid aa:bb:cc:dd:ee:02 -76dBm HT-MCS7 privacy,spectrum_mgmt,short_slottime,wpa2
        nwid AIRPORTWIFI chan 10 bssid aa:bb:cc:dd:ee:03 -79dBm HT-MCS15 privacy,short_preamble,short_slottime,radio_measurement,wpa2,wpa1
        nwid "" chan 10 bssid aa:bb:cc:dd:ee:04 -79dBm HT-MCS15 privacy,short_preamble,short_slottime,radio_measurement,wpa2
        nwid "" chan 11 bssid aa:bb:cc:dd:ee:05 -84dBm HT-MCS15 privacy,short_preamble,short_slottime,wpa2
...

To connect to MYWIFI:

# ifconfig if0 nwid MYWIFI wpakey MYWPAKEY
# ifconfig if0 autoconf
# ifconfig if0 inet6 temporary

Replace MYWIFI and MYWPAKEY with the actual network ID and wpa key.

We test the connection is successful:

# ping 8.8.8.8 
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: icmp_seq=0 ttl=109 time=86.059 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=109 time=362.485 ms
...
# ping6 2606:4700:4700::1111
PING 2606:4700:4700::1111 (2606:4700:4700::1111): 56 data bytes
64 bytes from 2606:4700:4700::1111: icmp_seq=0 hlim=54 time=358.017 ms
64 bytes from 2606:4700:4700::1111: icmp_seq=1 hlim=54 time=310.608 ms

You can also check with ifconfig:

# ifconfig if0
if0: flags=848843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,AUTOCONF6TEMP,AUTOCONF4> mtu 1500
	lladdr 00:12:34:56:78:01
	index 5 priority 4 llprio 3
	groups: wlan egress
	media: IEEE802.11 autoselect (HT-MCS4 mode 11n)
	status: active
	ieee80211: nwid MYWIFI chan 1 bssid aa:bb:cc:dd:ee:01 -61dBm wpakey wpaprotos wpa2 wpaakms psk wpaciphers ccmp wpagroupcipher ccmp
	inet 192.168.1.30 netmask 0xffffff00 broadcast 192.168.1.255
	inet6 fe80::212:7bff:fe20:5407%if0 prefixlen 64 scopeid 0x5
	inet6 2607:fb90:bd8d:d8e3:38bc:158b:ab34:c42 prefixlen 64 autoconf temporary pltime 68721 vltime 86297

Status should indicate active, and you should have IP addresses assigned.

To make these changes permanent, write to hostname.if(5):

# cat /etc/hostname.if0
nwid MYWIFI wpakey MYWPAKEY
inet autoconf
inet6 autoconf