Score:1

dnsmasq DHCP server not responding

in flag

I have connected a HikVision camera to a raspberry pi through two ethernet power line adapters TP-Link TL-PA4010.

I have configured the eth0 interface of the raspberry to have a static ip address. In /etc/dhcpcd.conf:

interface eth0
static ip_address=192.168.0.10/24

I have configured a DHCP server using dnsmasq, with the following configuration:

# Disable DNS
port=0

# Configuring the DHCP server
interface=eth0
dhcp-leasefile=/var/lib/misc/dnsmasq.leases
# The MAC address of the IP camera
dhcp-host=xx:xx:xx:xx:xx:xx,192.168.0.11
# I've added this later, didn't do anything
dhcp-authoritative

# Some logging
log-dhcp
log-queries
log-facility=/var/log/dnsmasq.log

This setup worked briefly and I could get images from it. But now the camera will not connect: cannot get an IP. It connects correctly to my home network and I can load the camera's web page. Tried to reset the camera to the factory default and reconfiguring it for DHCP but no luck.

Tried to capture packet going through eth0 using tcmdump and I see some trafic from the camera, something relative to router solicitation and a bunch of other stuff but I also see:

17:46:36.725552 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from xx:xx:xx:xx:xx:xx (oui Unknown), length 284
17:46:39.726180 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from xx:xx:xx:xx:xx:xx (oui Unknown), length 284
17:46:42.727918 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from xx:xx:xx:xx:xx:xx (oui Unknown), length 284

I have filtered the logs with dhcpdump and that's all I see, among the other traffic on eth0 these are the only DHCP related.

But no answer from dnsmasq. Nothing in dnsmasq's logs:

Apr 29 17:33:57 dnsmasq[590]: started, version 2.85 DNS disabled
Apr 29 17:33:57 dnsmasq[590]: compile time options: IPv6 GNU-getopt DBus no-UBus i18n IDN2 DHCP DHCPv6 no-Lua TFTP conntrack ipset auth cryptohash DNSSEC loop-detect inotify dumpfile

I have removed the lease file (/var/lib/dhcp/dhclient.leases) which initially contained an entry from my previous successful attempt following something I read on the net.

The service is running correctly:

● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
     Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2023-04-29 17:33:57 CEST; 15min ago
    Process: 538 ExecStartPre=/etc/init.d/dnsmasq checkconfig (code=exited, status=0/SUCCESS)
    Process: 570 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=0/SUCCESS)
    Process: 594 ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf (code=exited, status=0/SUCCESS)
   Main PID: 590 (dnsmasq)
      Tasks: 1 (limit: 779)
        CPU: 435ms
     CGroup: /system.slice/dnsmasq.service
             └─590 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsmasq -r /run/dnsmasq/resolv.conf -7 /etc/dnsmasq.d,.dpkg-dist,.dpkg-old,.dpkg-new --local-service --trust-anchor=.,20326,8,2,e06d44b80b8f1d3>

Apr 29 17:33:55 raspberrypi systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
Apr 29 17:33:57 raspberrypi systemd[1]: Started dnsmasq - A lightweight DHCP and caching DNS server.

I think the problem comes from the raspberry from the fact that:

  1. we see traffic so the PL adapters are working
  2. the camera can get an IP from the my internet gateway's DHCP server

The raspberry runs a raspbian (Debian GNU/Linux 11 (bullseye)) which is pretty standard. There is no firewall (at least as far as I know).

pi@raspberrypi:~ $ sudo systemctl stop firewall
Failed to stop firewall.service: Unit firewall.service not loaded.

I've come to my wit's end here. Any idea of what could be the problem? What I could investigate further?

Score:0
by flag

Your dnsmasq configuration is not providing the DHCP service properly, just specify the DHCP range and other options in the dnsmasq configuration file, for example:

port=0

interface=eth0
dhcp-range=192.168.0.11,192.168.0.20,255.255.255.0,1h
dhcp-option=3,192.168.0.10 # Gateway
dhcp-option=6,8.8.8.8,8.8.4.4 # DNS servers
dhcp-leasefile=/var/lib/misc/dnsmasq.leases
dhcp-authoritative

log-dhcp
log-queries
log-facility=/var/log/dnsmasq.log

We restart and it should work sudo systemctl restart dnsmasq

If there is still a problem check if another DHCP server running on your Raspberry Pi sudo systemctl list-units --type=service | grep -i dhcp and disable it.

Luke Skywalker avatar
in flag
Thanks for your help @saxtheowl. I actually only needed the `dhcp-range` line and I also kept the `dhcp-host` line as I want the camera to always have the same IP address. I don't understand why the range is needed though as I force an IP to the MAC address anyway. If you modify your answer to to remove the Gateway and DNS server line and keep the host line, I'll accept you answer.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.