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
總結:用這個命令可以看出那個埠被佔用,開啟那些埠很好用命令
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
總結:用這個命令可以看出那個埠被佔用,開啟那些埠很好用命令
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29065182/viewspace-1701153/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 網路安全netstat監聽網路狀態。
- [網路配置相關]——netstat命令
- Linux基礎命令---netstat顯示網路狀態Linux
- 10 個你需要了解的 Linux 網路和監控命令Linux
- linux效能監控命令Linux
- Linux - netstat命令Linux
- Linux監控命令全解Linux
- Unix/Linux 常用監控命令Linux
- 網路--netstat -an
- Linux之netstat命令Linux
- 注意啦!10 個你需要了解的 Linux 網路和監控命令Linux
- linux網路流量實時監控指令碼Linux指令碼
- 使用netstat檢測及監測網路連線
- Linux系統監控命令薦Linux
- linux監控CPU命令-mpstatLinux
- iOS網路效能監控iOS
- 網路監控工具ntopng
- Linux常見命令:網路相關ping finger nslookup netstat(轉)Linux
- Linux netstat命令詳解Linux
- linux netstat 命令詳解Linux
- Linux 中如何使用 Htop 監控工具?【網路安全】Linux
- Linux下網路流量實時監控工具大全Linux
- 在Linux中,如何實時監控網路流量?Linux
- Linux 常用系統效能監控命令Linux
- Linux系統監控命令之iotopLinux
- OpManager:網路監控的利器
- 12 個網路監控工具
- Linux netstat命令結果分析Linux
- Linux下smokeping網路監控環境部署記錄Linux
- 又一波你可能不知道的 Linux 命令列網路監控工具Linux命令列
- 每天一個 Linux 命令(56): netstat 命令Linux
- 網路監控工作模式:旁路映象、埠映象和旁路監控模式
- 幾個常用的linux效能監控命令Linux
- Linux效能監控,安全等命令集Linux
- 監控 Linux 容器效能的命令列神器Linux命令列
- netstat命令
- 網路螞蟻--會話命令--全過程監控--詳錄 (轉)會話
- Linux技術——netstat命令詳解Linux