edbird
Posts: 50
Joined: Wed Jun 25, 2014 1:11 pm

Debug wifi access point setup - hostapd + isc-dhcp-server

Tue May 26, 2020 8:01 pm

How can I debug my wireless AP configuation.

I have set up isc-dhcp-server and hostapd. The dhcp server assigns ip addresses on interface eth0 but does not seem to be working on wlan0.

I'm not sure where to start debugging this, so I will just post my config files.

Code: Select all

$ cat /etc/hostapd/hostapd.conf 
country_code=GB
interface=wlan0
ssid=wirelessnet
hw_mode=a
channel=40
#wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=password
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

Code: Select all

$ cat /etc/wpa_supplicant/wpa_supplicant.conf 
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB

Code: Select all

$ sudo systemctl status hostapd.service
● hostapd.service - Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticator
   Loaded: loaded (/lib/systemd/system/hostapd.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2020-05-26 20:53:34 BST; 6min ago
  Process: 540 ExecStart=/usr/sbin/hostapd -B -P /run/hostapd.pid -B $DAEMON_OPTS ${DAEMON_CONF} (code=exited, status=0/SUCCESS)
 Main PID: 552 (hostapd)
    Tasks: 1 (limit: 4915)
   Memory: 2.2M
   CGroup: /system.slice/hostapd.service
           └─552 /usr/sbin/hostapd -B -P /run/hostapd.pid -B /etc/hostapd/hostapd.conf

May 26 20:55:53 pi-grey hostapd[552]: wlan0: STA b4:9d:0b:72:ca:7d IEEE 802.11: associated
May 26 20:55:53 pi-grey hostapd[552]: wlan0: STA b4:9d:0b:72:ca:7d RADIUS: starting accounting session 8E902A8E557A6DB0
May 26 20:55:53 pi-grey hostapd[552]: wlan0: STA b4:9d:0b:72:ca:7d WPA: pairwise key handshake completed (RSN)
May 26 20:56:29 pi-grey hostapd[552]: wlan0: STA b4:9d:0b:72:ca:7d IEEE 802.11: disassociated
May 26 20:56:29 pi-grey hostapd[552]: wlan0: STA b4:9d:0b:72:ca:7d IEEE 802.11: disassociated
May 26 20:56:32 pi-grey hostapd[552]: wlan0: STA b4:9d:0b:72:ca:7d IEEE 802.11: associated
May 26 20:56:33 pi-grey hostapd[552]: wlan0: STA b4:9d:0b:72:ca:7d RADIUS: starting accounting session 161FBC769C59D5EC
May 26 20:56:33 pi-grey hostapd[552]: wlan0: STA b4:9d:0b:72:ca:7d WPA: pairwise key handshake completed (RSN)
May 26 20:57:09 pi-grey hostapd[552]: wlan0: STA b4:9d:0b:72:ca:7d IEEE 802.11: disassociated
May 26 20:57:09 pi-grey hostapd[552]: wlan0: STA b4:9d:0b:72:ca:7d IEEE 802.11: disassociated

Code: Select all

$ cat /etc/dhcpcd.conf 
# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.
hostname

# Use the hardware address of the interface for the Client ID.
clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.
#duid

# Persist interface configuration when dhcpcd exits.
persistent

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu

# Most distributions have NTP support.
#option ntp_servers

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate SLAAC address using the Hardware Address of the interface
#slaac hwaddr
# OR generate Stable Private IPv6 Addresses based from the DUID
slaac private

interface eth1
	static ip_address=192.168.2.254/24
	static domain_name_servers=192.168.2.1

interface wlan0
	static ip_address=192.168.4.254/24
	nohook wpa_supplicant

Code: Select all

3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether dc:a6:32:45:33:2f brd ff:ff:ff:ff:ff:ff
    inet 192.168.4.254/24 brd 192.168.4.255 scope global noprefixroute wlan0
       valid_lft forever preferred_lft forever
    inet6 fe80::b02f:e3dd:b68:5b0b/64 scope link 
       valid_lft forever preferred_lft forever
/etc/dhcp/dhcpd.conf contains these lines (among many others)

Code: Select all

subnet 192.168.4.0 netmask 255.255.255.0 {
	range 192.168.4.10 192.168.4.15;
	option routers 192.168.2.254;
	option broadcast-address 192.168.4.255;
}

Code: Select all

$ dhcp-lease-list 
To get manufacturer names please download http://standards.ieee.org/regauth/oui/oui.txt to /usr/local/etc/oui.txt
Reading leases from /var/lib/dhcp/dhcpd.leases
MAC                IP              hostname       valid until         manufacturer        
===============================================================================================
00:50:b6:68:97:6b  192.168.2.10    debian         2020-05-26 20:07:48 -NA-                


If I try to connect to the AP using my phone it just reports "ip configuration failure".

I'm not sure what other info I should add.

bls
Posts: 729
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA
Contact: Twitter

Re: Debug wifi access point setup - hostapd + isc-dhcp-server

Tue May 26, 2020 9:04 pm

Where is the configuration file for isc-dhcp-server? Should be /etc/dhcp/dhcpd.conf by default.
Pi tools:
Free your network from your router's DHCP/DNS and run it on a Pi:https://github.com/gitbls/ndm
Quickly and easily build customized-just-for-you SD Cards: https://github.com/gitbls/sdm
Easy strongSwan VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

edbird
Posts: 50
Joined: Wed Jun 25, 2014 1:11 pm

Re: Debug wifi access point setup - hostapd + isc-dhcp-server

Tue May 26, 2020 10:30 pm

Yes that's correct. Do you want me to paste the full file?

epoch1970
Posts: 5434
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Debug wifi access point setup - hostapd + isc-dhcp-server

Tue May 26, 2020 10:52 pm

The router is not in the same subnet as the IP range. I assume the server chokes on that.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

edbird
Posts: 50
Joined: Wed Jun 25, 2014 1:11 pm

Re: Debug wifi access point setup - hostapd + isc-dhcp-server

Tue May 26, 2020 11:04 pm

I guess that makes sense.

Although I'm a bit confused.

Let me tell you about my network setup.

I have a Raspberry Pi (obviously - you already knew this I am on the forum!) and it connects to my ISP router via the network

192.168.1.0

The Router has the IP 192.168.1.254, the Pi has eth0 IP 192.168.1.201

Then the Pi has 2 other interfaces, eth1 (a USB to ethernet adapter) and wlan0.

I have managed to get eth1 working. It connects to a switch with a bunch of other machines connected including my workstation and another Pi running Pi Hole, with IP 192.168.2.1

The eth1 network is 192.168.2.0, sorry for the backwards logic there.

Then wlan0 is supposed to be on network 192.168.4.0

I guess I'm confused about what the option "routers" actually means. What should the value be and why?

edbird
Posts: 50
Joined: Wed Jun 25, 2014 1:11 pm

Re: Debug wifi access point setup - hostapd + isc-dhcp-server

Tue May 26, 2020 11:12 pm

Double reply, but in this situation, "routers" has to be "itself", right? Because this Pi is functioning as a router between 3 networks:

192.168.1.X, 192.168.2.X and 192.168.4.X

What should I set the routers option to?

epoch1970
Posts: 5434
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Debug wifi access point setup - hostapd + isc-dhcp-server

Tue May 26, 2020 11:20 pm

A router is also known as a gateway [to other networks]. It sits at the border of the network you’re considering, one interface in it and the other on a neighboring network.

In your subnet definition basically everything that describes a network has to be numbered the same. In other words, define 192.168.2 or .4 but not a mix of both.

(Yes, the Pi itself. Why use isc dhcpd? Dnsmasq is so much easier. )
Last edited by epoch1970 on Fri May 29, 2020 6:37 pm, edited 1 time in total.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

edbird
Posts: 50
Joined: Wed Jun 25, 2014 1:11 pm

Re: Debug wifi access point setup - hostapd + isc-dhcp-server

Fri May 29, 2020 1:29 pm

Right, I guess I am totally confused then. How would I set up a Pi (or any Debian based linux system) as a router between multiple networks? (More than 2)

edbird
Posts: 50
Joined: Wed Jun 25, 2014 1:11 pm

Re: Debug wifi access point setup - hostapd + isc-dhcp-server

Fri May 29, 2020 3:34 pm

Strange - it works with dnsmasq but not with isc-dhcp-server

epoch1970
Posts: 5434
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Debug wifi access point setup - hostapd + isc-dhcp-server

Fri May 29, 2020 6:40 pm

edbird wrote:
Fri May 29, 2020 1:29 pm
Right, I guess I am totally confused then. How would I set up a Pi (or any Debian based linux system) as a router between multiple networks? (More than 2)
Add physical network interfaces via usb3, or simply create VLANs on the built-in ethernet interface and put a manageable switch behind the Pi. VLANs give you over 4000 separate interfaces.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Return to “Networking and servers”