【问题标题】:Opening a port with iptables doesn't work用 iptables 打开端口不起作用
【发布时间】:2014-09-01 19:31:51
【问题描述】:

我想用iptables -A INPUT -p tcp --dport 80 -j ACCEPT 在Debian 上打开一个端口,但它不起作用。当我扫描本地主机时:

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。

【问题讨论】:

  • 不是 Stackoverflow(又名编程问题),而是 SuperUser.SE 的问题。

标签: linux networking iptables


【解决方案1】:

你需要一些东西来监听这个端口以接受连接。以网络服务器为例。

运行这个看看你是否有一个正在运行的服务器监听 80 端口:

netstat -ntlup | grep 80

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-18
    • 2016-04-21
    • 2019-10-16
    • 1970-01-01
    • 2017-12-22
    • 2015-04-02
    • 1970-01-01
    相关资源
    最近更新 更多