cooldatabase 2019-04-17
最近,我们就同一主题写了两篇文章。这些文章内容帮助你如何检查远程服务器中给定的端口是否打开。
如果你想 检查远程 Linux 系统上的端口是否打开 请点击链接浏览。如果你想 检查多个远程 Linux 系统上的端口是否打开 请点击链接浏览。如果你想 检查多个远程 Linux 系统上的多个端口状态 请点击链接浏览。
但是本文帮助你检查本地系统上的开放端口列表。
在 Linux 中很少有用于此目的的实用程序。然而,我提供了四个最重要的 Linux 命令来检查这一点。
你可以使用以下四个命令来完成这个工作。这些命令是非常出名的并被 Linux 管理员广泛使用。
netstat
:netstat (“network statistics”) 是一个显示网络连接(进和出)相关信息命令行工具,例如:路由表, 伪装连接,多点传送成员和网络端口。nmap
:Nmap (“Network Mapper”) 是一个网络探索与安全审计的开源工具。它旨在快速扫描大型网络。ss
: ss 被用于转储套接字统计信息。它也可以类似 netstat 使用。相比其他工具它可以展示更多的TCP状态信息。lsof
: lsof 是 List Open File 的缩写. 它用于输出被某个进程打开的所有文件。netstat
是 Network Statistics 的缩写,是一个显示网络连接(进和出)相关信息命令行工具,例如:路由表、伪装连接、多播成员和网络端口。
它可以列出所有的 tcp、udp 连接和所有的 unix 套接字连接。
它用于发现发现网络问题,确定网络连接数量。
<span class="com">#</span><span class="pln"> </span><span class="kwd">netstat</span><span class="pln"> </span><span class="pun">-</span><span class="pln">tplugn</span>
<span class="typ">Active</span><span class="pln"> </span><span class="typ">Internet</span><span class="pln"> connections </span><span class="pun">(</span><span class="pln">only servers</span><span class="pun">)</span>
<span class="typ">Proto</span><span class="pln"> </span><span class="typ">Recv</span><span class="pun">-</span><span class="pln">Q </span><span class="typ">Send</span><span class="pun">-</span><span class="pln">Q </span><span class="typ">Local</span><span class="pln"> </span><span class="typ">Address</span><span class="pln"> </span><span class="typ">Foreign</span><span class="pln"> </span><span class="typ">Address</span><span class="pln"> </span><span class="typ">State</span><span class="pln"> PID</span><span class="pun">/</span><span class="typ">Program</span><span class="pln"> name</span>
<span class="pln">tcp </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:</span><span class="lit">25</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:*</span><span class="pln"> LISTEN </span><span class="lit">2038</span><span class="pun">/</span><span class="pln">master</span>
<span class="pln">tcp </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="lit">127.0</span><span class="pun">.</span><span class="lit">0.1</span><span class="pun">:</span><span class="lit">199</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:*</span><span class="pln"> LISTEN </span><span class="lit">1396</span><span class="pun">/</span><span class="pln">snmpd</span>
<span class="pln">tcp </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:</span><span class="lit">80</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:*</span><span class="pln"> LISTEN </span><span class="lit">1398</span><span class="pun">/</span><span class="pln">httpd</span>
<span class="pln">tcp </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:</span><span class="lit">22</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:*</span><span class="pln"> LISTEN </span><span class="lit">1388</span><span class="pun">/</span><span class="kwd">sshd</span>
<span class="pln">tcp6 </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="pun">:::</span><span class="lit">25</span><span class="pln"> </span><span class="pun">:::*</span><span class="pln"> LISTEN </span><span class="lit">2038</span><span class="pun">/</span><span class="pln">master</span>
<span class="pln">tcp6 </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="pun">:::</span><span class="lit">22</span><span class="pln"> </span><span class="pun">:::*</span><span class="pln"> LISTEN </span><span class="lit">1388</span><span class="pun">/</span><span class="kwd">sshd</span>
<span class="pln">udp </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:</span><span class="lit">39136</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:*</span><span class="pln"> </span><span class="lit">1396</span><span class="pun">/</span><span class="pln">snmpd</span>
<span class="pln">udp </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:</span><span class="lit">56130</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:*</span><span class="pln"> </span><span class="lit">1396</span><span class="pun">/</span><span class="pln">snmpd</span>
<span class="pln">udp </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:</span><span class="lit">40105</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:*</span><span class="pln"> </span><span class="lit">1396</span><span class="pun">/</span><span class="pln">snmpd</span>
<span class="pln">udp </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:</span><span class="lit">11584</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:*</span><span class="pln"> </span><span class="lit">1396</span><span class="pun">/</span><span class="pln">snmpd</span>
<span class="pln">udp </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:</span><span class="lit">30105</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:*</span><span class="pln"> </span><span class="lit">1396</span><span class="pun">/</span><span class="pln">snmpd</span>
<span class="pln">udp </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:</span><span class="lit">50656</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:*</span><span class="pln"> </span><span class="lit">1396</span><span class="pun">/</span><span class="pln">snmpd</span>
<span class="pln">udp </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:</span><span class="lit">1632</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:*</span><span class="pln"> </span><span class="lit">1396</span><span class="pun">/</span><span class="pln">snmpd</span>
<span class="pln">udp </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:</span><span class="lit">28265</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:*</span><span class="pln"> </span><span class="lit">1396</span><span class="pun">/</span><span class="pln">snmpd</span>
<span class="pln">udp </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:</span><span class="lit">40764</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:*</span><span class="pln"> </span><span class="lit">1396</span><span class="pun">/</span><span class="pln">snmpd</span>
<span class="pln">udp </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="lit">10.90</span><span class="pun">.</span><span class="lit">56.21</span><span class="pun">:</span><span class="lit">123</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:*</span><span class="pln"> </span><span class="lit">895</span><span class="pun">/</span><span class="pln">ntpd</span>
<span class="pln">udp </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="lit">127.0</span><span class="pun">.</span><span class="lit">0.1</span><span class="pun">:</span><span class="lit">123</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:*</span><span class="pln"> </span><span class="lit">895</span><span class="pun">/</span><span class="pln">ntpd</span>
<span class="pln">udp </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:</span><span class="lit">123</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:*</span><span class="pln"> </span><span class="lit">895</span><span class="pun">/</span><span class="pln">ntpd</span>
<span class="pln">udp </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:</span><span class="lit">53390</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:*</span><span class="pln"> </span><span class="lit">1396</span><span class="pun">/</span><span class="pln">snmpd</span>
<span class="pln">udp </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:</span><span class="lit">161</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:*</span><span class="pln"> </span><span class="lit">1396</span><span class="pun">/</span><span class="pln">snmpd</span>
<span class="pln">udp6 </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="pun">:::</span><span class="lit">123</span><span class="pln"> </span><span class="pun">:::*</span><span class="pln"> </span><span class="lit">895</span><span class="pun">/</span><span class="pln">ntpd</span>
<span class="typ">IPv6</span><span class="pun">/</span><span class="typ">IPv4</span><span class="pln"> </span><span class="typ">Group</span><span class="pln"> </span><span class="typ">Memberships</span>
<span class="typ">Interface</span><span class="pln"> </span><span class="typ">RefCnt</span><span class="pln"> </span><span class="typ">Group</span>
<span class="pun">---------------</span><span class="pln"> </span><span class="pun">------</span><span class="pln"> </span><span class="pun">---------------------</span>
<span class="pln">lo </span><span class="lit">1</span><span class="pln"> </span><span class="lit">224.0</span><span class="pun">.</span><span class="lit">0.1</span>
<span class="pln">eth0 </span><span class="lit">1</span><span class="pln"> </span><span class="lit">224.0</span><span class="pun">.</span><span class="lit">0.1</span>
<span class="pln">lo </span><span class="lit">1</span><span class="pln"> ff02</span><span class="pun">::</span><span class="lit">1</span>
<span class="pln">lo </span><span class="lit">1</span><span class="pln"> ff01</span><span class="pun">::</span><span class="lit">1</span>
<span class="pln">eth0 </span><span class="lit">1</span><span class="pln"> ff02</span><span class="pun">::</span><span class="lit">1</span>
<span class="pln">eth0 </span><span class="lit">1</span><span class="pln"> ff01</span><span class="pun">::</span><span class="lit">1</span>
你也可以使用下面的命令检查特定的端口。
<span class="com">#</span><span class="pln"> </span><span class="com">#</span><span class="pln"> </span><span class="kwd">netstat</span><span class="pln"> </span><span class="pun">-</span><span class="pln">tplugn </span><span class="pun">|</span><span class="pln"> </span><span class="kwd">grep</span><span class="pln"> </span><span class="pun">:</span><span class="lit">22</span>
<span class="pln">tcp </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:</span><span class="lit">22</span><span class="pln"> </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:*</span><span class="pln"> LISTEN </span><span class="lit">1388</span><span class="pun">/</span><span class="kwd">sshd</span>
<span class="pln">tcp6 </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="pun">:::</span><span class="lit">22</span><span class="pln"> </span><span class="pun">:::*</span><span class="pln"> LISTEN </span><span class="lit">1388</span><span class="pun">/</span><span class="kwd">sshd</span>
ss
被用于转储套接字统计信息。它也可以显示类似 netstat
的信息。相比其他工具它可以展示更多的 TCP 状态信息。
<span class="com">#</span><span class="pln"> </span><span class="kwd">ss</span><span class="pln"> </span><span class="pun">-</span><span class="pln">lntu</span>
<span class="typ">Netid</span><span class="pln"> </span><span class="typ">State</span><span class="pln"> </span><span class="typ">Recv</span><span class="pun">-</span><span class="pln">Q </span><span class="typ">Send</span><span class="pun">-</span><span class="pln">Q </span><span class="typ">Local</span><span class="pln"> </span><span class="typ">Address</span><span class="pun">:</span><span class="typ">Port</span><span class="pln"> </span><span class="typ">Peer</span><span class="pln"> </span><span class="typ">Address</span><span class="pun">:</span><span class="typ">Port</span>
<span class="pln">udp UNCONN </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="pun">*:</span><span class="lit">39136</span><span class="pln"> </span><span class="pun">*:*</span>
<span class="pln">udp UNCONN </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="pun">*:</span><span class="lit">56130</span><span class="pln"> </span><span class="pun">*:*</span>
<span class="pln">udp UNCONN </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="pun">*:</span><span class="lit">40105</span><span class="pln"> </span><span class="pun">*:*</span>
<span class="pln">udp UNCONN </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="pun">*:</span><span class="lit">11584</span><span class="pln"> </span><span class="pun">*:*</span>
<span class="pln">udp UNCONN </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="pun">*:</span><span class="lit">30105</span><span class="pln"> </span><span class="pun">*:*</span>
<span class="pln">udp UNCONN </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="pun">*:</span><span class="lit">50656</span><span class="pln"> </span><span class="pun">*:*</span>
<span class="pln">udp UNCONN </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="pun">*:</span><span class="lit">1632</span><span class="pln"> </span><span class="pun">*:*</span>
<span class="pln">udp UNCONN </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="pun">*:</span><span class="lit">28265</span><span class="pln"> </span><span class="pun">*:*</span>
<span class="pln">udp UNCONN </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="pun">*:</span><span class="lit">40764</span><span class="pln"> </span><span class="pun">*:*</span>
<span class="pln">udp UNCONN </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="lit">10.90</span><span class="pun">.</span><span class="lit">56.21</span><span class="pun">:</span><span class="lit">123</span><span class="pln"> </span><span class="pun">*:*</span>
<span class="pln">udp UNCONN </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="lit">127.0</span><span class="pun">.</span><span class="lit">0.1</span><span class="pun">:</span><span class="lit">123</span><span class="pln"> </span><span class="pun">*:*</span>
<span class="pln">udp UNCONN </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="pun">*:</span><span class="lit">123</span><span class="pln"> </span><span class="pun">*:*</span>
<span class="pln">udp UNCONN </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="pun">*:</span><span class="lit">53390</span><span class="pln"> </span><span class="pun">*:*</span>
<span class="pln">udp UNCONN </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="pun">*:</span><span class="lit">161</span><span class="pln"> </span><span class="pun">*:*</span>
<span class="pln">udp UNCONN </span><span class="lit">0</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="pun">:::</span><span class="lit">123</span><span class="pln"> </span><span class="pun">:::*</span>
<span class="pln">tcp LISTEN </span><span class="lit">0</span><span class="pln"> </span><span class="lit">100</span><span class="pln"> </span><span class="pun">*:</span><span class="lit">25</span><span class="pln"> </span><span class="pun">*:*</span>
<span class="pln">tcp LISTEN </span><span class="lit">0</span><span class="pln"> </span><span class="lit">128</span><span class="pln"> </span><span class="lit">127.0</span><span class="pun">.</span><span class="lit">0.1</span><span class="pun">:</span><span class="lit">199</span><span class="pln"> </span><span class="pun">*:*</span>
<span class="pln">tcp LISTEN </span><span class="lit">0</span><span class="pln"> </span><span class="lit">128</span><span class="pln"> </span><span class="pun">*:</span><span class="lit">80</span><span class="pln"> </span><span class="pun">*:*</span>
<span class="pln">tcp LISTEN </span><span class="lit">0</span><span class="pln"> </span><span class="lit">128</span><span class="pln"> </span><span class="pun">*:</span><span class="lit">22</span><span class="pln"> </span><span class="pun">*:*</span>
<span class="pln">tcp LISTEN </span><span class="lit">0</span><span class="pln"> </span><span class="lit">100</span><span class="pln"> </span><span class="pun">:::</span><span class="lit">25</span><span class="pln"> </span><span class="pun">:::*</span>
<span class="pln">tcp LISTEN </span><span class="lit">0</span><span class="pln"> </span><span class="lit">128</span><span class="pln"> </span><span class="pun">:::</span><span class="lit">22</span><span class="pln"> </span><span class="pun">:::*</span>
你也可以使用下面的命令检查特定的端口。
<span class="com">#</span><span class="pln"> </span><span class="com">#</span><span class="pln"> </span><span class="kwd">ss</span><span class="pln"> </span><span class="pun">-</span><span class="pln">lntu </span><span class="pun">|</span><span class="pln"> </span><span class="kwd">grep</span><span class="pln"> </span><span class="str">':25'</span>
<span class="pln">tcp LISTEN </span><span class="lit">0</span><span class="pln"> </span><span class="lit">100</span><span class="pln"> </span><span class="pun">*:</span><span class="lit">25</span><span class="pln"> </span><span class="pun">*:*</span>
<span class="pln">tcp LISTEN </span><span class="lit">0</span><span class="pln"> </span><span class="lit">100</span><span class="pln"> </span><span class="pun">:::</span><span class="lit">25</span><span class="pln"> </span><span class="pun">:::*</span>
Nmap (“Network Mapper”) 是一个网络探索与安全审计的开源工具。它旨在快速扫描大型网络,当然它也可以工作在独立主机上。
Nmap 使用裸 IP 数据包以一种新颖的方式来确定网络上有哪些主机可用,这些主机提供什么服务(应用程序名称和版本),它们运行什么操作系统(版本),使用什么类型的数据***滤器/防火墙,以及许多其他特征。
虽然 Nmap 通常用于安全审计,但许多系统和网络管理员发现它对于日常工作也非常有用,例如网络资产清点、管理服务升级计划以及监控主机或服务正常运行时间。
<span class="com">#</span><span class="pln"> </span><span class="kwd">nmap</span><span class="pln"> </span><span class="pun">-</span><span class="pln">sTU </span><span class="pun">-</span><span class="pln">O localhost</span>
<span class="typ">Starting</span><span class="pln"> </span><span class="typ">Nmap</span><span class="pln"> </span><span class="lit">6.40</span><span class="pln"> </span><span class="pun">(</span><span class="pln"> http</span><span class="pun">:</span><span class="com">//nmap.org ) at 2019-03-20 09:57 CDT</span>
<span class="typ">Nmap</span><span class="pln"> scan report </span><span class="kwd">for</span><span class="pln"> localhost </span><span class="pun">(</span><span class="lit">127.0</span><span class="pun">.</span><span class="lit">0.1</span><span class="pun">)</span>
<span class="typ">Host</span><span class="pln"> </span><span class="kwd">is</span><span class="pln"> up </span><span class="pun">(</span><span class="lit">0.00028s</span><span class="pln"> latency</span><span class="pun">).</span>
<span class="typ">Other</span><span class="pln"> addresses </span><span class="kwd">for</span><span class="pln"> localhost </span><span class="pun">(</span><span class="kwd">not</span><span class="pln"> scanned</span><span class="pun">):</span><span class="pln"> </span><span class="lit">127.0</span><span class="pun">.</span><span class="lit">0.1</span>
<span class="typ">Not</span><span class="pln"> shown</span><span class="pun">:</span><span class="pln"> </span><span class="lit">1994</span><span class="pln"> closed ports</span>
<span class="pln">PORT STATE SERVICE</span>
<span class="lit">22</span><span class="pun">/</span><span class="pln">tcp open </span><span class="kwd">ssh</span>
<span class="lit">25</span><span class="pun">/</span><span class="pln">tcp open smtp</span>
<span class="lit">80</span><span class="pun">/</span><span class="pln">tcp open http</span>
<span class="lit">199</span><span class="pun">/</span><span class="pln">tcp open smux</span>
<span class="lit">123</span><span class="pun">/</span><span class="pln">udp open ntp</span>
<span class="lit">161</span><span class="pun">/</span><span class="pln">udp open snmp</span>
<span class="typ">Device</span><span class="pln"> type</span><span class="pun">:</span><span class="pln"> general purpose</span>
<span class="typ">Running</span><span class="pun">:</span><span class="pln"> </span><span class="typ">Linux</span><span class="pln"> </span><span class="lit">3.X</span>
<span class="pln">OS CPE</span><span class="pun">:</span><span class="pln"> cpe</span><span class="pun">:/</span><span class="pln">o</span><span class="pun">:</span><span class="pln">linux</span><span class="pun">:</span><span class="pln">linux_kernel</span><span class="pun">:</span><span class="lit">3</span>
<span class="pln">OS details</span><span class="pun">:</span><span class="pln"> </span><span class="typ">Linux</span><span class="pln"> </span><span class="lit">3.7</span><span class="pln"> </span><span class="pun">-</span><span class="pln"> </span><span class="lit">3.9</span>
<span class="typ">Network</span><span class="pln"> </span><span class="typ">Distance</span><span class="pun">:</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> hops</span>
<span class="pln">OS detection performed</span><span class="pun">.</span><span class="pln"> </span><span class="typ">Please</span><span class="pln"> report any incorrect results at http</span><span class="pun">:</span><span class="com">//nmap.org/submit/ .</span>
<span class="typ">Nmap</span><span class="pln"> </span><span class="kwd">done</span><span class="pun">:</span><span class="pln"> </span><span class="lit">1</span><span class="pln"> IP address </span><span class="pun">(</span><span class="lit">1</span><span class="pln"> host up</span><span class="pun">)</span><span class="pln"> scanned </span><span class="kwd">in</span><span class="pln"> </span><span class="lit">1.93</span><span class="pln"> seconds</span>
你也可以使用下面的命令检查特定的端口。
<span class="com">#</span><span class="pln"> </span><span class="kwd">nmap</span><span class="pln"> </span><span class="pun">-</span><span class="pln">sTU </span><span class="pun">-</span><span class="pln">O localhost </span><span class="pun">|</span><span class="pln"> </span><span class="kwd">grep</span><span class="pln"> </span><span class="lit">123</span>
<span class="lit">123</span><span class="pun">/</span><span class="pln">udp open ntp</span>
它向你显示系统上打开的文件列表以及打开它们的进程。还会向你显示与文件相关的其他信息。
<span class="com">#</span><span class="pln"> </span><span class="kwd">lsof</span><span class="pln"> </span><span class="pun">-</span><span class="pln">i</span>
<span class="pln">COMMAND PID USER FD TYPE DEVICE SIZE</span><span class="pun">/</span><span class="pln">OFF NODE NAME</span>
<span class="pln">ntpd </span><span class="lit">895</span><span class="pln"> ntp </span><span class="lit">16u</span><span class="pln"> </span><span class="typ">IPv4</span><span class="pln"> </span><span class="lit">18481</span><span class="pln"> </span><span class="lit">0t0</span><span class="pln"> UDP </span><span class="pun">*:</span><span class="pln">ntp</span>
<span class="pln">ntpd </span><span class="lit">895</span><span class="pln"> ntp </span><span class="lit">17u</span><span class="pln"> </span><span class="typ">IPv6</span><span class="pln"> </span><span class="lit">18482</span><span class="pln"> </span><span class="lit">0t0</span><span class="pln"> UDP </span><span class="pun">*:</span><span class="pln">ntp</span>
<span class="pln">ntpd </span><span class="lit">895</span><span class="pln"> ntp </span><span class="lit">18u</span><span class="pln"> </span><span class="typ">IPv4</span><span class="pln"> </span><span class="lit">18487</span><span class="pln"> </span><span class="lit">0t0</span><span class="pln"> UDP localhost</span><span class="pun">:</span><span class="pln">ntp</span>
<span class="pln">ntpd </span><span class="lit">895</span><span class="pln"> ntp </span><span class="lit">20u</span><span class="pln"> </span><span class="typ">IPv4</span><span class="pln"> </span><span class="lit">23020</span><span class="pln"> </span><span class="lit">0t0</span><span class="pln"> UDP </span><span class="typ">CentOS7</span><span class="pun">.</span><span class="lit">2daygeek</span><span class="pun">.</span><span class="pln">com</span><span class="pun">:</span><span class="pln">ntp</span>
<span class="kwd">sshd</span><span class="pln"> </span><span class="lit">1388</span><span class="pln"> root </span><span class="lit">3u</span><span class="pln"> </span><span class="typ">IPv4</span><span class="pln"> </span><span class="lit">20065</span><span class="pln"> </span><span class="lit">0t0</span><span class="pln"> TCP </span><span class="pun">*:</span><span class="kwd">ssh</span><span class="pln"> </span><span class="pun">(</span><span class="pln">LISTEN</span><span class="pun">)</span>
<span class="kwd">sshd</span><span class="pln"> </span><span class="lit">1388</span><span class="pln"> root </span><span class="lit">4u</span><span class="pln"> </span><span class="typ">IPv6</span><span class="pln"> </span><span class="lit">20067</span><span class="pln"> </span><span class="lit">0t0</span><span class="pln"> TCP </span><span class="pun">*:</span><span class="kwd">ssh</span><span class="pln"> </span><span class="pun">(</span><span class="pln">LISTEN</span><span class="pun">)</span>
<span class="pln">snmpd </span><span class="lit">1396</span><span class="pln"> root </span><span class="lit">6u</span><span class="pln"> </span><span class="typ">IPv4</span><span class="pln"> </span><span class="lit">22739</span><span class="pln"> </span><span class="lit">0t0</span><span class="pln"> UDP </span><span class="pun">*:</span><span class="pln">snmp</span>
<span class="pln">snmpd </span><span class="lit">1396</span><span class="pln"> root </span><span class="lit">7u</span><span class="pln"> </span><span class="typ">IPv4</span><span class="pln"> </span><span class="lit">22729</span><span class="pln"> </span><span class="lit">0t0</span><span class="pln"> UDP </span><span class="pun">*:</span><span class="lit">40105</span>
<span class="pln">snmpd </span><span class="lit">1396</span><span class="pln"> root </span><span class="lit">8u</span><span class="pln"> </span><span class="typ">IPv4</span><span class="pln"> </span><span class="lit">22730</span><span class="pln"> </span><span class="lit">0t0</span><span class="pln"> UDP </span><span class="pun">*:</span><span class="lit">50656</span>
<span class="pln">snmpd </span><span class="lit">1396</span><span class="pln"> root </span><span class="lit">9u</span><span class="pln"> </span><span class="typ">IPv4</span><span class="pln"> </span><span class="lit">22731</span><span class="pln"> </span><span class="lit">0t0</span><span class="pln"> UDP </span><span class="pun">*:</span><span class="pln">pammratc</span>
<span class="pln">snmpd </span><span class="lit">1396</span><span class="pln"> root </span><span class="lit">10u</span><span class="pln"> </span><span class="typ">IPv4</span><span class="pln"> </span><span class="lit">22732</span><span class="pln"> </span><span clas