2021-05-12 14:32:11
Linux 網路監控命令(netstat)
netstat命令
netstat命令用來列印Linux中網路系統的狀態資訊,可讓你得知整個Linux系統的網路情況。
netstat(選項)
-a或--all:顯示所有連線中的Socket;
-A<網路型別>或--<網路型別>:列出該網路型別連線中的相關地址;
-c或--continuous:持續列出網路狀態;
-C或--cache:顯示路由器設定的快取資訊;
-e或--extend:顯示網路其他相關資訊;
-F或--fib:顯示FIB;
-g或--groups:顯示多重廣播功能群組組員名單;
-h或--help:線上幫助;
-i或--interfaces:顯示網路介面資訊表單;
-l或--listening:顯示監控中的伺服器的Socket;
-M或--masquerade:顯示偽裝的網路連線;
-n或--numeric:直接使用ip地址,而不通過域名伺服器;
-N或--netlink或--symbolic:顯示網路硬體外圍裝置的符號連線名稱;
-o或--timers:顯示計時器;
-p或--programs:顯示正在使用Socket的程式識別碼和程式名稱;
-r或--route:顯示Routing Table;
-s或--statistice:顯示網路工作資訊統計表;
-t或--tcp:顯示TCP傳輸協定的連線狀況;
-u或--udp:顯示UDP傳輸協定的連線狀況;
-v或--verbose:顯示指令執行過程;
-V或--version:顯示版本資訊;
-w或--raw:顯示RAW傳輸協定的連線狀況;
-x或--unix:此引數的效果和指定"-A unix"引數相同;
--ip或--inet:此引數的效果和指定"-A inet"引數相同。
列出所有埠
[root@smsplatform01 ~]# netstat -a
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 localhost:ipp *:* LISTEN
tcp 0 0 localhost:smtp *:* LISTEN
tcp 0 0 *:40904 *:* LISTEN
tcp 0 0 localhost:memcache *:* LISTEN
tcp 0 0 *:sunrpc *:* LISTEN
tcp 0 0 smsplatform01:ncube-lm *:* LISTEN
tcp 0 0 *:ssh *:*
列出所有已經再監聽埠
[root@smsplatform01 ~]# netstat -al
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 localhost:ipp *:* LISTEN
tcp 0 0 localhost:smtp *:* LISTEN
tcp 0 0 *:40904 *:* LISTEN
tcp 0 0 localhost:memcache *:* LISTEN
tcp 0 0 *:sunrpc *:* LISTEN
tcp 0 0 smsplatform01:ncube-lm *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
列出所有的tcp埠
[root@smsplatform01 ~]# netstat -at
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 localhost:ipp *:* LISTEN
tcp 0 0 localhost:smtp *:* LISTEN
tcp 0 0 *:40904 *:* LISTEN
tcp 0 0 localhost:memcache *:* LISTEN
tcp 0 0 *:sunrpc *:* LISTEN
tcp 0 0 smsplatform01:ncube-lm *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 smsplatform01:61004 smsplatform02:ncube-lm ESTABLISHED
tcp 0 0 smsplatform01:61006 smsplatform02:ncube-lm ESTABLISHED
tcp 0 0 smsplatform01:61007 smsplatform02:ncube-lm ESTABLISHED
tcp 0 0 smsplatform01:61005 smsplatform02:ncube-lm ESTABLISHED
tcp 0 0 smsplatform01:ssh 172.20.1.31:13120 ESTABLISHED
tcp 0 0 smsplatform01:ncube-lm smsplatform01:59954 ESTABLISHED
tcp 0 0 smsplatform01:ssh 172.20.1.31:http-wmap ESTABLISHED
tcp 0 0 smsplatform01:59954 smsplatform01:ncube-lm ESTABLISHED
列出所有的udp埠
[root@smsplatform01 ~]# netstat -au
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
udp 0 0 *:sunrpc *:*
udp 0 0 *:ipp *:*
udp 0 0 *:rushd *:*
udp 0 0 localhost:745 *:*
udp 0 0 *:17343 *:*
udp 0 0 *:11648 *:*
顯示正在使用Socket的程式識別碼和程式名稱
[root@smsplatform01 ~]# netstat -p
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 smsplatform01:61004 smsplatform02:ncube-lm ESTABLISHED 6569/ora_arc0_oracl
tcp 0 0 smsplatform01:61006 smsplatform02:ncube-lm ESTABLISHED 6577/ora_nsa2_oracl
tcp 0 0 smsplatform01:61007 smsplatform02:ncube-lm ESTABLISHED 6573/ora_arc2_oracl
tcp 0 0 smsplatform01:61005 smsplatform02:ncube-lm ESTABLISHED 6575/ora_arc3_oracl
tcp 0 0 smsplatform01:ssh 172.20.1.31:13120 ESTABLISHED 37508/sshd
tcp 0 0 smsplatform01:ncube-lm smsplatform01:59954 ESTABLISHED 6155/tnslsnr
tcp 0 0 smsplatform01:ssh 172.20.1.31:http-wmap ESTABLISHED 37197/sshd
tcp 0 0 smsplatform01:59954 smsplatform01:ncube-lm ESTABLISHED 6313/ora_pmon_oracl
直接使用ip地址,而不通過域名伺服器;
[root@smsplatform01 ~]# netstat -n
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 172.20.1.34:61004 172.20.1.35:1521 ESTABLISHED
tcp 0 0 172.20.1.34:61006 172.20.1.35:1521 ESTABLISHED
tcp 0 0 172.20.1.34:61007 172.20.1.35:1521 ESTABLISHED
tcp 0 0 172.20.1.34:61005 172.20.1.35:1521 ESTABLISHED
tcp 0 224 172.20.1.34:22 172.20.1.31:13120 ESTABLISHED
tcp 0 0 172.20.1.34:1521 172.20.1.34:59954 ESTABLISHED
tcp 0 0 172.20.1.34:22 172.20.1.31:8990 ESTABLISHED
tcp 0 0 172.20.1.34:59954 172.20.1.34:1521 ESTABLISHED
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags Type State I-Node Path
unix 18 [ ] DGRAM 20061 /dev/log
unix 2 [ ] DGRAM 17931 @/org/kernel/udev/udevd
unix 2 [ ] DGRAM 20251 @/org/freedesktop/hal/udev_event
unix 3 [ ] STREAM CONNECTED 20465
unix 3 [ ] STREAM CONNECTED 8890 @/tmp/.X11-unix/X0
unix 3 [ ] STREAM CONNECTED 17266
unix 3 [ ] STREAM CONNECTED 11029 /tmp/orbit-gdm/linc-1a88-0-7b17782b4443e
unix 3 [ ] STREAM CONNECTED 20121
unix 3 [ ] STREAM CONNECTED 20455
顯示所有在用埠tcp程式名
[root@smsplatform01 ~]# netstat -antp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 5731/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 5993/master
tcp 0 0 0.0.0.0:40904 0.0.0.0:* LISTEN 5657/rpc.statd
tcp 0 0 127.0.0.1:11211 0.0.0.0:* LISTEN 37557/memcached
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 5609/rpcbind
tcp 0 0 172.20.1.34:1521 0.0.0.0:* LISTEN 6155/tnslsnr
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 5881/sshd
tcp 0 0 172.20.1.34:61004 172.20.1.35:1521 ESTABLISHED 6569/ora_arc0_oracl
tcp 0 0 172.20.1.34:61006 172.20.1.35:1521 ESTABLISHED 6577/ora_nsa2_oracl
tcp 0 0 172.20.1.34:61007 172.20.1.35:1521 ESTABLISHED 6573/ora_arc2_oracl
tcp 0 0 172.20.1.34:61005 172.20.1.35:1521 ESTABLISHED 6575/ora_arc3_oracl
tcp 0 672 172.20.1.34:22 172.20.1.31:13120 ESTABLISHED 37508/sshd
tcp 0 0 172.20.1.34:1521 172.20.1.34:59954 ESTABLISHED 6155/tnslsnr
tcp 0 0 172.20.1.34:22 172.20.1.31:8990 ESTABLISHED 37197/sshd
tcp 0 0 172.20.1.34:59954 172.20.1.34:1521 ESTABLISHED 6313/ora_pmon_oracl
tcp 0 0 ::1:631 :::* LISTEN 5731/cupsd
tcp 0 0 :::11614 :::* LISTEN 6347/ora_d000_oracl
tcp 0 0 :::25449 :::* LISTEN 5657/rpc.statd
tcp 0 0 :::111 :::* LISTEN 5609/rpcbind
tcp 0 0 :::22 :::* LISTEN 5881/sshd
總結:用這個命令可以看出那個埠被占用,開啟那些埠很好用命令
Linux netstat命令詳解 http://www.linuxidc.com/Linux/2012-12/75667.htm
使用netstat檢測及監測網路連線 http://www.linuxidc.com/Linux/2014-09/106497.htm
Netstat 的10個基本用法 http://www.linuxidc.com/Linux/2014-01/94644.htm
Linux netstat命令 http://www.linuxidc.com/Linux/2013-06/85528.htm
Linux命令:service & netstat http://www.linuxidc.com/Linux/2011-12/48395.htm
Linux下用netstat命令檢視網路負載狀況的一條語句 http://www.linuxidc.com/Linux/2011-08/41429.htm
LPI認證考試學習之Linux netstat 命令詳解 http://www.linuxidc.com/Linux/2009-12/23197.htm
本文永久更新連結地址:http://www.linuxidc.com/Linux/2015-06/118926.htm
相關文章