Ling-iptables

来自ling
跳转至: 导航搜索
tee > /etc/sysconfig/iptables <<EOF
# sample configuration for iptables service
# you can edit this manually or use system-config-firewall
# please do not ask us to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 73 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 50:80 -j ACCEPT
-A INPUT -p tcp -m multiport --dports 8889,5432,6379,10022,2181,9092,50000,27017,9200,9300 -m state --state NEW,ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp -m multiport --sports 8889,5432,6379,10022,2181,9092,50000,27017,9200,9300 -m state --state ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m multiport --dports 5672,4369,25672,15671,15672 -m state --state NEW,ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp -m multiport --sports 5672,4369,25672,15671,15672 -m state --state ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m multiport --dports 1577 -m state --state NEW,ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp -m multiport --sports 1577 -m state --state ESTABLISHED -j ACCEPT
-A INPUT -p tcp --dport 6800:6999 -m state --state NEW,ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp --sport 6800:6999 -m state --state ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m multiport --dports 2379,2380,4001 -m state --state NEW,ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp -m multiport --sports 2379,2380,4001 -m state --state ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m multiport --dports 6443,8989 -m state --state NEW,ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp -m multiport --sports 6443,8989 -m state --state ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m multiport --dports 1521 -m state --state NEW,ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp -m multiport --sports 1521 -m state --state ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m multiport --dports 3306,3307,3308,3309 -m state --state NEW,ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp -m multiport --sports 3306,3307,3308,3309 -m state --state ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m multiport --dports 25,109,110,143,465,587,995,993 -m state --state NEW,ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp -m multiport --sports 25,109,110,143,465,587,995,993 -m state --state ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m multiport --dports 33080 -m state --state NEW,ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp -m multiport --sports 33080  -m state --state ESTABLISHED -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
EOF
systemctl daemon-reload
systemctl enable iptables
systemctl start iptables
systemctl status iptables
systemctl reload iptables
systemctl restart docker