Connecting to Wi-Fi networks
Connection to Wi-Fi networks on OpenBSD.
Me
304 Words 1 Minute, 22 Seconds
21 Sep 2025
Wi-Fi configuration
To connect to and remember Wi-Fi networks on OpenBSD, a simple configuration is needed.
Tested on OpenBSD 7.4.
Identifying the network interface
The configuration has to be done for the right network interface. The naming convention of the network interfaces is different from Linux, and it depends on the driver. The following command should identify the wireless network interface:
$ dmesg | egrep -i '(wireless)|(^(acx|an|athn?|atu|atw|bwfm|bwi|ipw|iwim?|iwn|iwx|malo|mtw|otus|pgt|qww|ral|rsu|rtwn?|rum|run|uath|upgt|ural|urtwn?|wi|wpi|zyd)\d+( |:))'
The output could be similar to this:
iwm0 at pci2 dev 0 function 0 "Intel Dual Band Wireless-AC 1234" rev 0x42
Here, iwm0 is the network interface name. It should be confirmed by ifconfig iwm0.
Adding the network to the configuration file
To connect to a Wi-Fi network, the network interface has to be configured.
Edit the file /etc/hostname.if, .if being replaced by the name of the network interface. Example: /etc/hostname.iwm0
join 'home' wpakey 'your-Random-P4ssw0rd!-Her3.' join 'work' wpakey 'your-otHer--Pa55w0rd!-Her3' join 'Moe-tavern' wpakey 'M4rge_51mp5on-<3' join 'Old-Unsafe-AP' wpaprotos wpa1,wpa2 wpakey 'passw0rd' inet autoconf
The join instruction is better than nwid, since it allows to connect to one of several networks.
The inet autoconf is to use DHCP to get an IPv4 address, inet6 autoconf for IPv6. It must be the last line of the file.
Note: the single quotes around the network name and the network password aren't mandatory, except if you have a special characters like $ or <space> inside. So, it's better to always use them.
WPA1 is disabled by default because it's considered unsafe. It is recommended not to login an access point not supporting WPA2 or later, but if you really need to do it, use wpaprotos to enable WPA1.
Finally, restart the network service with the following command:
# sh /etc/netstart