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?

2 Answers 2

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.

1
  • 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, 2009 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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .