Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here is the output of my iptables-save command. The last rule and default policy is to DROP any packets that dont match any thing.

Generated by iptables-save v1.4.9 on Wed Aug 3 21:00:05 2011
:OUTPUT ACCEPT [76:6239]
-A INPUT -p -m tcp --dport 8080 -j ACCEPT
-A INPUT -p -m tcp --dport 2222 -j ACCEPT
-A INPUT -p icmp -j ACCEPT

But surprisingly, DHCP and every other traffic is getting through... Please advise how to allow connections on port 8080 and port 2222 only and drop everything else.

Network Diagram

The iptables rules are being set on the FedoraRouter Machine. And this FedoraRouter machine is running Apache and SSH on port 8080 and 2222 respectively.

The clients FedoraClient and WinXP-Client need to have access to these services only. I cannot block them by IP because i'll be adding in more computers in future, anything other than HTTP and SSH traffic needs to be dropped in general.

Based on the current setup - It is allowing DHCP packets to the router, the router is infact running DHCP and i need to block it.


share|improve this question
"Getting through" what? Where is the traffic coming from? Where is it going to? What is this mystery machine that you're putting these rules onto? – womble Aug 4 '11 at 1:09
please refer to the network diagram above.. FedoraClient is the machine that is running iptables and the current setup is allowing DHCP on the router to talk to the clients.. which i dont want. it needs to block the DHCP packets. Thanks in advance! – Jasdeep Singh Aug 4 '11 at 1:19
Your comment and question don't match... is the firewall on FedoraClient or FedoraRouter? And if you don't want DHCP, why are you running it? – womble Aug 4 '11 at 1:34
I'm sorry that was a typo. It's FedoraRouter that is running the iptables. Answer below by mizi is exactly what i wanted. – Jasdeep Singh Aug 4 '11 at 18:45
up vote 1 down vote accepted

ISC dhcpd, for various rather annoying reasons uses raw sockets to perform it's network I/O. For other technical reasons, raw sockets bypass iptables processing (including the inappropriately named raw table), which makes iptables ineffective for filtering DHCP server traffic when the firewall and host are on the same machine.

You can read about raw sockets here

DHCP traffic is broadcasted anyway, and it's not easy to block it on a per-client basis. So why wouldn't you just shut the dhcpd daemon down?

share|improve this answer
Care to investigate before commenting and downvoting? – mizi Aug 6 '11 at 22:22
Does tcpdump implement some kind of magic that dhcpd is just incapable of? You should really read about RAW sockets and promiscuous mode – mizi Aug 6 '11 at 22:30
Sure they did. My point is that dhcpd works the way tcpdump does - it sees packets before iptables, unltimately bypassing it. So it's not possible to block incoming dhcp requests. I'm not sure about outgoing replies though, high chances they aren't get blocked as well. Anyway, blocking outgoing packets may achieve the goal of rendering dhcpd deaf, but it does nothing from the security point of view, should a security vulnerability found in dhcpd. – mizi Aug 6 '11 at 23:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.