luoluo牛再一次給我展示了他強大的linux能力,現總結下netstat的用法。
首先,看下netstat的man page:
NAME
netstat - Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships
可以看到,netstat命令可以列印網路連接、路由表、介面統計、偽裝連結和多播成員。
SYNOPSIS
netstat [--all|-a] [--numeric|-n] [--tcp|-t] [--udp|-u] [--listening|-l] [--program|-p][--statistics|-s] [--help|-h]
參數解釋:
netstat -a : 顯示所有串連中和等待中的socket狀態
netstat -n : 顯示網路狀態時,以數字表示地址(如localhost表示成127.0.0.1)
netstat -s : 按網路通訊協定分類展示網路統計
netstat -t : 顯示TCP協議網路狀態
netstat -u : 顯示UDP協議網路狀態
netstat -p : 顯示進程名
常用組合:
1.netstat -an (Listing all the LISTENING Ports of TCP and UDP connections)
2.netstat -at (Listing only TCP (Transmission Control Protocol) port connections using netstat -at.)
3.netstat -l (Listing all active listening ports connections with netstat -l.)
4.netstat -tp (Displaying service name with their PID number, using option netstat -tp will display “PID/Program Name”.)
參考:
http://www.tecmint.com/20-netstat-commands-for-linux-network-management/
http://write.blog.csdn.net/postedit/17555445