像这样的脚本可能对任何人都有用吗?
请注意,您将丢失当前配置的所有内容,因为它会删除Firewalld并刷新INPUT表中的所有当前规则:
yum remove firewalld && yum install iptables-services
iptables --flush INPUT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT # Any packages related to an existing connection are OK
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT # ssh is OK
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 3000 -j ACCEPT # Port 3000 for IPv4 is OK
iptables -A INPUT -j REJECT # any other traffic is not welcome - this should be the last line
service iptables save # Save IPv4 IPTABLES rules van memory naar disk
systemctl enable iptables # To make sure the IPv4 rules are reloaded at system startup
我想如果IPv6流量可能会(现在或以后)访问您的系统,您也希望这样做:
ip6tables --flush INPUT
ip6tables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT # Any packages related to an existing connection are OK
ip6tables -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT # ssh is OK
ip6tables -A INPUT -m state --state NEW -m tcp -p tcp --dport 3000 -j ACCEPT # Port 3000 for IPv6 is OK
ip6tables -A INPUT -j REJECT # any other traffic is not welcome - this should be the last line
service ip6tables save # Save IPv6 IPTABLES rules van memory naar disk
systemctl enable ip6tables # To make sure the IPv6 rules are reloaded at system startup