如何使用 Puppet 实现 iptables

如何使用 Puppet 实现 iptables

我想在 Puppet 中从 Puppet Master 到客户端实现以下这些规则

有人能帮我获取这个 iptables 规则的脚本吗,以及我们想要在哪个文件中包含以下配置

17x.x8.9x.10 (Execute below in this host)
sudo iptables -I INPUT 1 -p tcp --dport 80 -m comment --comment "Allow http connection" -j ACCEPT
sudo iptables -I INPUT 1 -p tcp --dport 443 -m comment --comment "Allow https connection" -j ACCEPT

17x.x8.9x.222 (Execute below in this host)
sudo iptables -I INPUT 1 -p tcp --dport 80 -m comment --comment "Allow http connection" -j ACCEPT
sudo iptables -I INPUT 1 -p tcp --dport 443 -m comment --comment "Allow https connection" -j ACCEPT


17x.x8.9x.33 (Execute below in this host)
sudo iptables -I INPUT 1 -p tcp -s 17x.18.89.1 --dport 8009 -m comment --comment "Allow MOUNTD" -j ACCEPT
sudo iptables -I INPUT 1 -p tcp -s 17x.18.89.2 --dport 8009 -m comment --comment "Allow MOUNTD" -j ACCEPT
sudo iptables -I INPUT 1 -p tcp -s 17x.18.89.34 --dport 60295 -m comment --comment "Allow MOUNTD" -j ACCEPT
sudo iptables -I INPUT 1 -p tcp -s 17x.18.89.34 --dport 2049 -m comment --comment "Allow NFS" -j ACCEPT
sudo iptables -I INPUT 1 -p tcp -s 17x.18.89.34 --dport 111 -m comment --comment "Allow portmapper" -j ACCEPT
sudo iptables -I INPUT 1 -p tcp -s 17x.18.89.35 --dport 60295 -m comment --comment "Allow MOUNTD" -j ACCEPT
sudo iptables -I INPUT 1 -p tcp -s 17x.18.89.35 --dport 2049 -m comment --comment "Allow NFS" -j ACCEPT
sudo iptables -I INPUT 1 -p tcp -s 17x.18.89.35 --dport 111 -m comment --comment "Allow portmapper" -j ACCEPT


17x.18.160.34 (Execute below in this host)
sudo iptables -I INPUT 1 -p tcp -s 17x.18.160.1 --dport 8009 -m comment --comment "Allow MOUNTD" -j ACCEPT
sudo iptables -I INPUT 1 -p tcp -s 17x.18.160.2 --dport 8009 -m comment --comment "Allow MOUNTD" -j ACCEPT


17x.18.89.35 (Execute below in this host)
sudo iptables -I INPUT 1 -p tcp -s 17x.18.89.1 --dport 8009 -m comment --comment "Allow MOUNTD" -j ACCEPT
sudo iptables -I INPUT 1 -p tcp -s 17x.18.89.2 --dport 8009 -m comment --comment "Allow MOUNTD" -j ACCEPT

答案1

使用防火墙模块(由 Puppet Labs 开发)。

自述文件中有使用示例,可​​以很好地涵盖您的用例。

相关内容