Открыть порт в iptables

July 8, 2009, revised January 9, 2011 iptables Linux хостинг
iptables-save > /etc/iptables.up.rules #backup
cp /etc/iptables.up.rules ~/iptables.test.rules #new rules
vim ~/iptables.test.rules #edit
iptables-restore < ~/iptables.test.rules #load new rules
iptables-save > /etc/iptables.up.rules #commit

Пример:

*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT -d 127.0.0.0/255.0.0.0 -i ! lo -j REJECT --reject-with icmp-port-unreachable
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 25 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 21 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 3690 -j ACCEPT
-A INPUT -p udp -m udp --dport 3690 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 5222 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 5223 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 5280 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 5281 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 5269 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7
-A INPUT -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -j REJECT --reject-with icmp-port-unreachable
-A OUTPUT -j ACCEPT
COMMIT

Buy Me a Coffee at ko-fi.com