I'm trying to drop all access to 8180 (TCP) port except for one IP.

The drop:

iptables -A INPUT -p tcp --dport 8180 -j DROP

The exception:

iptables -A INPUT -s -p tcp --dport 8180 -j ACCEPT

Where is the IP that is allowed to access the specific port.

What's wrong?


Make sure your ACCEPT rule is above your DROP rule in your rules file, otherwise the packet will be dropped before it has the chance to be accepted.

| improve this answer | |
  • Yes, that can be a problem also but it wasn't mine. I actually fixed it by specifying the destination and the interface. – Bogdan May 17 '09 at 15:17

Just going to add, you probably want to have a default-deny rule in place. In that case you won't need the drop for that port and can simply specify what you do want to allow, i.e. access to port 8180 from

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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