| 1 2 3 4 5 6 7 |
nmap端口状态解析open : 应用程序在该端口接收 TCP 连接或者 UDP 报文。 closed :关闭的端口对于nmap也是可访问的, 它接收nmap探测报文并作出响应。但没有应用程序在其上监听。filtered :由于包过滤阻止探测报文到达端口,nmap无法确定该端口是否开放。过滤可能来自专业的防火墙设备,路由规则 或者主机上的软件防火墙。unfiltered :未被过滤状态意味着端口可访问,但是nmap无法确定它是开放还是关闭。 只有用于映射防火墙规则集的 ACK 扫描才会把端口分类到这个状态。open | filtered :无法确定端口是开放还是被过滤, 开放的端口不响应就是一个例子。没有响应也可能意味着报文过滤器丢弃了探测报文或者它引发的任何反应。UDP,IP协议,FIN, Null 等扫描会引起。closed|filtered:(关闭或者被过滤的):无法确定端口是关闭的还是被过滤的 |
| 1 | yum install nmap -y |
| 1 2 3 4 5 6 7 8 9 10 |
[root@A ~]# netstat -lntp --inetActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2157/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1930/cupsd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2365/master tcp 0 0 0.0.0.0:13306 0.0.0.0:* LISTEN 21699/mysqld tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 2640/rsync tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 21505/rpcbind [root@A ~]# |
过滤掉监控在127.0.0.1的端口
| 1 2 3 4 5 6 7 8 |
[root@A ~]# netstat -lntp --inet | grep -v 127.0.0.1Active Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2157/sshd tcp 0 0 0.0.0.0:13306 0.0.0.0:* LISTEN 21699/mysqld tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 2640/rsync tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 21505/rpcbind [root@A ~]# |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
[root@B ~]# nmap 10.0.1.161 -p1-65535Starting Nmap 5.51 ( http://nmap.org ) at 2016-12-29 10:11 CSTNmap scan report for 10.0.1.161Host is up (0.00017s latency).Not shown: 65531 closed portsPORT STATE SERVICE22/tcp open ssh111/tcp open rpcbind873/tcp open rsync13306/tcp open unknownMAC Address: 00:0C:29:56:DE:46 (VMware)Nmap done: 1 IP address (1 host up) scanned in 2.49 seconds[root@B ~]# |
如果不加-p1-65535,对于未知服务的端口(A机器的13306端口)就没法扫描到
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
[root@B ~]# nmap 10.0.1.161Starting Nmap 5.51 ( http://nmap.org ) at 2016-12-29 10:12 CSTNmap scan report for 10.0.1.161Host is up (0.000089s latency).Not shown: 997 closed portsPORT STATE SERVICE22/tcp open ssh111/tcp open rpcbind873/tcp open rsyncMAC Address: 00:0C:29:56:DE:46 (VMware)Nmap done: 1 IP address (1 host up) scanned in 0.43 seconds[root@B ~]# |
| 1 2 3 4 5 |
[root@A ~]# nc -l 7777&[1] 21779[root@A ~]# nc -l 8888&[2] 21780[root@A ~]# |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
[root@B ~]# nmap 10.0.1.161 -p20-200,7777,8888Starting Nmap 5.51 ( http://nmap.org ) at 2016-12-29 10:32 CSTNmap scan report for 10.0.1.161Host is up (0.00038s latency).Not shown: 179 closed portsPORT STATE SERVICE22/tcp open ssh111/tcp open rpcbind7777/tcp open cbt8888/tcp open sun-answerbookMAC Address: 00:0C:29:56:DE:46 (VMware)Nmap done: 1 IP address (1 host up) scanned in 0.17 seconds[root@B ~]# |
| 1 | netstat -lnup --inet |grep -v 127.0.0.1 |
| 1 2 3 4 5 6 7 8 9 |
[root@A ~]# netstat -lnup --inet |grep -v 127.0.0.1Active Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name udp 0 0 0.0.0.0:111 0.0.0.0:* 21505/rpcbind udp 0 0 0.0.0.0:631 0.0.0.0:* 1930/cupsd udp 0 0 10.0.1.161:123 0.0.0.0:* 2261/ntpd udp 0 0 0.0.0.0:123 0.0.0.0:* 2261/ntpd udp 0 0 0.0.0.0:904 0.0.0.0:* 21505/rpcbind [root@A ~]# |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
[root@B ~]# nmap -sU 10.0.1.161 -PnStarting Nmap 5.51 ( http://nmap.org ) at 2016-12-29 10:16 CSTStats: 0:12:54 elapsed; 0 hosts completed (1 up), 1 undergoing UDP ScanUDP Scan Timing: About 75.19% done; ETC: 10:33 (0:04:16 remaining)Stats: 0:12:55 elapsed; 0 hosts completed (1 up), 1 undergoing UDP ScanUDP Scan Timing: About 75.29% done; ETC: 10:33 (0:04:15 remaining)Nmap scan report for 10.0.1.161Host is up (0.0011s latency).Not shown: 997 closed portsPORT STATE SERVICE111/udp open rpcbind123/udp open ntp631/udp open|filtered ippMAC Address: 00:0C:29:56:DE:46 (VMware)Nmap done: 1 IP address (1 host up) scanned in 1081.27 seconds[root@B ~]# |
中间用空格分开
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
[root@B ~]# nmap 10.0.1.161 10.0.1.162Starting Nmap 5.51 ( http://nmap.org ) at 2016-12-29 10:18 CSTNmap scan report for 10.0.1.161Host is up (0.000060s latency).Not shown: 997 closed portsPORT STATE SERVICE22/tcp open ssh111/tcp open rpcbind873/tcp open rsyncMAC Address: 00:0C:29:56:DE:46 (VMware)Nmap scan report for 10.0.1.162Host is up (0.0000070s latency).Not shown: 998 closed portsPORT STATE SERVICE22/tcp open ssh111/tcp open rpcbindNmap done: 2 IP addresses (2 hosts up) scanned in 0.26 seconds[root@B ~]# |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
[root@B ~]# nmap 10.0.1.161,162Starting Nmap 5.51 ( http://nmap.org ) at 2016-12-29 10:19 CSTNmap scan report for 10.0.1.161Host is up (0.00025s latency).Not shown: 997 closed portsPORT STATE SERVICE22/tcp open ssh111/tcp open rpcbind873/tcp open rsyncMAC Address: 00:0C:29:56:DE:46 (VMware)Nmap scan report for 10.0.1.162Host is up (0.0000080s latency).Not shown: 998 closed portsPORT STATE SERVICE22/tcp open ssh111/tcp open rpcbindNmap done: 2 IP addresses (2 hosts up) scanned in 0.81 seconds[root@B ~]# |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
[root@B ~]# nmap 10.0.1.161-162Starting Nmap 5.51 ( http://nmap.org ) at 2016-12-29 10:20 CSTNmap scan report for 10.0.1.161Host is up (0.00011s latency).Not shown: 997 closed portsPORT STATE SERVICE22/tcp open ssh111/tcp open rpcbind873/tcp open rsyncMAC Address: 00:0C:29:56:DE:46 (VMware)Nmap scan report for 10.0.1.162Host is up (0.0000030s latency).Not shown: 998 closed portsPORT STATE SERVICE22/tcp open ssh111/tcp open rpcbindNmap done: 2 IP addresses (2 hosts up) scanned in 0.25 seconds[root@B ~]# |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
[root@B ~]# nmap 10.0.3.0/24Starting Nmap 5.51 ( http://nmap.org ) at 2016-12-29 10:21 CSTNmap scan report for 10.0.3.1Host is up (0.020s latency).Not shown: 997 closed portsPORT STATE SERVICE23/tcp open telnet6666/tcp open irc8888/tcp open sun-answerbookNmap scan report for 10.0.3.2Host is up (0.012s latency).Not shown: 997 closed portsPORT STATE SERVICE21/tcp filtered ftp22/tcp filtered ssh23/tcp open telnetNmap scan report for 10.0.3.3Host is up (0.018s latency).Not shown: 997 closed portsPORT STATE SERVICE21/tcp filtered ftp22/tcp filtered ssh23/tcp open telnetNmap done: 256 IP addresses (3 hosts up) scanned in 14.91 seconds[root@B ~]# |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
[root@B ~]# cat ip.txt10.0.1.16110.0.1.162[root@B ~]# nmap -iL ip.txtStarting Nmap 5.51 ( http://nmap.org ) at 2016-12-29 10:23 CSTNmap scan report for 10.0.1.161Host is up (0.00030s latency).Not shown: 997 closed portsPORT STATE SERVICE22/tcp open ssh111/tcp open rpcbind873/tcp open rsyncMAC Address: 00:0C:29:56:DE:46 (VMware)Nmap scan report for 10.0.1.162Host is up (0.0000070s latency).Not shown: 998 closed portsPORT STATE SERVICE22/tcp open ssh111/tcp open rpcbindNmap done: 2 IP addresses (2 hosts up) scanned in 0.68 seconds[root@B ~]# |
| 1 | nmap 10.0.1.161-162 --exclude 10.0.1.162 |
用法如下
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
[root@B ~]# nmap 10.0.1.161-162 --exclude 10.0.1.162Starting Nmap 5.51 ( http://nmap.org ) at 2016-12-29 10:24 CSTNmap scan report for 10.0.1.161Host is up (0.0022s latency).Not shown: 997 closed portsPORT STATE SERVICE22/tcp open ssh111/tcp open rpcbind873/tcp open rsyncMAC Address: 00:0C:29:56:DE:46 (VMware)Nmap done: 1 IP address (1 host up) scanned in 0.53 seconds[root@B ~]# |
| 1 | nmap 10.0.1.161-163 --exclude 10.0.1.162-163 |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
[root@B ~]# nmap 10.0.1.161-163 --exclude 10.0.1.162-163Starting Nmap 5.51 ( http://nmap.org ) at 2016-12-29 10:25 CSTNmap scan report for 10.0.1.161Host is up (0.00023s latency).Not shown: 997 closed portsPORT STATE SERVICE22/tcp open ssh111/tcp open rpcbind873/tcp open rsyncMAC Address: 00:0C:29:56:DE:46 (VMware)Nmap done: 1 IP address (1 host up) scanned in 0.56 seconds[root@B ~]# |
排除分散的,使用逗号隔开
| 1 | nmap 10.0.1.161-163 --exclude 10.0.1.161,10.0.1.163 |
| 1 2 3 4 5 6 7 8 9 10 11 12 |
[root@B ~]# nmap 10.0.1.161-163 --exclude 10.0.1.161,10.0.1.163Starting Nmap 5.51 ( http://nmap.org ) at 2016-12-29 10:27 CSTNmap scan report for 10.0.1.162Host is up (0.0000030s latency).Not shown: 998 closed portsPORT STATE SERVICE22/tcp open ssh111/tcp open rpcbindNmap done: 1 IP address (1 host up) scanned in 0.12 seconds[root@B ~]# |
| 1 | nmap 10.0.1.161-163 --excludefile ex.txt |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
[root@B ~]# cat ex.txt10.0.1.16110.0.1.163[root@B ~]# nmap 10.0.1.161-163 --excludefile ex.txtStarting Nmap 5.51 ( http://nmap.org ) at 2016-12-29 10:29 CSTNmap scan report for 10.0.1.162Host is up (0.0000050s latency).Not shown: 998 closed portsPORT STATE SERVICE22/tcp open ssh111/tcp open rpcbindNmap done: 1 IP address (1 host up) scanned in 0.18 seconds[root@B ~]# |
相关阅读
1
最全整理MySQL高可用架构之——主从复制、故障转移、读写分离、负载均衡