首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >是否需要为iptables上的传出规则为源端口和目标端口设置规则?

是否需要为iptables上的传出规则为源端口和目标端口设置规则?
EN

Server Fault用户
提问于 2015-04-24 15:09:08
回答 1查看 425关注 0票数 0

我正在使用傀儡实验室的防火墙模块,我在为一个简单的web主机设置iptable时遇到了麻烦。

我正在遵循这个指南,并希望建立更多的规则。https://sysadmincasts.com/episodes/18-managing-iptables-with-puppet

例如,我添加了允许使用git和mysql端口的传出通信量的规则:

代码语言:javascript
运行
复制
  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中,我可以看到以下规则:

代码语言:javascript
运行
复制
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获取原点只是超时。我是否也必须为传出源端口设置一些规则?提前感谢!

EN

回答 1

Server Fault用户

回答已采纳

发布于 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

票数 2
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/685359

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档