我知道一个事实,即运行iptables导致我的Apache Solr实例无法访问。 我怎么知道这个? 因为我跑了:
/sbin/service iptables save && /sbin/service iptables stop
一旦我做到了,一切都完美无瑕。
我想继续使用我的防火墙,但是,添加必要的规则似乎并没有工作。 我已经用尽了我想要的工作:
/sbin/service iptables start /sbin/iptables -A RH-Firewall-1-INPUT -p tcp -s 127.0.0.1 --dport 8983 -j ACCEPT /sbin/service iptables save
还是行不通
/sbin/iptables -D RH-Firewall-1-INPUT -p tcp -s 127.0.0.1 --dport 8983 -j ACCEPT /sbin/iptables -A RH-Firewall-1-INPUT -p tcp --dport 8983 -j ACCEPT /sbin/service iptables save
还是行不通
我甚至尝试在8983端口上进行一般性的接受:
/sbin/iptables -A INPUT -p tcp --dport 8983 -j ACCEPT /sbin/service iptables save
还是行不通!
想法?
**/sbin/iptables -L -n -v** Chain INPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 215K 50M RH-Firewall-1-INPUT all -- * * 0.0.0.0/0 0.0.0.0/0 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8983 Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 0 0 RH-Firewall-1-INPUT all -- * * 0.0.0.0/0 0.0.0.0/0 Chain OUTPUT (policy ACCEPT 279K packets, 286M bytes) pkts bytes target prot opt in out source destination Chain RH-Firewall-1-INPUT (2 references) pkts bytes target prot opt in out source destination 14286 19M ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0 8 672 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 255 0 0 ACCEPT esp -- * * 0.0.0.0/0 0.0.0.0/0 0 0 ACCEPT ah -- * * 0.0.0.0/0 0.0.0.0/0 0 0 ACCEPT udp -- * * 0.0.0.0/0 224.0.0.251 udp dpt:5353 0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:631 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:631 181K 29M ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED 2 164 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:55 148 7676 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:8008 2 120 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22 11208 621K ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80 2202 123K ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:443 5372 951K REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
更新(在上次规则之前添加):
*# /sbin/iptables -L -n -v --line-numbers* Chain INPUT (policy ACCEPT 0 packets, 0 bytes) num pkts bytes target prot opt in out source destination 1 585K 123M RH-Firewall-1-INPUT 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 1 0 0 RH-Firewall-1-INPUT all -- * * 0.0.0.0/0 0.0.0.0/0 Chain OUTPUT (policy ACCEPT 782K packets, 822M bytes) num pkts bytes target prot opt in out source destination Chain RH-Firewall-1-INPUT (2 references) num pkts bytes target prot opt in out source destination 1 31867 43M ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0 2 27 2232 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 255 3 0 0 ACCEPT esp -- * * 0.0.0.0/0 0.0.0.0/0 4 0 0 ACCEPT ah -- * * 0.0.0.0/0 0.0.0.0/0 5 0 0 ACCEPT udp -- * * 0.0.0.0/0 224.0.0.251 udp dpt:5353 6 0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:631 7 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:631 8 502K 76M ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED 9 4 268 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:55 10 189 9780 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:8008 11 8 480 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22 12 29633 1656K ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80 13 6138 345K ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:443 14 14841 2635K REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited *# /sbin/iptables --insert RH-Firewall-1-INPUT 14 -p tcp --dport 8983 -j ACCEPT # /sbin/iptables -L -n -v --line-numbers* Chain INPUT (policy ACCEPT 0 packets, 0 bytes) num pkts bytes target prot opt in out source destination 1 599K 127M RH-Firewall-1-INPUT 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 1 0 0 RH-Firewall-1-INPUT all -- * * 0.0.0.0/0 0.0.0.0/0 Chain OUTPUT (policy ACCEPT 801K packets, 841M bytes) num pkts bytes target prot opt in out source destination Chain RH-Firewall-1-INPUT (2 references) num pkts bytes target prot opt in out source destination 1 32631 44M ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0 2 27 2232 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 255 3 0 0 ACCEPT esp -- * * 0.0.0.0/0 0.0.0.0/0 4 0 0 ACCEPT ah -- * * 0.0.0.0/0 0.0.0.0/0 5 0 0 ACCEPT udp -- * * 0.0.0.0/0 224.0.0.251 udp dpt:5353 6 0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:631 7 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:631 8 514K 78M ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED 9 4 268 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:55 10 292 15136 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:8008 11 8 480 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22 12 30425 1701K ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80 13 6304 355K ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:443 14 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8983 15 15130 2690K REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
即使在RH-Firewall-1-INPUT链的最后一行之前添加了ACCEPT规则,它仍然不起作用
iptables规则的顺序非常重要,因为第一场比赛胜利。 与大多数明智的人一样,红帽通常在其链条的末端放置一个REJECT,并添加规则以允许solrstream量或任何其他types的stream量,这对于数据包永远不会有太大的帮助下链。
如果是这样的话,你需要做一个iptables -L -n -v --line-number ,find最后的一揽子规则的编号,并使用iptables -I RH-Firewall-1-INPUT n ...在行号n处插入你的ACCEPT,其中n小于毛毯REJECT的号码。
编辑 :感谢上市。 看到毯子REJECT all -- * *在最后? 之后再加上你的ACCEPT是没有意义的,因为你永远不会那么做。 尝试做--line-number列表找出你需要插入该行 – 在最后一行应该做的任何地方 – 看看是否有效。
编辑2 :你也可以确认服务器上的netstat -an|grep 8983返回一些合理的东西吗?
编辑3 :那么你的服务器没有监听端口8983,这就是为什么即使打开防火墙端口也无法连接的原因。 如果你在那个港口有一个听众,你会看到类似的东西
[madhatta@www mail]$ netstat -an|grep 443 tcp 0 0 193.219.118.100:443 0.0.0.0:* LISTEN
上面的例子取自我的networking服务器,这就是为什么它是端口443而不是8983.你将需要找出为什么在8983上没有任何监听器,才能取得进一步的进展。
编辑4 :你不能连接到一个不在监听的守护进程。 我知道你说过,“取下防火墙可以解决所有问题”,守护进程正在监听的时候可能是这样; 但现在我怀疑它。 如果你愿意重复这个实验:取下防火墙,确认服务器上的netstat -an|grep 8983仍然没有任何返回,然后显示telnet server 8983给出连接,我将感到惊喜。
编辑5 :很高兴帮助!