自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Linux netstat命令詳解

系統(tǒng) Linux 系統(tǒng)運維
Netstat 命令用于顯示各種網(wǎng)絡(luò)相關(guān)信息,如網(wǎng)絡(luò)連接,路由表,接口狀態(tài) (Interface Statistics),masquerade 連接,多播成員 (Multicast Memberships) 等等。

[[185097]]

簡介

Netstat 命令用于顯示各種網(wǎng)絡(luò)相關(guān)信息,如網(wǎng)絡(luò)連接,路由表,接口狀態(tài) (Interface Statistics),masquerade 連接,多播成員 (Multicast Memberships) 等等。

輸出信息含義

執(zhí)行netstat后,其輸出結(jié)果為

  1. Active Internet connections (w/o servers) 
  2. Proto Recv-Q Send-Q Local Address Foreign Address State 
  3. tcp 0 2 210.34.6.89:telnet 210.34.6.96:2873 ESTABLISHED 
  4. tcp 296 0 210.34.6.89:1165 210.34.6.84:netbios-ssn ESTABLISHED 
  5. tcp 0 0 localhost.localdom:9001 localhost.localdom:1162 ESTABLISHED 
  6. tcp 0 0 localhost.localdom:1162 localhost.localdom:9001 ESTABLISHED 
  7. tcp 0 80 210.34.6.89:1161 210.34.6.10:netbios-ssn CLOSE 
  8.  
  9. Active UNIX domain sockets (w/o servers) 
  10. Proto RefCnt Flags Type State I-Node Path 
  11. unix 1 [ ] STREAM CONNECTED 16178 @000000dd 
  12. unix 1 [ ] STREAM CONNECTED 16176 @000000dc 
  13. unix 9 [ ] DGRAM 5292 /dev/log 
  14. unix 1 [ ] STREAM CONNECTED 16182 @000000df  

從整體上看,netstat的輸出結(jié)果可以分為兩個部分:

一個是Active Internet connections,稱為有源TCP連接,其中"Recv-Q"和"Send-Q"指%0A的是接收隊列和發(fā)送隊列。這些數(shù)字一般都應(yīng)該是0。如果不是則表示軟件包正在隊列中堆積。這種情況只能在非常少的情況見到。

另一個是Active UNIX domain sockets,稱為有源Unix域套接口(和網(wǎng)絡(luò)套接字一樣,但是只能用于本機(jī)通信,性能可以提高一倍)。Proto顯示連接使用的協(xié)議,RefCnt表示連接到本套接口上的進(jìn)程號,Types顯示套接口的類型,State顯示套接口當(dāng)前的狀態(tài),Path表示連接到套接口的其它進(jìn)程使用的路徑名。

常見參數(shù) 

-a (all)顯示所有選項,默認(rèn)不顯示LISTEN相關(guān)
-t (tcp)僅顯示tcp相關(guān)選項
-u (udp)僅顯示udp相關(guān)選項
-n 拒絕顯示別名,能顯示數(shù)字的全部轉(zhuǎn)化成數(shù)字。
-l 僅列出有在 Listen (監(jiān)聽) 的服務(wù)狀態(tài)
-p 顯示建立相關(guān)鏈接的程序名
-r 顯示路由信息,路由表
-e 顯示擴(kuò)展信息,例如uid等
-s 按各個協(xié)議進(jìn)行統(tǒng)計
-c 每隔一個固定時間,執(zhí)行該netstat命令。 

提示:LISTEN和LISTENING的狀態(tài)只有用-a或者-l才能看到

實用命令實例

1.列出所有端口 (包括監(jiān)聽和未監(jiān)聽的)

列出所有端口 netstat -a 

  1. # netstat -a | more 
  2.  Active Internet connections (servers and established) 
  3.  Proto Recv-Q Send-Q Local Address           Foreign Address         State 
  4.  tcp        0      0 localhost:30037         *:*                     LISTEN 
  5.  udp        0      0 *:bootpc                *:* 
  6.   
  7. Active UNIX domain sockets (servers and established) 
  8.  Proto RefCnt Flags       Type       State         I-Node   Path 
  9.  unix  2      [ ACC ]     STREAM     LISTENING     6135     /tmp/.X11-unix/X0 
  10.  unix  2      [ ACC ]     STREAM     LISTENING     5140     /var/run/acpid.socket  

