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

I want to drop ALL the ipv4 traffic on a certain port and only allow ipv6 traffic with iptables. Is it possible? is so, how?

share|improve this question
You should be setting your chain policies to default to drop. So all you have to do is not add rule to permit traffic. If you already have a complex rule set, then you might need to tell us what rules you currently have, so we can tell you what to add, and where. – Zoredache Jun 28 '12 at 18:37
When you say port, do you mean an ethernet port, or a protocol port (please specify TCP or UDP) – Mike Pennington Jun 28 '12 at 18:47

You can't do this directly with just iptables as it only controls ipv4. To interact with netfilter for ipv6 you have to use the ip6tables command. To block the IPv4 port just use iptables as you would normally e,g,

iptables -I INPUT -p tcp --dport 80 -j DROP

To open the IPv6 port use ip6tables e.g.

ip6tables -I INPUT -p tcp --dport 80 -j ACCEPT
share|improve this answer

Presumably the best way to block all IPv4 traffic is not to have an IPv4 address on the port; I'm not sure why iptables would be needed to drop all IPv4 traffic.

share|improve this answer
You could conceivably want to do something like this for testing purposes. – Iain Jun 28 '12 at 18:51

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.