Friday, September 26, 2014

iptables

Add a rule
sudo iptables -A INPUT -p tcp -m state --state NEW,RELATED,ESTABLISHED -m tcp --dport 1234 -j ACCEPT 

Insert a rule to a specific line
sudo iptables -I INPUT 7 -p tcp -m state --state NEW,RELATED,ESTABLISHED -m tcp --dport 1234 -j ACCEPT

The above example inserts the rule before the line 7. If no line number is defined it will use the default value of 1 in which your rule is inserted at the topmost line. 

Delete a rule
-D INPUT -p tcp -m state --state NEW,RELATED,ESTABLISHED -m tcp --dport 1234 -j ACCEPT 

Saving rules
service iptables save

Restart service
service iptables restart

No comments:

Post a Comment