Wi-Fi SetupMost home and public Wi-Fi networks use DHCP for IP addressing and WPA-Personal for authentication. On MidnightBSD, a physical wireless device, such as iwlwifi0 or urtwn0, is used to create a client interface such as wlan0. The client interface is then authenticated by wpa_supplicant and receives an address through DHCP.
You need the network name (SSID) and its password. Perform initial configuration from a local console when possible: restarting network services can disconnect an SSH session.
List wireless devices known to the kernel:
sysctl net.wlan.devices
ifconfig -l
The result of net.wlan.devices is the physical device name. For example, if it reports iwlwifi0, use that name in the configuration below. To identify PCI hardware and look for driver or firmware messages, use:
pciconf -lv | grep -A1 -B3 network
dmesg | grep -i -E 'wifi|wlan|firmware'
If the adapter is unsupported or fails to attach, consult the MidnightBSD Wi-Fi hardware wiki and the manual page for the detected driver.
Create or edit /etc/wpa_supplicant.conf as root. The file contains credentials, so it must not be readable by other users:
doas ee /etc/wpa_supplicant.conf
doas chmod 600 /etc/wpa_supplicant.conf
Add a network block, replacing the example values with your SSID and password:
network={
ssid="ExampleNetwork"
psk="correct horse battery staple"
}
For a hidden network, add scan_ssid=1 inside that network block. wpa_passphrase "ExampleNetwork" "correct horse battery staple" can generate a hashed PSK block; review its output before adding it to the configuration file.
Next, configure the physical device to create wlan0 and configure that interface at boot. Substitute the physical device name shown by sysctl net.wlan.devices:
doas sysrc wlans_iwlwifi0="wlan0"
doas sysrc ifconfig_wlan0="WPA SYNCDHCP"
WPA starts wpa_supplicant; SYNCDHCP waits for DHCP to complete while the interface is configured. The settings are stored in /etc/rc.conf. If an installer or previous setup has already created Wi-Fi entries there, update them rather than adding conflicting ones.
To create the client interface immediately, without waiting for a reboot:
doas ifconfig wlan0 create wlandev iwlwifi0
Replace iwlwifi0 with your physical device. Scan for nearby access points:
doas ifconfig wlan0 up list scan
Apply the persistent configuration:
doas service netif restart
Confirm association and addressing, then test both IP connectivity and DNS:
ifconfig wlan0
ping -c 2 1.1.1.1
ping -c 2 midnightbsd.org
If the first ping succeeds but the second fails, the Wi-Fi link is working and the problem is DNS. See the DNS configuration guide.
Wireless channel availability depends on the country. Check the current settings and available country codes:
ifconfig wlan0 list regdomain
ifconfig wlan0 list countries
Set the country and regulatory domain appropriate for your location. For example, the following is an Austria/ETSI example only:
doas ifconfig wlan0 country AT regdomain ETSI2
doas sysrc create_args_wlan0="country AT regdomain ETSI2"
The second command preserves the setting in /etc/rc.conf. Check /etc/regdomain.xml and ifconfig(8) for the values applicable to your country and hardware. Do not use the example values outside their applicable region.
For an open network, connect temporarily by selecting its SSID and requesting DHCP:
doas ifconfig wlan0 ssid "NetworkName"
doas dhclient wlan0
Open networks do not protect traffic; use HTTPS and avoid sensitive activity unless you trust the network. Hotel and café networks may also require a browser-based captive-portal login after DHCP succeeds.
Enterprise Wi-Fi uses organization-specific 802.1X/EAP credentials and certificates. Do not copy a WPA-Personal block for these networks; obtain the required settings from the network administrator and use wpa_supplicant.conf(5) as the configuration reference.
pciconf -lv and dmesg to identify the adapter and any firmware failure. Verify that its driver is supported before changing configuration files.wlan0 does not exist: check the physical device name, create the interface with ifconfig wlan0 create wlandev <device>, and verify the matching wlans_<device> entry in /etc/rc.conf.doas service wpa_supplicant status wlan0 and wpa_cli -i wlan0 status for status.ifconfig wlan0, test an IP address with ping, then check DNS and any captive portal.