![在 iptables 中打开 8140 端口,使 Puppet 在 centos 5 中工作](https://linux22.com/image/516607/%E5%9C%A8%20iptables%20%E4%B8%AD%E6%89%93%E5%BC%80%208140%20%E7%AB%AF%E5%8F%A3%EF%BC%8C%E4%BD%BF%20Puppet%20%E5%9C%A8%20centos%205%20%E4%B8%AD%E5%B7%A5%E4%BD%9C.png)
以下是 iptables -L 的输出
Chain INPUT (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- anywhere anywhere
Chain FORWARD (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain RH-Firewall-1-INPUT (2 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT icmp -- anywhere anywhere icmp any
ACCEPT esp -- anywhere anywhere
ACCEPT ah -- anywhere anywhere
ACCEPT udp -- anywhere 224.0.0.251 udp dpt:mdns
ACCEPT udp -- anywhere anywhere udp dpt:ipp
ACCEPT tcp -- anywhere anywhere tcp dpt:ipp
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
我想打开端口 8140,以便其他 Puppet 客户端可以与 Puppet Master 进行通信,因此我尝试添加此规则:
iptables -I INPUT 2 -p tcp --dport 8140 -j ACCEPT
但它不起作用。如果有帮助的话,iptables-save 的输出是
# Generated by iptables-save v1.3.5 on Mon Jun 21 17:07:33 2010
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [605:28389]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A INPUT -p tcp -m tcp --dport 8140 -j ACCEPT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp -m icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p esp -j ACCEPT
-A RH-Firewall-1-INPUT -p ah -j ACCEPT
-A RH-Firewall-1-INPUT -d 224.0.0.251 -p udp -m udp --dport 5353 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
# Completed on Mon Jun 21 17:07:33 2010
谢谢。
答案1
如果你要添加
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 8140 -j ACCEPT
就在以下行之前:
-A RH-Firewall-1-INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
这应该会给你带来你所期望的结果。
答案2
您需要更新名为 RH-Firewall-1 的链,而不是 INPUT。
答案3
您应该能够使用 system-config-security(或类似的东西)来修改防火墙规则。这是首选,因为它是持久的,并且在服务器重新启动后仍然存在。