Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have two IP addresses on my physical eth interface. Lets say (eth0:0) and (eth0). So it works. But I use application, working on the only one of this addresses on port 12000. It is setup in this application internally to work on address I set app to work on address too, using iptables, in such way:

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -t nat -A PREROUTING -p tcp -d --dport 12000 -j DNAT --to

Now I want to block all incoming traffic to IP address (interface eth0:0) except port 12000. All the rest traffic must be unchanged. I am not iptables expert. Can anybody help me?

share|improve this question

1 Answer 1

assuming your iptables rule work on the same machine with your application, you have to define a rule to accept incoming and outgoing packet to the address and application port, then you just simply drop everything else, it seems like this :

iptables -A INPUT -p tcp -d --dport 12000 -j ACCEPT
iptables -A OUTPUT -p tcp -s --sport 12000 -j ACCEPT

iptables -A INPUT -j DROP
iptables -A OUTPUT -j DROP

share|improve this answer

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.