Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

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.

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

share|improve this answer

Your Answer

 
discard

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.