Iptables – Block DHCP traffic for one device/mac address

dhcpiptablesrouting

I have a network with a central router that runs dd-wrt. Connected to it are several enduser devices. One port however is reserved for a special device that runs a DHCP server. I call it special because I cannot turn DHCP off on it. Actually though, I do want my dd-wrt router to provide DHCP.

How do I setup a rule (I presume it has to be iptables based?) to block any and all DHCP traffic to and from that one device?

Note that I want the device to still be on the same subnet and reachable from all other devices for different services.

Best Answer

The fact that DHCP uses UDP port 67 for the server and UDP port 68 for clients, you can make ip table rules like these:

iptables -A FORWARD -p udp -d that-one-device-ip-address --dport 67 -j DROP
iptables -A FORWARD -p udp -s that-one-device-ip-address --sport 68 -j DROP