iptables阻止我在端口80上telnet到外部服务器

时间:2013-09-03 17:42:27

标签: java linux tomcat tcp iptables

我一直试图在端口80上的一台外部服务器上进行远程登录。

使用iptables:

telnet XYZ 80
Trying XYZ...
Connected to XYZ.
Escape character is '^]'.
qwer (here i type some characters)
HTTP/1.1 400 Bad Request
Server: Apache-Coyote/1.1
Transfer-Encoding: chunked
Date: Tue, 03 Sep 2013 16:58:31 GMT
Connection: close

0

Connection closed by foreign host.

关闭iptables:

telnet XYZ 80
Trying XYZ...
Connected to XYZ.
Escape character is '^]'.
qwer (here i type some characters)

Getting back html response (It's working here, with iptables off)

输出:     iptables -L

Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             abcd                state NEW tcp dpt:http

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

在/etc/iptables.conf文件中,我已完成端口转发(出于安全考虑,将80端口传入的Web流量重定向到Apache 8080端口,反之亦然):

:PREROUTING ACCEPT [2:100]
:POSTROUTING ACCEPT [20:1650]
:OUTPUT ACCEPT [20:1650]
-A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080 
-A OUTPUT -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080 
COMMIT

在iptables中用什么条目在端口80上的XYZ服务器上运行telnet,因为如果我保持我的iptables关闭它会正常工作?

1 个答案:

答案 0 :(得分:0)

我很困惑。你正试图telnet到http服务器?或者您是否尝试将您的telnet服务器放在端口80上? 8080端口到底在哪里?