2

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 1.2.3.4 -p tcp --dport 8180 -j ACCEPT

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

What's wrong?

6

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
2

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 1.2.3.4.

| 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.