OPNsense Forum

English Forums => General Discussion => Topic started by: verfluchten on May 11, 2025, 11:48:58 PM

Title: Hardening DHCP
Post by: verfluchten on May 11, 2025, 11:48:58 PM
Is my understanding of https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol correct that the 'from' IPv4 address of the initial discovery and the first DHCP request from a DHCP client are always 0.0.0.0 and always from port 68/udp?

Next, I want to allow DHCP only from select MAC addresses, and they will include visitor devices. How can I discover MAC addresses to be manually allowed if they are not printed on the device or supplied by the visitor? Only by looking at the log for DHCPREQUEST ... from ... when the device is plugged in?
Title: Re: Hardening DHCP
Post by: bartjsmit on May 12, 2025, 09:04:03 AM
Yes, DHCP uses broadcast. Restricting clients by MAC has limited value since you cannot control the address that the client uses. For instance, an attacker can sniff packets on the network and assume the MAC and IP of a client that is allowed to connect.

Do your hardening on layer 2 by implementing VLAN separation on managed switches and multi-SSID WiFi access points.
Title: Re: Hardening DHCP
Post by: verfluchten on May 12, 2025, 02:23:14 PM
Not really looking for design suggestions ATM, only for the answers to the original questions.
Title: Re: Hardening DHCP
Post by: bartjsmit on May 12, 2025, 06:29:48 PM
Capture the DHCP traffic on the firewall while bringing the device on the network.
Title: Re: Hardening DHCP
Post by: EricPerl on May 13, 2025, 06:28:20 AM
The initial DHCPDISCOVER message from the client includes its MAC address. It goes in the log at Info level.
If you block unknown clients, there won't be a reply...

FWIW, newer Apple products have a privacy feature that randomizes the MAC.
Title: Re: Hardening DHCP
Post by: verfluchten on May 13, 2025, 10:20:52 PM
Do they always originate from ip 0.0.0.0 and port 68/udp?
Title: Re: Hardening DHCP
Post by: EricPerl on May 13, 2025, 10:46:37 PM
Yes, according to https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol (https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol)
The client does not have an IP yet. UDP Port is 67 on the server side, 68 client side. The auto-generated rules include these for a reason...