Netstat 命令用於顯示各類網絡相關信息,如網絡鏈接,路由表,接口狀態 (Interface Statistics),masquerade 鏈接,多播成員 (Multicast Memberships) 等等。mysql
執行netstat後輸出:sql
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 52 VM-f7217532-ce7b-469e-b:ssh 171.8.74.161:fcmsys ESTABLISHED
tcp 0 0 VM-f7217532-ce7b-469e:46277 VM-45a1f60b-551f-4deb:mysql ESTABLISHED
tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:47932 ESTABLISHED
tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:52000 TIME_WAIT
tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:47862 ESTABLISHED
tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:52018 TIME_WAIT
tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:47860 ESTABLISHED
tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:52009 TIME_WAIT
tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:47865 ESTABLISHED
tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:51997 TIME_WAIT
tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:47879 ESTABLISHED
tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:52012 TIME_WAIT
tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:48012 ESTABLISHED
tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:47864 ESTABLISHED
tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:52024 TIME_WAIT
tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:52015 TIME_WAIT
tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:38655 ESTABLISHED
tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:47861 ESTABLISHED
tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:52021 TIME_WAIT 網絡
從總體上看,netstat的輸出結果能夠分爲兩個部分:dom
一個是Active Internet connections,稱爲有源TCP鏈接,其中"Recv-Q"和"Send-Q"指%0A的是接收隊列和發送隊列。這些數字通常都應該是0。若是不是則表示軟件包正在隊列中堆積。這種狀況只能在很是少的狀況見到。ssh
另外一個是Active UNIX domain sockets,稱爲有源Unix域套接口(和網絡套接字同樣,可是隻能用於本機通訊,性能能夠提升一倍)。
Proto顯示鏈接使用的協議,RefCnt表示鏈接到本套接口上的進程號,Types顯示套接口的類型,State顯示套接口當前的狀態,Path表示鏈接到套接口的其它進程使用的路徑名。socket
-a (all)顯示全部選項,默認不顯示LISTEN相關
-t (tcp)僅顯示tcp相關選項
-u (udp)僅顯示udp相關選項
-n 拒絕顯示別名,能顯示數字的所有轉化成數字。
-l 僅列出有在 Listen (監聽) 的服務狀態tcp
-p 顯示創建相關連接的程序名
-r 顯示路由信息,路由表
-e 顯示擴展信息,例如uid等
-s 按各個協議進行統計
-c 每隔一個固定時間,執行該netstat命令。性能
提示:LISTEN和LISTENING的狀態只有用-a或者-l才能看到ui
列出全部端口 netstat -aspa
tcp 0 0 VM-f7217532-ce7b-469e:46277 VM-45a1f60b-551f-4deb:mysql ESTABLISHED tcp 0 0 *:ssh *:* LISTEN tcp 0 0 localhost:smtp *:* LISTEN tcp 0 0 *:mysql *:* LISTEN tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:47932 ESTABLISHED tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:52216 TIME_WAIT tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:47862 ESTABLISHED tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:47860 ESTABLISHED tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:47865 ESTABLISHED tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:47879 ESTABLISHED tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:52210 TIME_WAIT tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:52213 TIME_WAIT tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:48012 ESTABLISHED tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:47864 ESTABLISHED tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:38655 ESTABLISHED tcp 0 0 VM-f7217532-ce7b-469e:mysql VM-31e27f6e-2e5f-4a2f:47861 ESTABLISHED