Commands / Logging in to the network

Logging in to the network

hostapd

Also access point, ap, wpa2, wpa3, sae, beacon, 802.11w, pmf

Turns a Wi-Fi radio into an access point: beacons an SSID and runs WPA2-PSK, WPA3-SAE or Enterprise.

hostapd makes a radio an access point. Its config file names the interface, the ssid, the channel and the security: wpa=2 with wpa_key_mgmt=WPA-PSK and a wpa_passphrase for WPA2-PSK, or wpa_key_mgmt=SAE with an sae_password and ieee80211w=2 for WPA3 (which requires 802.11w protected management frames); leaving the WPA lines out makes an open network. Started with -B it runs in the background and the radio leaves scanning to beacon the SSID, which iw dev wlan0 info then shows as type AP. The radio's hardware address is the BSSID clients lock onto, so pinning it with ip link set wlan0 address before starting gives the AP a known BSSID.

hostapd command usage

hostapd -B [-f LOGFILE] CONFIG

Options

-B
run in the background as a daemon
-f /var/log/hostapd.log
write the log to a file
CONFIG
the config file: interface, ssid, channel and the WPA settings

hostapd examples

hostapd -B -f /var/log/hostapd.log /etc/hostapd.conf
Starts the access point in the background with the given config.
hostapd -B /etc/hostapd.conf
Starts the access point, logging to the console.

Pitfalls

  • Most config changes take effect only when hostapd starts again, and stopping it sends every client away: each one picks an AP again, the same one or another.
  • WPA3 (wpa_key_mgmt=SAE) needs ieee80211w=2, or the association is refused.

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start learning