:: gem list -remote :: iptablesconfiguration

一旦我用iptableslocking我的VPS服务器,这意味着我只有几个选定的端口打开input访问,我的gem命令停止工作,我不知道我做错了什么。

这是一个双重的问题。

1。 这是在Gem命令行运行的命令。

gem list -r 

之前,它显示了一个可用于安装的远程gem列表,现在它已经停止,除非我再次通过iptables打开所有的端口。 我已经读了几个地方来打开443号港口,但​​是我看到的例子对我来说是相当陌生的,我试图从中拿走的例子并不起作用。 那么有没有人有任何想法? 这是我的iptables设置的输出。

 Chain INPUT (policy ACCEPT 0 packets, 0 bytes) num pkts bytes target prot opt in out source destination 1 193 14308 ACCEPT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:22 2 0 0 ACCEPT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 3 0 0 ACCEPT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:81 4 0 0 ACCEPT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:82 5 0 0 ACCEPT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8080 6 0 0 ACCEPT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8090 7 0 0 ACCEPT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:443 8 28 2214 LOGGING all -- * * 0.0.0.0/0 0.0.0.0/0 Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) num pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 154 packets, 16540 bytes) num pkts bytes target prot opt in out source destination Chain LOGGING (1 references) num pkts bytes target prot opt in out source destination 1 28 2214 LOG all -- * * 0.0.0.0/0 0.0.0.0/0 LOG flags 0 level 4 prefix "IPTables Dropped" 2 28 2214 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 

我的问题的第二部分是,在没有文档的情况下,如何显示在这种情况下正在访问的程序(如gem)的IP地址和端口? 我希望有一些程序可以input类似的命令,如下所示:

 sandbox-wrap 'gem list -r' 

并且,在屏幕上观看互联网访问信息显示。


谢谢Iain回答这个问题。 对于你们其余的人来说,这里是新的iptables的一个副本。 我添加了一个新行,将其放置在过滤表的INPUT链的第1位。

 Chain INPUT (policy ACCEPT 0 packets, 0 bytes) num pkts bytes target prot opt in out source destination 1 7 488 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED 2 700 50592 ACCEPT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:22 3 0 0 ACCEPT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 4 0 0 ACCEPT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:81 5 0 0 ACCEPT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:82 6 0 0 ACCEPT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8080 7 0 0 ACCEPT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8090 8 1 40 ACCEPT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:443 9 83 6958 LOGGING all -- * * 0.0.0.0/0 0.0.0.0/0 

按照configuration,我认为你的主要问题是LOGGING链末端的DROP。 它正在丢弃所有到达它的数据包。 gem命令将使用一个随机的临时端口来连接到远程系统。 数据包将返回给它,因为你不只是允许数据包显式端口在你的INPUT链,你用DROP阻止他们。

通过在INPUT链中尽早添加相关/已build立的连接是正常的

 iptables -I INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT 

这将允许包中的数据包与传出的gem连接有关。