nmap表示端口已关闭,而nestat表示正在收听

时间:2012-08-10 15:56:35

标签: linux port netcat nmap

这是Ubuntu 12.04环境。我在框上的端口8020上运行了TCP服务:

我的问题是:

为什么在nat中没有发现端口8020作为开放端口,而nestat说它正在监听?

如果我跑

netstat -tuplen

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       User           Inode       PID/Program name
tcp        0      0 127.0.0.1:9001          0.0.0.0:*               LISTEN      0          10564       1917/python    
tcp        0      0 127.0.0.1:8020          0.0.0.0:*               LISTEN      117        29259       4448/java       

但如果我跑

nmap -v -sT 127.0.0.1

Starting Nmap 5.21 ( http://nmap.org ) at 2012-08-10 08:51 PDT
Initiating Connect Scan at 08:51
Scanning localhost (127.0.0.1) [1000 ports]
Discovered open port 53/tcp on 127.0.0.1
Discovered open port 22/tcp on 127.0.0.1
Discovered open port 9000/tcp on 127.0.0.1
Discovered open port 631/tcp on 127.0.0.1
Discovered open port 9001/tcp on 127.0.0.1
Completed Connect Scan at 08:51, 0.04s elapsed (1000 total ports)
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00046s latency).
rDNS record for 127.0.0.1: hadoop-namenode-01
Not shown: 995 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
53/tcp   open  domain
631/tcp  open  ipp
9000/tcp open  cslistener
9001/tcp open  tor-orport

Read data files from: /usr/share/nmap
Nmap done: 1 IP address (1 host up) scanned in 0.10 seconds
       Raw packets sent: 0 (0B) | Rcvd: 0 (0B)

3 个答案:

答案 0 :(得分:8)

默认情况下,nmap不会扫描所有端口。试试这个。

nmap -sT -sU -p- 127.0.0.1

答案 1 :(得分:6)

@Satish,您不需要添加-sU来扫描UDP端口,并且需要一段时间。

nmap -v -p 8020 127.0.0.1

这应该足够及时。

答案 2 :(得分:2)

默认情况下,nmap仅扫描众所周知的端口。 您可以使用-p参数指定端口。

扫描所有端口: nmap -v -p“*”127.0.0.1

仅扫描端口8020: nmap -v -p 8020 127.0.0.1