Monday, March 17, 2014

Editing iptables to allow/drop ports

To enable a particular ports on iptables you can run the command

$sudo iptables -A INPUT -p tcp --dport ssh -j ACCEPT
$sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
$sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT
$sudo iptables -A INPUT -p tcp --dport smtp -j ACCEPT

If you need to listen on loopback interface, you will need to add that as the first rule below

$sudo iptables -I INPUT 1 -i lo -j ACCEPT

To confirm you can run "sudo iptables -v -L". To add a drop rule to the firewall you can add

$sudo iptables -A INPUT -j DROP

Refer to more detailed instructions at: Ubuntu IptablesHowTo

No comments:

Post a Comment