我正在使用傀儡实验室的防火墙模块,我在为一个简单的web主机设置iptable时遇到了麻烦。
我正在遵循这个指南,并希望建立更多的规则。https://sysadmincasts.com/episodes/18-managing-iptables-with-puppet
例如,我添加了允许使用git和mysql端口的传出通信量的规则:
firewall { '200 allow outgoing mysql':
chain => 'OUTPUT',
state => ['NEW'],
proto => 'tcp',
dport => '3306',
action => 'accept',
}
firewall { '200 allow outgoing git':
chain => 'OUTPUT',
state => ['NEW'],
dport => '9418',
proto => 'tcp',
action => 'accept',
}
在iptables中,我可以看到以下规则:
root@app01:~/geppetto# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0 /* 000 accept all icmp */
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 /* 001 accept all to lo interface */
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 /* 003 accept related established rules */ state RELATED,ESTABLISHED
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 multiport dports 80 /* 200 allow incoming http */ state NEW
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 multiport dports 22 /* 200 allow openssh */ state NEW
LOG all -- 0.0.0.0/0 0.0.0.0/0 /* 900 log dropped input chain */ LOG flags 0 level 6 prefix "[IPTABLES INPUT] dropped "
DROP all -- 0.0.0.0/0 0.0.0.0/0 /* 910 deny all other input requests */
Chain FORWARD (policy ACCEPT)
target prot opt source destination
LOG all -- 0.0.0.0/0 0.0.0.0/0 /* 900 log dropped forward chain */ LOG flags 0 level 6 prefix "[IPTABLES FORWARD] dropped "
DROP all -- 0.0.0.0/0 0.0.0.0/0 /* 910 deny all other forward requests */
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 /* 004 accept related established rules */ state RELATED,ESTABLISHED
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 multiport dports 53 /* 200 allow outgoing dns lookups */ state NEW
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 multiport dports 9418 /* 200 allow outgoing git */ state NEW
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 multiport dports 80 /* 200 allow outgoing http */ state NEW
ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0 /* 200 allow outgoing icmp type 8 (ping) */ icmptype 8
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 multiport dports 3306 /* 200 allow outgoing mysql */ state NEW
LOG all -- 0.0.0.0/0 0.0.0.0/0 /* 900 log dropped output chain */ LOG flags 0 level 6 prefix "[IPTABLES OUTPUT] dropped "
DROP all -- 0.0.0.0/0 0.0.0.0/0 /* 910 deny all other output requests */
但是,我不能从机器上用git访问任何东西。运行git获取原点只是超时。我是否也必须为传出源端口设置一些规则?提前感谢!
发布于 2015-04-24 22:18:12
Git可以使用几种协议,它们是记录在这里 --其中最常见的是SSH,它用于GitHub (公共和企业风味)以及Gitosis和Gitolite。
要在SSH上使用Git,您需要打开端口22出站,要使用更为罕见的Git协议,您需要打开端口9418,这是您已经拥有的端口,因此您很可能实际上使用的是SSH Git URL。
示例:git@github.com:craigwatson/puppet-vmwaretools.git
https://serverfault.com/questions/685359
复制相似问题