CentOS 7がiptablesを開く
CentOS 7がiptablesを開く
リファレンス
1.インストール
systemctl stop firewalld && systemctl mask firewalld && yum install -y iptables iptables-services
2.構成
#!/bin/sh
iptables -P INPUT ACCEPT
iptables -F
iptables -X
iptables -Z
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 21 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
iptables -A INPUT -p tcp -s 127.0.0.1 -j ACCEPT
iptables -A INPUT -p udp -s 127.0.0.1 -j ACCEPT
service iptables save
systemctl restart iptables.service
systemctl enable iptables.service
3.インポートエクスポート
iptables-save > iptables.txt
iptables-restore < iptables.txt
service iptables save