2

I'm trying to host a DNS and DHCP service with dnsmasq. Here is my dnsmasq.conf

# DHCP
dhcp-authoritative
bind-interfaces

dhcp-range=192.168.122.2,192.168.122.99,12h
dhcp-leasefile=/var/lib/dnsmasq/dnsmasq.leases

dhcp-host=0a:0a:0a:0a:0a:01,192.168.122.100  # node.local

# DNS
no-hosts # ignore etc hosts
address=/node.local/192.168.122.100
ptr-record=100.122.168.192.in-addr.arpa.,"node.local"

When I do look at the ports being listened with: sudo ss -tulpn | grep LISTEN I only see the :53, DNS port being listened to. Port 67 is not being listened on, so it doesn't seem like the DHCP service is running.

Is the DHCP running? and If so, will clients be able to get IP addresses if I'm only listening on port 53, and not the default DHCP port?

0

1 Answer 1

1

An IPv4 DHCP server will need to be able to send & receive broadcast packets addressed to destination 255.255.255.255, which requires (as far as I know) the use of a raw socket.

See ss -A raw -lpn to find the DHCP server's raw socket. Since it works at the level of raw IP protocol, the socket won't be specific to port 67: the DHCP server will have to build the UDP headers on its own on outgoing packets, including putting in the port number.

For incoming packets, if it was listening for UDP port 67 in the normal way, the kernel would discard some packets the DHCP server wants to receive as "misconfigured" - precisely because the DHCP client might not have a valid network configuration yet! Or the client might be unaware that it has been plugged into a different network while powered off, and might start trying to validate its old DHCP lease using network parameters that are incorrect for the new network - ideally the DHCP server needs to be able to hear this and send a DHCP NAK to such a client to tell it to forget the old address and start the DHCP process over.

So, the DHCP server needs to listen for incoming UDP packets using a raw socket, to also accept some incoming packets the normal network driver stack would reject. Because of this, ss -tulpn | grep LISTEN won't show such a socket. In effect, the kernel does not really know what the DHCP server is listening for, as using a raw socket is equivalent to telling the kernel "give me a copy of any incoming IP packets, I'll search myself for the specific things that interest me."

2
  • Thanks for your response. So if I understood correctly, the server doesn't need to be listening on port 67 to function normally as a dhcp server?
    – qMo
    Commented Sep 25, 2022 at 17:50
  • 1
    See my edit above. In short, the DHCP server is listening for traffic addressed to UDP port 67, but in a way that is not visible to ss -tulpn | grep LISTEN.
    – telcoM
    Commented Sep 25, 2022 at 18:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .