1

I keep following this tutorial using a bash shell on ubuntu 12.04 as I open more and more ports on my server. I usually open up ports like this

sudo iptables -A INPUT -p tcp --dport PortNumberToOpen -j ACCEPT

Then I use this rule to close off remaining traffic

sudo iptables -P INPUT DROP

Normally if I then do sudo iptables -L it show a rule at the end of Input like this

 DROP       all  --  anywhere             anywhere 

But this time when I do sudo iptables -P INPUT DROP; sudo iptables -L it is not showing this DROP rule. I am following the exact same steps. What is going on?

3

I seriously doubt sudo iptables -P INPUT DROP produce the ending DROP rule. In fact, -P sets the policy, and the policy is found in the headers of the table:

sudo iptables -L
Chain INPUT (policy DROP)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination        

What you may have done is sudo iptables -A INPUT -j DROP which indeed produce the effect you have seen:

➜  src  sudo iptables -A INPUT -j DROP
➜  src  sudo iptables -L
Chain INPUT (policy DROP)
target     prot opt source               destination         
DROP       all  --  anywhere             anywhere            

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.