Hostapd with DHCP

Hello, I’m trying to create an AP with hostapd, but with no success, maybe because DHCP configuration.
Does anyone know how to configure this correctly?

Thanks in advance.

Hello Luiz,
I would try it static if you suspect DHCP to be the problem.
You can set it in the /etc/network/interfaces.
Regards

1 Like

It worked, with static IP, thanks for the reply, after that I used dnsmasq to set DHCP instead of ISP-DHCP and worked too.

1. Create a dedicated interface ap0 for AP mode (optional, you can use wlan0):

iw dev wlan0 interface add ap0 type __ap

Prevent NetworkManager to take care of the interface (/etc/NetworkManager/conf.d/ignore-ap0.conf):

[keyfile]
unmanaged-devices=interface-name:ap0

2. Configure systemd to auto set IP of ap0 interface:

create /systemd/network/42-ap0.network with the following content:

[Match]
Name=ap0

[Network]
Address=192.168.42.1/24

3. Create DHCP configuration for clients

create dnsmasq.d/dnsmasq-mydhcp.conf

listen-address=::1,127.0.0.1,192.168.42.1
domain-needed
bogus-priv
filterwin2k
localise-queries
local=/lan/
expand-hosts
no-negcache
resolv-file=/tmp/resolv.conf.auto
dhcp-authoritative
dhcp-leasefile=/tmp/dhcp.leases
read-ethers
# Plage DHCP
dhcp-range=192.168.42.100,192.168.42.150,12h
# Netmask
dhcp-option=1,255.255.255.0
# Route
dhcp-option=3,192.168.42.1

then restart dnsmasq

systemctl restart dnsmasq
  1. Create hostapd configuration (Wifi AP mode)

Create /etc/hostapd.conf with the following content:

interface=ap0
driver=nl80211
ssid=dragonAP
hw_mode=g
ieee80211n=1
ht_capab=[DSSS_CCK-40][SHORT-GI-20]
channel=1
  1. stop ‘client’ interface

    ifconfig wlan0 down

  2. Run hostapd:

    ifconfig ap0 up
    hostapd hostapd.conf

1 Like