Configure hostapd with separate dhcp_server - Error: unknown configuration item "dhcp_server"
Dan Hayes
dhayes501 at gmail.com
Sat Oct 15 11:04:49 PDT 2022
I've installed AlmaLinux 9.0 on a machine with eth/wifi ports. The
machine connects to my network via ethernet. I want to set the machine
up as an AP for wifi clients within range using hostapd. I've
installed hostapd-2.10-1.el9.x86_64.
I have everything working except DHCP. If I manually configure IP/DNS
on wireless client and then connect to hostapd, the wireless client
works fine. Since I already have a DHCP server on the network and
want to setup multiple linux hostapd servers in different locations, I
want to use a single DHCP instance for all hostapd servers.
If I'm understanding it correctly, the documentation in
/usr/share/doc/hostapd/hostapd.conf seems to support this:
# DHCP server for FILS HLP
# If configured, hostapd will act as a DHCP relay for all FILS HLP requests
# that include a DHCPDISCOVER message and send them to the specific DHCP
# server for processing. hostapd will then wait for a response
from that server
# before replying with (Re)Association Response frame that encapsulates this
# DHCP response. own_ip_addr is used as the local address for the
communication
# with the DHCP server.
#dhcp_server=127.0.0.1
# DHCP server UDP port
# Default: 67
#dhcp_server_port=67
# DHCP relay UDP port on the local device
# Default: 67; 0 means not to bind any specific port
#dhcp_relay_port=67
# DHCP rapid commit proxy
# If set to 1, this enables hostapd to act as a DHCP rapid commit proxy to
# allow the rapid commit options (two message DHCP exchange) to be
used with a
# server that supports only the four message DHCP exchange. This
is disabled by
# default (= 0) and can be enabled by setting this to 1.
#dhcp_rapid_commit_proxy=0
But when I add those lines to the end of my /etc/hostapd/hostapd.conf file
87 dhcp_server=192.168.1.1
88 dhcp_server_port=67
89 dhcp_relay_port=67
90 dhcp_rapid_commit_proxy=0
I get an error:
Oct 13 15:56:58 localhost.localdomain hostapd[33576]: Line 87:
unknown configuration item 'dhcp_server'
Oct 13 15:56:58 localhost.localdomain hostapd[33576]: Line 88:
unknown configuration item 'dhcp_server_port'
Oct 13 15:56:58 localhost.localdomain hostapd[33576]: Line 89:
unknown configuration item 'dhcp_relay_port'
Oct 13 15:56:58 localhost.localdomain hostapd[33576]: Line 90:
unknown configuration item 'dhcp_rapid_commit_proxy'
Oct 13 15:56:58 localhost.localdomain hostapd[33576]: 4 errors
found in configuration file '/etc/hostapd/hostapd.conf'
*Note - the server at 192.168.1.1 is another linux machine running
AlmaLinux 9 and dhcp-server-4.4.2-16.b1.el9.x86_64
For completeness, here is my entire /etc/hostapd/hostapd.conf file
with comments removed:
interface=wlp2s0
bridge=br0
driver=nl80211
logger_stdout=-1
logger_stdout_level=2
ctrl_interface=/var/run/hostapd
ctrl_interface_group=wheel
ssid=MyNetworkName
country_code=US
hw_mode=g
channel=7
max_num_sta=5
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wmm_enabled=1
ieee80211n=1
ht_capab=[HT40+][SHORT-GI-40][TX-STBC][RX-STBC1][DSSS_CCK-40]
own_ip_addr=192.168.1.4
wpa=2
wpa_passphrase=MyWirelessPassword
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
dhcp_server=192.168.1.1
dhcp_server_port=67
dhcp_relay_port=67
dhcp_rapid_commit_proxy=0
>From "Minimal Install" of AlmaLinux 9, my setup scripts looks like this:
dnf -y update
shutdown -r now
dnf -y install epel-release
dnf -y groupinstall "Development Tools"
dnf -y install vim-enhanced mlocate git nmap pv tmux wget unzip
nethogs iftop rsync htop tcpdump net-tools bind-utils iw
dnf -y install hostapd
systemctl enable hostapd.service
nmcli conn add type bridge con-name br0 ifname br0
nmcli conn modify br0 ipv4.addresses '192.168.1.5/24'
nmcli conn modify br0 ipv4.gateway '192.168.1.1'
nmcli conn modify br0 ipv4.dns '192.168.1.1'
nmcli conn modify br0 ipv4.method manual
nmcli conn add type ethernet slave-type bridge con-name bridge-br0
ifname enp1s0 master br0
nmcli conn up br0
cat > /etc/hostapd/hostapd.conf <<EOF
interface=wlp2s0
bridge=br0
driver=nl80211
logger_stdout=-1
logger_stdout_level=2
ctrl_interface=/var/run/hostapd
ctrl_interface_group=wheel
ssid=MyNetworkName
country_code=US
hw_mode=g
channel=7
max_num_sta=5
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wmm_enabled=1
ieee80211n=1
ht_capab=[HT40+][SHORT-GI-40][TX-STBC][RX-STBC1][DSSS_CCK-40]
own_ip_addr=192.168.1.4
wpa=2
wpa_passphrase=MyWirelessPassword
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
EOF
systemctl restart hostapd.service
Do I need to install other packages to get hostapd to recognize the
dhcp_server variable? Do I need to include other variables? I've
googled quite a bit, but I can't find many instances of people setting
up hostapd with a remote dhcp server. And without configuring a DHCP
client on the hostapd server, would it get DHCP information
automatically if I removed a firewall block? Is there maybe an
iptables entry that would open this up for me?
I've read everything I can find searching google, but nothing I've
tried has worked.
More information about the Hostap
mailing list