|
/Admin/iptables:
Build A Basic Firewall with iptables
This seems like a good starting point[1], blocking everything except SSH, established, loopback, and outgoing connections:
iptables -P INPUT ACCEPT iptables -F iptables -A INPUT -i lo -j ACCEPT iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A INPUT -p tcp --dport 22 -j ACCEPT iptables -P INPUT DROP iptables -P FORWARD DROP iptables -P OUTPUT ACCEPT iptables -L -v /etc/init.d/iptables-persistent save
On my Debian system, the last "save" line puts a reloadable copy of the current running iptables rules in /etc/iptables/rules.v4 & /etc/iptables/rules.v6. Thereafter, it is also possible (advisable?) to edit these files directly to add/modify rules. For instance to open up the http port, add the following line to /etc/iptables/rules.v4:
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPTThen load the new ruleset using:
iptables-restore < rules.v4
[1] http://wiki.centos.org/HowTos/Network/IPTables
posted at: 04:56 | path: /Admin/iptables | permanent link to this entry