用iptables打开一个端口是行不通的

时间:2014-09-01 19:31:52

标签: linux networking iptables

我想用iptables -A INPUT -p tcp --dport 80 -j ACCEPT在Debian上打开一个端口,但它无法正常工作。当我扫描localhost时:

root@debian:~# nmap -p 80 localhost

Starting Nmap 6.00 ( http://nmap.org ) at 2014-08-27 12:38 CEST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00033s latency).
Other addresses for localhost (not scanned): 127.0.0.1
PORT   STATE  SERVICE
80/tcp closed http

Nmap done: 1 IP address (1 host up) scanned in 0.14 seconds

我无法使用netcat连接:

root@debian:~# nc -vv localhost 80
localhost [127.0.0.1] 80 (?) : Connection refused
sent 0, rcvd 0

但它在iptables上:

root@debian:~# iptables -L
...
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:80
...

我还在路由器上使用NAT打开了连接到互联网的端口。

我在i368上使用Debian 3.2.0-4。

1 个答案:

答案 0 :(得分:-1)

你需要一些东西来听这个端口接受连接。例如Web服务器。

运行此命令以查看是否有正在运行的服务器侦听80端口:

netstat -ntlup | grep 80