列出所有 tcp 端口 netstat -at

  1. # netstat -at 
  2.  Active Internet connections (servers and established) 
  3.  Proto Recv-Q Send-Q Local Address           Foreign Address         State 
  4.  tcp        0      0 localhost:30037         *:*                     LISTEN 
  5.  tcp        0      0 localhost:ipp           *:*                     LISTEN 
  6.  tcp        0      0 *:smtp                  *:*                     LISTEN 
  7.  tcp6       0      0 localhost:ipp           [::]:*                  LISTEN  

列出所有 udp 端口 netstat -au

  1. # netstat -au 
  2.  Active Internet connections (servers and established) 
  3.  Proto Recv-Q Send-Q Local Address           Foreign Address         State 
  4.  udp        0      0 *:bootpc                *:* 
  5.  udp        0      0 *:49119                 *:* 
  6.  udp        0      0 *:mdns                  *:*  

2. 列出所有處于監(jiān)聽狀態(tài)的 Sockets

只顯示監(jiān)聽端口 netstat -l 

  1. # netstat -l 
  2.  
  3.  Active Internet connections (only servers) 
  4.  Proto Recv-Q Send-Q Local Address           Foreign Address         State 
  5.  tcp        0      0 localhost:ipp           *:*                     LISTEN 
  6.  tcp6       0      0 localhost:ipp           [::]:*                  LISTEN 
  7.  udp        0      0 *:49119                 *:*  

只列出所有監(jiān)聽 tcp 端口 netstat -lt

  1. # netstat -lt 
  2.  Active Internet connections (only servers) 
  3.  Proto Recv-Q Send-Q Local Address           Foreign Address         State 
  4.  tcp        0      0 localhost:30037         *:*                     LISTEN 
  5.  tcp        0      0 *:smtp                  *:*                     LISTEN 
  6.  tcp6       0      0 localhost:ipp           [::]:*                  LISTEN  

只列出所有監(jiān)聽 udp 端口 netstat -lu 

  1. # netstat -lu 
  2.  Active Internet connections (only servers) 
  3.  Proto Recv-Q Send-Q Local Address           Foreign Address         State 
  4.  udp        0      0 *:49119                 *:* 
  5.  udp        0      0 *:mdns                  *:*  

只列出所有監(jiān)聽 UNIX 端口 netstat -lx

  1. # netstat -lx  
  2. Active UNIX domain sockets (only servers) 
  3.  Proto RefCnt Flags       Type       State         I-Node   Path 
  4.  unix  2      [ ACC ]     STREAM     LISTENING     6294     private/maildrop 
  5.  unix  2      [ ACC ]     STREAM     LISTENING     6203     public/cleanup 
  6.  unix  2      [ ACC ]     STREAM     LISTENING     6302     private/ifmail 
  7.  unix  2      [ ACC ]     STREAM     LISTENING     6306     private/bsmtp  

 

責(zé)任編輯:龐桂玉 來源: segmentfault
相關(guān)推薦

2019-07-12 09:23:54

Linux 系統(tǒng) 運維

2021-12-31 13:02:33

netstatLinuxss

2010-06-02 15:37:38

Linux 網(wǎng)絡(luò)性能

2014-06-05 15:06:29

2023-11-27 13:57:00

Linux用法

2014-07-24 11:37:54

LinuxTop命令

2022-09-01 12:17:43

SCSI協(xié)議Linux

2012-05-10 08:46:05

Linuxsort命令

2020-07-20 07:45:00

Linux

2021-04-14 16:06:42

Linuxchattr命令

2020-08-13 07:38:41

Linux screen命令

2011-06-03 09:25:13

netstatDHCP

2011-06-02 14:36:25

Netstat

2011-09-08 11:38:44

2012-05-11 10:07:55

Linuxfind

2012-05-10 08:37:54

Linuxxargs

2021-03-22 10:05:59

netstat命令Linux

2010-06-23 10:03:18

Linux Bash命

2009-11-11 10:24:10

linuxecho命令詳解

2009-07-31 16:14:27

linux cd命令Linux基本命令
點贊
收藏

51CTO技術(shù)棧公眾號