hostapd - bunnyamin/bunnix GitHub Wiki

Requirements

The wireless network device must support operation mode AP:

$ iw list
Wiphy phy0
...
        Supported interface modes:
                 * IBSS
                 * managed
                 * AP
                 * AP/VLAN
                 * monitor
                 * mesh point
                 * P2P-client
                 * P2P-GO
                 * outside context of a BSS
...

To use the wireless device both as a client and AP at the same time, the network device must support a valid interface combination. For example:

        # 2048 "managed" (clients)?, eight AP, one type of P2P, together total 2048 on one [the same] channel.
        valid interface combinations:
                 * #{ managed } <= 2048, #{ AP, mesh point } <= 8, #{ P2P-client, P2P-GO } <= 1,
                   total <= 2048, #channels <= 1, STA/AP BI must match

        # One "managed" (client), one AP, together total 2 on one [the same] channel.
        valid interface combinations:
                 * #{ managed } <= 1, #{ AP } <= 1, total <= 2, #channels <= 1

According to the Arch Linux Wiki Software access point:

  • "The constraint #channels <= 1 means that your software AP must operate on the same channel as your Wi-Fi client connection; see the channel setting in hostapd.conf below."
  • Two separate virtual interfaces are necessary.

Regarding the requirement of two separate virtual interfaces. For the current setup only one virtual interface was necessary. The one for the AP. The interface to the physical device could still be used for accessing the Internet.

Configuration

Remember number of "stations" allowed. Any additional device attempting to connect is going to fail and it may not report that the reason is no available stations.

Regulatory domain

iw reg get
global
country SE: DFS-ETSI
        (2400 - 2483 @ 40), (N/A, 20), (N/A)
        (5150 - 5250 @ 80), (N/A, 23), (N/A), NO-OUTDOOR, AUTO-BW
        (5250 - 5350 @ 80), (N/A, 20), (0 ms), NO-OUTDOOR, DFS, AUTO-BW
        (5470 - 5725 @ 160), (N/A, 26), (0 ms), DFS
        (5725 - 5875 @ 80), (N/A, 13), (N/A)
        (5945 - 6425 @ 160), (N/A, 23), (N/A), NO-OUTDOOR
        (57000 - 66000 @ 2160), (N/A, 40), (N/A)
iw list
                Frequencies:
                        * 5180.0 MHz [36] (23.0 dBm)
                        * 5200.0 MHz [40] (23.0 dBm)
                        * 5220.0 MHz [44] (23.0 dBm)
                        * 5240.0 MHz [48] (23.0 dBm)
                        * 5260.0 MHz [52] (20.0 dBm) (radar detection)
                        * 5280.0 MHz [56] (20.0 dBm) (radar detection)
                        * 5300.0 MHz [60] (20.0 dBm) (radar detection)
                        * 5320.0 MHz [64] (20.0 dBm) (radar detection)
                        * 5500.0 MHz [100] (26.0 dBm) (radar detection)
                        * 5520.0 MHz [104] (26.0 dBm) (radar detection)
                        * 5540.0 MHz [108] (26.0 dBm) (radar detection)
                        * 5560.0 MHz [112] (26.0 dBm) (radar detection)
                        * 5580.0 MHz [116] (26.0 dBm) (radar detection)
                        * 5600.0 MHz [120] (26.0 dBm) (radar detection)
                        * 5620.0 MHz [124] (26.0 dBm) (radar detection)
                        * 5640.0 MHz [128] (26.0 dBm) (radar detection)
                        * 5660.0 MHz [132] (26.0 dBm) (radar detection)
                        * 5680.0 MHz [136] (26.0 dBm) (radar detection)
                        * 5700.0 MHz [140] (26.0 dBm) (radar detection)
                        * 5720.0 MHz [144] (13.0 dBm) (radar detection)
                        * 5745.0 MHz [149] (13.0 dBm)
                        * 5765.0 MHz [153] (13.0 dBm)
                        * 5785.0 MHz [157] (13.0 dBm)
                        * 5805.0 MHz [161] (13.0 dBm)
                        * 5825.0 MHz [165] (13.0 dBm)
...

Microsoft Windows compatibility

# Disable EAP - Fix for Windows 10
ieee8021x=0
eap_server=0

systemd-networkd

  1. List available physical devices.
    • iw phy or iw list
  2. Create a virtual network interface for the AP from the physical device.
  3. Create a network interface for the AP: /etc/systemd/network/30-ap.network
    • The UseDNS=true takes DNS from the DHCP server.
  4. Create the configuration for HostAP: /etc/hostapd/hostapd.conf
    • Notice that bridge is disabled; using NAT.
    • Notice that channel is set to 0. It activates ACS (Automatic Channel Selection). It requires that ACS was enabled during compilation otherwise the channel 0 cannot be found. An incorrect channel prevents initializing of service.
  5. Ensure that the /usr/lib/systemd/system/hostapd.service starts after network-online.target:
    • systemctl enable --now hostapd

Debug

Start hostapd with all debug messages (-dd). If the program cannot start then it exists after failure otherwise if the program starts successfully then stop it with Ctrl+C.

  • hostapd -dd /etc/hostapd/hostapd.conf

Information about the device:

  • iw <INTERFACE> info

Information about connected stations:

  • hostapd_cli all_sta
  • arp -a -n <MAC> to retrieve hostname

Error, problem, troubleshooting

Event Error Cause Remedy
hostapd ACS was disabled on your build, rebuild hostapd with CONFIG_ACS=y or set channel Manually set a channel.
hostapd <INTERFACE>: IEEE 802.11 Configured channel (0) not found from the channel list of current mode (2) IEEE 802.11a Select a channel from the mode=2 selection.
hostapd_cli Could not connect to hostapd - re-trying Cannot find the Unix domain socket to connect to HostapD. Define the variable ctrl_interface=/var/run/hostapd in hostapd.conf.
Connecting to the Host AP SME: Authentication request to the driver failed The connecting computer had its own HOST AP running. After disabling it the error disappeared and a connection was established.
Waiting for connections hostapd[511]: handle_probe_req: send failed
Connected to AP No Internet access The problem may be that no DHCP server is not assigned or the firewall is blocking connections If DHCP and firewall are correctly configured, the problem can resolve by itself. For example, wait a couple of hours and, or restart server, computer a couple of times.

Errors related to invalid channel selection

If the channel selection is invalid or cannot be determined then the hostapd is deactivated with error. For example:

...
wlv1ap: ACS-STARTED
ACS: Unable to collect survey data
ACS: All study options have failed
Interface initialization failed
wlv1ap: interface state ACS->DISABLED
wlv1ap: AP-DISABLED
ACS: Possibly channel configuration is invalid, please report this along with your config file.
ACS: Failed to start
wlv1ap: AP-DISABLED
hostapd_free_hapd_data: Interface wlv1ap wasn't started
nl80211: deinit ifname=wlv1ap disabled_11b_rates=0
wlv1ap: interface state DISABLED->DISABLED
wlv1ap: interface state DISABLED->DISABLED
wlv1ap: AP-DISABLED
wlv1ap: CTRL-EVENT-TERMINATING
hostapd_free_hapd_data: Interface wlv1ap wasn't started
hostapd.service: Deactivated successfully.
⚠️ **GitHub.com Fallback** ⚠️