netstat 用於顯示各種網絡相關信息,如網絡連接,路由表,接口狀態 (Interface Statistics),masquerade 連接,多播成員 (Multicast Memberships) 等等
grid_hd@hadoop1:~$ netstat -h usage: netstat [-vWeenNcCF] [<Af>] -r netstat {-V|--version|-h|--help} netstat [-vWnNcaeol] [<Socket> ...] netstat { [-vWeenNac] -i | [-cWnNe] -M | -s }
-r, --route display routing table ##顯示路由表
-i, --interfaces display interface table
-g, --groups display multicast group memberships
-s, --statistics display networking statistics (like SNMP) 顯示網絡統計信息
-v, --verbose be verbose
-W, --wide don't truncate IP addresses -n, --numeric don't resolve names ##不解析名字,以數字形式顯示(可以看到端口) --numeric-hosts don't resolve host names --numeric-ports don't resolve port names --numeric-users don't resolve user names -N, --symbolic resolve hardware names -e, --extend display other/more information
-p, --programs display PID/Program name for sockets ##
-c, --continuous continuous listing
-l, --listening display listening server sockets -a, --all, --listening display all sockets (default: connected) -o, --timers display timers -F, --fib display Forwarding Information Base (default) -C, --cache display routing cache instead of FIB
<Socket>={-t|--tcp} {-u|--udp} {-w|--raw} {-x|--unix} --ax25 --ipx --netrom <AF>=Use '-6|-4' or '-A <af>' or '--<af>'; default: inet List of possible address families (which support routing): inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25) netrom (AMPR NET/ROM) ipx (Novell IPX) ddp (Appletalk DDP) x25 (CCITT X.25)
參考文章 http://www.cnblogs.com/ggjucheng/archive/2012/01/08/2316661.html 常見參數 -a (all) 顯示所有選項,默認不顯示LISTEN相關 -p 顯示建立相關鏈接的程序名 提示:LISTEN和LISTENING的狀態只有用-a或者-l才能看到
列出所有tcp端口sudo netstat -at (以root用戶運行) 轉化成數字形式顯示sudo netstat -natp (以root用戶運行)
顯示53端口的占用情況(在tcp, udp中找 -l 顯示正在監聽的sockets)
顯示53端口的占用情況(顯示所有的連接)
列出所有連接情況(並顯示進程名) 從整體上看,netstat的輸出結果可以分為兩個部分: 一個是Active Internet connections,稱為有源TCP、UDP連接,其中"Recv-Q"和"Send-Q"指%0A的是接收隊列和發送隊列。 這些數字一般都應該是0。如果不是則表示軟件包正在隊列中堆積。這種情況只能在非常少的情況見到。
另一個是Active UNIX domain sockets,稱為有源Unix域套接口(和網絡套接字一樣,但是只能用於本機通信,性能可以提高一倍)。 RefCnt 表示連接到本套接口上的進程號 Types 顯示套接口的類型 State 顯示套接口當前的狀態 Path 表示連接到套接口的其它進程使用的路徑名 |