超级实用的 iptables 防火墙脚本( 二 )

iptables 的清空和恢复
【超级实用的 iptables 防火墙脚本】[root@Jaking ~]# iptables -F[root@Jaking ~]# iptables -LChain INPUT (policy ACCEPT)targetprot opt sourcedestinationChain FORWARD (policy ACCEPT)targetprot opt sourcedestinationChain OUTPUT (policy ACCEPT)targetprot opt sourcedestination[root@Jaking ~]# iptables -t nat -F[root@Jaking ~]# iptables -t nat -LChain PREROUTING (policy ACCEPT)targetprot opt sourcedestinationChain INPUT (policy ACCEPT)targetprot opt sourcedestinationChain OUTPUT (policy ACCEPT)targetprot opt sourcedestinationChain POSTROUTING (policy ACCEPT)targetprot opt sourcedestination [root@Jaking ~]# iptables-restore < /etc/sysconfig/iptables[root@Jaking ~]# iptables -LChain INPUT (policy ACCEPT)targetprot opt sourcedestinationACCEPTall--anywhereanywhereACCEPTall--localhostlocalhostACCEPTicmp --anywhereanywhereicmp echo-requestACCEPTicmp --anywhereanywhereicmp fragmentation-neededACCEPTtcp--anywhereanywheretcp dpt:httpACCEPTtcp--anywhereanywheretcp dpt:httpsACCEPTudp--anywhereanywheremultiport dports http,httpsACCEPTtcp--192.168.1.63anywheretcp dpt:sshACCEPTtcp--192.168.1.3anywheretcp dpt:sshACCEPTudp--192.168.1.26anywhereudp dpt:snmpDROPall--anywhereanywhereChain FORWARD (policy ACCEPT)targetprot opt sourcedestinationDROPall--anywhereanywhereChain OUTPUT (policy ACCEPT)targetprot opt sourcedestinationACCEPTall--anywhereanywherestate ESTABLISHEDDROPall--anywhereanywhere[root@Jaking ~]# iptables -t nat -LChain PREROUTING (policy ACCEPT)targetprot opt sourcedestinationDNATtcp--anywhere192.168.1.63tcp dpt:http to:192.168.2.2:80Chain INPUT (policy ACCEPT)targetprot opt sourcedestinationChain OUTPUT (policy ACCEPT)targetprot opt sourcedestinationChain POSTROUTING (policy ACCEPT)targetprot opt sourcedestinationSNATall--192.168.2.0/24anywhereto:192.168.1.63总结
以上就是生产环境中超级实用的iptables脚本,这个脚本可以直接拿去用,不过请谨慎操作!
本文原创地址:https://www.linuxprobe.com/super-practical-iptables.html编辑:传棋,审核员:逄增宝




推荐阅读