davesteele / comitup

Bootstrap Wifi support over Wifi
https://davesteele.github.io/comitup/
GNU General Public License v2.0
320 stars 54 forks source link

How to debug missing DHCP IP? #113

Closed marcelstoer closed 4 years ago

marcelstoer commented 4 years ago

While testing tonight I noticed on a few occasions that client devices didn't get a DHCP IP from the Pi when it was in AP mode. The client (MacBook & iPhone) joined the WiFi AP comitup-nn just fine but didn't get an IP.

Once I manually set the IP to 10.41.0.2 plus subnet mask plus router IP 10.41.0.1 the comitup-web interface was accessible.

I checked the FAQ, the troubleshooting guide and the issues list but didn't find any hints. What could be the root cause and how could I debug this?

davesteele commented 4 years ago

DHCP is provided by dnsmasq, which is configured by the conf/dns-*.conf files, and controlled by cdns.py. The most likely cause is that there is a competing DHCP service on the address/DHCP port for the AP.

sudo netstat -elnp | grep 67

If true, there will be errors visible in the systemd log for comitup.

Cwmwd24 commented 4 years ago

I was having similar problems with comitup in router mode not handing out IP addresses on the hotspot so could not connect.

Nothing obvious in the system logs but systemctl status comitup had errors like these:

Jun 04 22:48:40 raspberrypi comitup[1503]: dnsmasq: failed to create listening socket for port 53: Address already in use
Jun 04 22:48:40 raspberrypi dnsmasq[1586]: failed to create listening socket for port 53: Address already in use
Jun 04 22:48:40 raspberrypi dnsmasq[1586]: FAILED to start up
Jun 04 22:48:40 raspberrypi comitup[1503]: dnsmasq: failed to create listening socket for port 53: Address already in use
Jun 04 22:48:40 raspberrypi comitup[1503]: dnsmasq: failed to create listening socket for port 53: Address already in use

Eventually fixed this by saying sudo systemctl disable dnsmasq and restarting comitup. I'd also tried systemctl disable dhcpcd in the process of trying to resolve the problem but I'm not sure if it's relevant.

I'm using "image_2020-04-05-Comitup-lite" on a Raspberry Pi 3 Model A+ with a USB WiFi dongle for the station.

marcelstoer commented 4 years ago

I installed the comitup package to a recent (~3w old) Raspian on a Pi 4. Here's the output I get after restart when the device is in client mode:

pi@pink-panter:~ $ systemctl status comitup
● comitup.service - Comitup Wifi Management
   Loaded: loaded (/lib/systemd/system/comitup.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2020-06-04 17:57:40 CEST; 13h ago
     Docs: man:comitup(8)
 Main PID: 498 (comitup)
    Tasks: 1 (limit: 4035)
   Memory: 25.1M
   CGroup: /system.slice/comitup.service
           └─498 /usr/bin/python3 /usr/sbin/comitup

Jun 04 17:57:41 pink-panter dnsmasq[584]: FAILED to start up
Jun 04 17:57:41 pink-panter dnsmasq[589]: started, version 2.80 cachesize 150
Jun 04 17:57:41 pink-panter dnsmasq[589]: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth DNSSEC loop-detect 
Jun 04 17:57:41 pink-panter dnsmasq-dhcp[589]: DHCP, IP range 10.41.0.100 -- 10.41.0.150, lease time 10m
Jun 04 17:57:41 pink-panter dnsmasq[589]: reading /etc/resolv.conf
Jun 04 17:57:41 pink-panter dnsmasq[589]: ignoring nameserver 127.0.0.1 - local interface
Jun 04 17:57:41 pink-panter dnsmasq[589]: read /etc/hosts - 5 addresses
Jun 04 17:57:47 pink-panter dnsmasq[589]: exiting on receipt of SIGTERM
Jun 04 17:57:47 pink-panter comitup[498]: OK
Jun 04 17:57:47 pink-panter comitup[498]: OK

pi@pink-panter:~ $ sudo netstat -elnp | grep 67
udp        0      0 0.0.0.0:68              0.0.0.0:*                           0          14276      674/dhclient        
raw6       0      0 :::58                   :::*                    7           0          13967      861/dhcpcd          
unix  2      [ ACC ]     STREAM     LISTENING     13167    861/dhcpcd           /var/run/dhcpcd.unpriv.sock
pi@pink-panter:~ $ sudo netstat -tulpen
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode      PID/Program name    
tcp        0      0 0.0.0.0:53              0.0.0.0:*               LISTEN      0          17258      885/dnsmasq         
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      0          19521      900/sshd            
tcp6       0      0 :::139                  :::*                    LISTEN      0          18142      1184/docker-proxy   
tcp6       0      0 :::53                   :::*                    LISTEN      0          17260      885/dnsmasq         
tcp6       0      0 :::22                   :::*                    LISTEN      0          19523      900/sshd            
tcp6       0      0 :::445                  :::*                    LISTEN      0          19033      1169/docker-proxy   
udp        0      0 0.0.0.0:53              0.0.0.0:*                           0          17257      885/dnsmasq         
udp        0      0 0.0.0.0:68              0.0.0.0:*                           0          14276      674/dhclient        
udp        0      0 0.0.0.0:68              0.0.0.0:*                           0          14041      861/dhcpcd          
udp        0      0 0.0.0.0:44680           0.0.0.0:*                           108        13238      378/avahi-daemon: r 
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           108        13236      378/avahi-daemon: r 
udp6       0      0 :::53                   :::*                                0          17259      885/dnsmasq         
udp6       0      0 :::60488                :::*                                108        13239      378/avahi-daemon: r 
udp6       0      0 :::5353                 :::*                                108        13237      378/avahi-daemon: r
pi@pink-panter:~ $ systemctl status systemd-resolved
● systemd-resolved.service - Network Name Resolution
   Loaded: loaded (/lib/systemd/system/systemd-resolved.service; disabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/systemd-resolved.service.d
           └─resolvconf.conf
   Active: inactive (dead)
     Docs: man:systemd-resolved.service(8)
           https://www.freedesktop.org/wiki/Software/systemd/resolved
           https://www.freedesktop.org/wiki/Software/systemd/writing-network-configuration-managers
           https://www.freedesktop.org/wiki/Software/systemd/writing-resolver-clients 
muelli commented 4 years ago

just guessing: Is systemd-resolved running? Cf. https://github.com/davesteele/comitup/issues/51

marcelstoer commented 4 years ago

Good point; I added the sudo netstat -tulpen output to the above comment.

davesteele commented 4 years ago

I've made new images, with the dnsmasq service masked (one step past disabled). Does this help?

marcelstoer commented 4 years ago
pi@pink-panter:~ $  sudo apt-get install comitup
Reading package lists... Done
Building dependency tree       
Reading state information... Done
comitup is already the newest version (1.10-1).

Which is in line with what I see here https://davesteele.github.io/comitup/archive.html and here https://github.com/davesteele/comitup/tree/gh-pages/deb

davesteele commented 4 years ago

New disk images.

marcelstoer commented 4 years ago

Sorry, got it. Still getting familiar with the project and the Pi world.

I masked it manually and rebooted the Pi. Then I cleared the comitup/NetworkManager connection. Connecting to the WiFi and getting an IP worked reliably. I tested this a couple of times.

davesteele commented 4 years ago

I've added detail to the Wiki install page, and also modified the disk image to address this issue. Closing pending additional input.

marcelstoer commented 4 years ago

Thanks