![我使用 iptables 打开的端口似乎已关闭](https://linux22.com/image/640135/%E6%88%91%E4%BD%BF%E7%94%A8%20iptables%20%E6%89%93%E5%BC%80%E7%9A%84%E7%AB%AF%E5%8F%A3%E4%BC%BC%E4%B9%8E%E5%B7%B2%E5%85%B3%E9%97%AD%20.png)
我在 Debian 7 上使用 iptables 打开了以下端口:
iptables -X
iptables -F
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --dport 21 -j ACCEPT #FTP
iptables -A INPUT -p tcp --dport 111 -j ACCEPT #RPCBIND
iptables -A INPUT -p tcp --dport 113 -j ACCEPT #AUTH
iptables -A INPUT -p tcp --dport 139 -j ACCEPT #NETBIOS-SSH
iptables -A INPUT -p tcp --dport 443 -j ACCEPT #HTTPS
iptables -A INPUT -p tcp --dport 901 -j ACCEPT #SAMBA
iptables -A INPUT -p tcp --dport 993 -j ACCEPT #IMAP
iptables -A INPUT -p tcp --dport 8080 -j ACCEPT #TOMCAT
iptables -A INPUT -p tcp --dport 1723 -j ACCEPT #PPTP
iptables -A INPUT -p tcp --dport 10000 -j ACCEPT #WEBMIN
iptables -A INPUT -j DROP
但是当我使用“nmap”扫描服务器上的开放端口时,有些端口显示为已关闭。有人能帮我吗?
~ $ nmap 172.16.17.135
Starting Nmap 6.40 ( http://nmap.org ) at 2014-08-21 14:38 PDT
Nmap scan report for 172.16.17.135
Host is up (0.00060s latency).
Not shown: 988 filtered ports
PORT STATE SERVICE
21/tcp open ftp
22/tcp open ssh
80/tcp open http
111/tcp open rpcbind
113/tcp closed ident
139/tcp closed netbios-ssn
443/tcp open https
901/tcp closed samba-swat
993/tcp closed imaps
1723/tcp closed pptp
8080/tcp closed http-proxy
10000/tcp closed snet-sensor-mgmt
答案1
用户3680708,
列出具有开放端口的服务:
# netstat -tulpn
这将列出 PID 和服务名称以及 TCP/UDP 信息。如果未列出服务/端口,那么这可能解释了为什么 nmap 扫描中的端口状态为“关闭”。