超级实用的 iptables 防火墙脚本
本文档详细介绍生产环境中超级实用的iptables 脚本 。 创建 iptables.sh 脚本 [root@Jaking ~]# vim iptables.sh #!/bin/bash #清空 filter 表和 nat 表 iptables -F iptables -t nat -F #关掉 firewalld systemctl stop firewalld &>/dev/null systemctl disable firewalld &>/dev/null #以下两行允许某些调用 localhost 的应用访问 iptables -A INPUT -i lo -j ACCEPT #规则1 iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT #规则2 #以下一行允许从其他地方 ping iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT #规则3 #以下一行允许从其他主机、网络设备发送 MTU 调整的报文 #在一些情况下,例如通过 IPSec VPN 隧道时,主机的 MTU 需要动态减小 iptables -A INPUT -p icmp --icmp-type fragmentation-needed -j ACCEPT #规则4