溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

如何在Linux中使用netstat命令

發(fā)布時(shí)間:2021-03-15 16:55:17 來源:億速云 閱讀:296 作者:Leah 欄目:系統(tǒng)運(yùn)維

本篇文章為大家展示了如何在Linux中使用netstat命令,內(nèi)容簡(jiǎn)明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過這篇文章的詳細(xì)介紹希望你能有所收獲。

1.命令格式:

netstat [-acCeFghilMnNoprstuvVwx][-A<網(wǎng)絡(luò)類型>][--ip]

2.命令功能:

netstat用于顯示與IP、TCP、UDP和ICMP協(xié)議相關(guān)的統(tǒng)計(jì)數(shù)據(jù),一般用于檢驗(yàn)本機(jī)各端口的網(wǎng)絡(luò)連接情況。

3.命令參數(shù):

-a或&ndash;all 顯示所有連線中的Socket。

-A<網(wǎng)絡(luò)類型>或&ndash;<網(wǎng)絡(luò)類型> 列出該網(wǎng)絡(luò)類型連線中的相關(guān)地址。

-c或&ndash;continuous 持續(xù)列出網(wǎng)絡(luò)狀態(tài)。

-C或&ndash;cache 顯示路由器配置的快取信息。

-e或&ndash;extend 顯示網(wǎng)絡(luò)其他相關(guān)信息。

-F或&ndash;fib 顯示FIB。

-g或&ndash;groups 顯示多重廣播功能群組組員名單。

-h或&ndash;help 在線幫助。

-i或&ndash;interfaces 顯示網(wǎng)絡(luò)界面信息表單。

-l或&ndash;listening 顯示監(jiān)控中的服務(wù)器的Socket。

-M或&ndash;masquerade 顯示偽裝的網(wǎng)絡(luò)連線。

-n或&ndash;numeric 直接使用IP地址,而不通過域名服務(wù)器。

-N或&ndash;netlink或&ndash;symbolic 顯示網(wǎng)絡(luò)硬件外圍設(shè)備的符號(hào)連接名稱。

-o或&ndash;timers 顯示計(jì)時(shí)器。

-p或&ndash;programs 顯示正在使用Socket的程序識(shí)別碼和程序名稱。

-r或&ndash;route 顯示Routing Table。

-s或&ndash;statistice 顯示網(wǎng)絡(luò)工作信息統(tǒng)計(jì)表。

-t或&ndash;tcp 顯示TCP傳輸協(xié)議的連線狀況。

-u或&ndash;udp 顯示UDP傳輸協(xié)議的連線狀況。

-v或&ndash;verbose 顯示指令執(zhí)行過程。

-V或&ndash;version 顯示版本信息。

-w或&ndash;raw 顯示RAW傳輸協(xié)議的連線狀況。

-x或&ndash;unix 此參數(shù)的效果和指定”-A unix”參數(shù)相同。

&ndash;ip或&ndash;inet 此參數(shù)的效果和指定”-A inet”參數(shù)相同。

4.使用實(shí)例:

實(shí)例1:無(wú)參數(shù)使用

命令:netstat

輸出:

代碼如下:


[root@localhost ~]# netstat
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 268 192.168.120.204:ssh 10.2.0.68:62420 ESTABLISHED
udp 0 0 192.168.120.204:4371 10.58.119.119:domain ESTABLISHED
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags Type State I-Node Path
unix 2 [ ] DGRAM 1491 @/org/kernel/udev/udevd
unix 4 [ ] DGRAM 7337 /dev/log
unix 2 [ ] DGRAM 708823
unix 2 [ ] DGRAM 7539
unix 3 [ ] STREAM CONNECTED 7287
unix 3 [ ] STREAM CONNECTED 7286
[root@localhost ~]#

說明:

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

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

另一個(gè)是Active UNIX domain sockets,稱為有源Unix域套接口(和網(wǎng)絡(luò)套接字一樣,但是只能用于本機(jī)通信,性能可以提高一倍)。

Proto顯示連接使用的協(xié)議,RefCnt表示連接到本套接口上的進(jìn)程號(hào),Types顯示套接口的類型,State顯示套接口當(dāng)前的狀態(tài),Path表示連接到套接口的其它進(jìn)程使用的路徑名。

套接口類型:

-t :TCP

-u :UDP

-raw :RAW類型

--unix :UNIX域類型

--ax25 :AX25類型

--ipx :ipx類型

--netrom :netrom類型

狀態(tài)說明:

LISTEN:偵聽來自遠(yuǎn)方的TCP端口的連接請(qǐng)求

SYN-SENT:再發(fā)送連接請(qǐng)求后等待匹配的連接請(qǐng)求(如果有大量這樣的狀態(tài)包,檢查是否中招了)

SYN-RECEIVED:再收到和發(fā)送一個(gè)連接請(qǐng)求后等待對(duì)方對(duì)連接請(qǐng)求的確認(rèn)(如有大量此狀態(tài),估計(jì)被flood攻擊了)

ESTABLISHED:代表一個(gè)打開的連接

FIN-WAIT-1:等待遠(yuǎn)程TCP連接中斷請(qǐng)求,或先前的連接中斷請(qǐng)求的確認(rèn)

FIN-WAIT-2:從遠(yuǎn)程TCP等待連接中斷請(qǐng)求

CLOSE-WAIT:等待從本地用戶發(fā)來的連接中斷請(qǐng)求

CLOSING:等待遠(yuǎn)程TCP對(duì)連接中斷的確認(rèn)

LAST-ACK:等待原來的發(fā)向遠(yuǎn)程TCP的連接中斷請(qǐng)求的確認(rèn)(不是什么好東西,此項(xiàng)出現(xiàn),檢查是否被攻擊)

TIME-WAIT:等待足夠的時(shí)間以確保遠(yuǎn)程TCP接收到連接中斷請(qǐng)求的確認(rèn)

CLOSED:沒有任何連接狀態(tài)

實(shí)例2:列出所有端口

命令:netstat -a

輸出:

代碼如下:


[root@localhost ~]# netstat -a
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 localhost:smux *:* LISTEN
tcp 0 0 *:svn *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 284 192.168.120.204:ssh 10.2.0.68:62420 ESTABLISHED
udp 0 0 localhost:syslog *:*
udp 0 0 *:snmp *:*
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node Path
unix 2 [ ACC ] STREAM LISTENING 708833 /tmp/ssh-yKnDB15725/agent.15725
unix 2 [ ACC ] STREAM LISTENING 7296 /var/run/audispd_events
unix 2 [ ] DGRAM 1491 @/org/kernel/udev/udevd
unix 4 [ ] DGRAM 7337 /dev/log
unix 2 [ ] DGRAM 708823
unix 2 [ ] DGRAM 7539
unix 3 [ ] STREAM CONNECTED 7287
unix 3 [ ] STREAM CONNECTED 7286
[root@localhost ~]#

說明:

顯示一個(gè)所有的有效連接信息列表,包括已建立的連接(ESTABLISHED),也包括監(jiān)聽連接請(qǐng)(LISTENING)的那些連接。

實(shí)例3:顯示當(dāng)前UDP連接狀況

命令:netstat -nu

輸出:

代碼如下:


[root@andy ~]# netstat -nu
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
udp 0 0 ::ffff:192.168.12:53392 ::ffff:192.168.9.120:10000 ESTABLISHED
udp 0 0 ::ffff:192.168.12:56723 ::ffff:192.168.9.120:10000 ESTABLISHED
udp 0 0 ::ffff:192.168.12:56480 ::ffff:192.168.9.120:10000 ESTABLISHED
udp 0 0 ::ffff:192.168.12:58154 ::ffff:192.168.9.120:10000 ESTABLISHED
udp 0 0 ::ffff:192.168.12:44227 ::ffff:192.168.9.120:10000 ESTABLISHED
udp 0 0 ::ffff:192.168.12:36954 ::ffff:192.168.9.120:10000 ESTABLISHED
udp 0 0 ::ffff:192.168.12:53984 ::ffff:192.168.9.120:10000 ESTABLISHED
udp 0 0 ::ffff:192.168.12:57703 ::ffff:192.168.9.120:10000 ESTABLISHED
udp 0 0 ::ffff:192.168.12:53613 ::ffff:192.168.9.120:10000 ESTABLISHED
[root@andy ~]#

實(shí)例4:顯示UDP端口號(hào)的使用情況

命令:netstat -apu

輸出:

代碼如下:


[root@andy ~]# netstat -apu
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
udp 0 0 *:57604 *:* 28094/java
udp 0 0 *:40583 *:* 21220/java
udp 0 0 *:45451 *:* 14583/java
udp 0 0 ::ffff:192.168.12:53392 ::ffff:192.168.9.120:ndmp ESTABLISHED 19327/java
udp 0 0 *:52370 *:* 15841/java
udp 0 0 ::ffff:192.168.12:56723 ::ffff:192.168.9.120:ndmp ESTABLISHED 15841/java
udp 0 0 *:44182 *:* 31757/java
udp 0 0 *:48155 *:* 5476/java
udp 0 0 *:59808 *:* 17333/java
udp 0 0 ::ffff:192.168.12:56480 ::ffff:192.168.9.120:ndmp ESTABLISHED 28094/java
udp 0 0 ::ffff:192.168.12:58154 ::ffff:192.168.9.120:ndmp ESTABLISHED 15429/java
udp 0 0 *:36780 *:* 10091/java
udp 0 0 *:36795 *:* 24594/java
udp 0 0 *:41922 *:* 20506/java
udp 0 0 ::ffff:192.168.12:44227 ::ffff:192.168.9.120:ndmp ESTABLISHED 17333/java
udp 0 0 *:34258 *:* 8866/java
udp 0 0 *:55508 *:* 11667/java
udp 0 0 *:36055 *:* 12425/java
udp 0 0 ::ffff:192.168.12:36954 ::ffff:192.168.9.120:ndmp ESTABLISHED 16532/java
udp 0 0 ::ffff:192.168.12:53984 ::ffff:192.168.9.120:ndmp ESTABLISHED 20506/java
udp 0 0 ::ffff:192.168.12:57703 ::ffff:192.168.9.120:ndmp ESTABLISHED 31757/java
udp 0 0 ::ffff:192.168.12:53613 ::ffff:192.168.9.120:ndmp ESTABLISHED 3199/java
udp 0 0 *:56309 *:* 15429/java
udp 0 0 *:54007 *:* 16532/java
udp 0 0 *:39544 *:* 3199/java
udp 0 0 *:43900 *:* 19327/java
[root@andy ~]#

實(shí)例5:顯示網(wǎng)卡列表

命令:netstat -i

輸出:

代碼如下:


[root@andy ~]# netstat -i
Kernel Interface table
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0 1500 0 151818887 0 0 0 198928403 0 0 0 BMRU
lo 16436 0 107235 0 0 0 107235 0 0 0 LRU
[root@andy ~]#

實(shí)例6:顯示組播組的關(guān)系

命令:netstat -g

輸出:

代碼如下:


[root@andy ~]# netstat -g
IPv6/IPv4 Group Memberships
Interface RefCnt Group
--------------- ------ ---------------------
lo 1 all-systems.mcast.net
eth0 1 all-systems.mcast.net
lo 1 ff02::1
eth0 1 ff02::1:ffff:9b0c
eth0 1 ff02::1
[root@andy ~]#

實(shí)例7:顯示網(wǎng)絡(luò)統(tǒng)計(jì)信息

命令:netstat -s

輸出:

代碼如下:


[root@localhost ~]# netstat -s
Ip:
530999 total packets received
0 forwarded
0 incoming packets discarded
530999 incoming packets delivered
8258 requests sent out
1 dropped because of missing route
Icmp:
90 ICMP messages received
0 input ICMP message failed.
ICMP input histogram:
destination unreachable: 17
echo requests: 1
echo replies: 72
106 ICMP messages sent
0 ICMP messages failed
ICMP output histogram:
destination unreachable: 8
echo request: 97
echo replies: 1
IcmpMsg:
InType0: 72
InType3: 17
InType8: 1
OutType0: 1
OutType3: 8
OutType8: 97
Tcp:
8 active connections openings
15 passive connection openings
8 failed connection attempts
3 connection resets received
1 connections established
3132 segments received
2617 segments send out
53 segments retransmited
0 bad segments received.
252 resets sent
Udp:
0 packets received
0 packets to unknown port received.
0 packet receive errors
5482 packets sent
TcpExt:
1 invalid SYN cookies received
1 TCP sockets finished time wait in fast timer
57 delayed acks sent
Quick ack mode was activated 50 times
60 packets directly queued to recvmsg prequeue.
68 packets directly received from backlog
4399 packets directly received from prequeue
520 packets header predicted
51 packets header predicted and directly queued to user
1194 acknowledgments not containing data received
21 predicted acknowledgments
0 TCP data loss events
1 timeouts after reno fast retransmit
9 retransmits in slow start
42 other TCP timeouts
3 connections aborted due to timeout
IpExt:
InBcastPkts: 527777

說明:

按照各個(gè)協(xié)議分別顯示其統(tǒng)計(jì)數(shù)據(jù)。如果我們的應(yīng)用程序(如Web瀏覽器)運(yùn)行速度比較慢,或者不能顯示W(wǎng)eb頁(yè)之類的數(shù)據(jù),那么我們就可以用本選項(xiàng)來查看一下所顯示的信息。我們需要仔細(xì)查看統(tǒng)計(jì)數(shù)據(jù)的各行,找到出錯(cuò)的關(guān)鍵字,進(jìn)而確定問題所在。

實(shí)例8:顯示監(jiān)聽的套接口

命令:netstat -l

輸出:

代碼如下:


[root@localhost ~]# netstat -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 localhost:smux *:* LISTEN
tcp 0 0 *:svn *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
udp 0 0 localhost:syslog *:*
udp 0 0 *:snmp *:*
Active UNIX domain sockets (only servers)
Proto RefCnt Flags Type State I-Node Path
unix 2 [ ACC ] STREAM LISTENING 708833 /tmp/ssh-yKnDB15725/agent.15725
unix 2 [ ACC ] STREAM LISTENING 7296 /var/run/audispd_events
[root@localhost ~]#

實(shí)例9:顯示所有已建立的有效連接

命令:netstat -n

輸出:

代碼如下:


[root@localhost ~]# netstat -n
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 268 192.168.120.204:22 10.2.0.68:62420 ESTABLISHED
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags Type State I-Node Path
unix 2 [ ] DGRAM 1491 @/org/kernel/udev/udevd
unix 4 [ ] DGRAM 7337 /dev/log
unix 2 [ ] DGRAM 708823
unix 2 [ ] DGRAM 7539
unix 3 [ ] STREAM CONNECTED 7287
unix 3 [ ] STREAM CONNECTED 7286
[root@localhost ~]#

實(shí)例10:顯示關(guān)于以太網(wǎng)的統(tǒng)計(jì)數(shù)據(jù)

命令:netstat -e

輸出:

代碼如下:


[root@localhost ~]# netstat -e
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State User Inode
tcp 0 248 192.168.120.204:ssh 10.2.0.68:62420 ESTABLISHED root 708795
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags Type State I-Node Path
unix 2 [ ] DGRAM 1491 @/org/kernel/udev/udevd
unix 4 [ ] DGRAM 7337 /dev/log
unix 2 [ ] DGRAM 708823
unix 2 [ ] DGRAM 7539
unix 3 [ ] STREAM CONNECTED 7287
unix 3 [ ] STREAM CONNECTED 7286
[root@localhost ~]#

說明:

用于顯示關(guān)于以太網(wǎng)的統(tǒng)計(jì)數(shù)據(jù)。它列出的項(xiàng)目包括傳送的數(shù)據(jù)報(bào)的總字節(jié)數(shù)、錯(cuò)誤數(shù)、刪除數(shù)、數(shù)據(jù)報(bào)的數(shù)量和廣播的數(shù)量。這些統(tǒng)計(jì)數(shù)據(jù)既有發(fā)送的數(shù)據(jù)報(bào)數(shù)量,也有接收的數(shù)據(jù)報(bào)數(shù)量。這個(gè)選項(xiàng)可以用來統(tǒng)計(jì)一些基本的網(wǎng)絡(luò)流量)

實(shí)例11:顯示關(guān)于路由表的信息

命令:netstat -r

輸出:

代碼如下:


[root@localhost ~]# netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.120.0 * 255.255.255.0 U 0 0 0 eth0
192.168.0.0 192.168.120.1 255.255.0.0 UG 0 0 0 eth0
10.0.0.0 192.168.120.1 255.0.0.0 UG 0 0 0 eth0
default 192.168.120.240 0.0.0.0 UG 0 0 0 eth0
[root@localhost ~]#

實(shí)例12:列出所有 tcp 端口

命令:netstat -at

輸出:
 

代碼如下:


[root@localhost ~]# netstat -at
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 localhost:smux *:* LISTEN
tcp 0 0 *:svn *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 284 192.168.120.204:ssh 10.2.0.68:62420 ESTABLISHED
[root@localhost ~]#

實(shí)例13:統(tǒng)計(jì)機(jī)器中網(wǎng)絡(luò)連接各個(gè)狀態(tài)個(gè)數(shù)

命令:netstat -a | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'

輸出:

代碼如下:


[root@localhost ~]# netstat -a | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
ESTABLISHED 1
LISTEN 3
[root@localhost ~]#



實(shí)例14:把狀態(tài)全都取出來后使用uniq -c統(tǒng)計(jì)后再進(jìn)行排序

命令:netstat -nat |awk '{print $6}'|sort|uniq -c

輸出:

 

代碼如下:


[root@andy ~]# netstat -nat |awk '{print $6}'|sort|uniq -c
14 CLOSE_WAIT
1 established)
578 ESTABLISHED
1 Foreign
43 LISTEN
5 TIME_WAIT
[root@andy ~]# netstat -nat |awk '{print $6}'|sort|uniq -c|sort -rn
576 ESTABLISHED
43 LISTEN
14 CLOSE_WAIT
5 TIME_WAIT
1 Foreign
1 established)
[root@andy ~]#

實(shí)例15:查看連接某服務(wù)端口最多的的IP地址

命令:netstat -nat | grep "192.168.120.20:16067" |awk '{print $5}'|awk -F: '{print $4}'|sort|uniq -c|sort -nr|head -20

輸出:

 

代碼如下:


[root@andy ~]# netstat -nat | grep "192.168.120.20:16067" |awk '{print $5}'|awk -F: '{print $4}'|sort|uniq -c|sort -nr|head -20
8 10.2.1.68
7 192.168.119.13
6 192.168.119.201
6 192.168.119.20
6 192.168.119.10
4 10.2.1.199
3 10.2.1.207
2 192.168.120.20
2 192.168.120.15
2 192.168.119.197
2 192.168.119.11
2 10.2.1.206
2 10.2.1.203
2 10.2.1.189
2 10.2.1.173
1 192.168.120.18
1 192.168.119.19
1 10.2.2.227
1 10.2.2.138
1 10.2.1.208
[root@andy ~]#

實(shí)例16:找出程序運(yùn)行的端口

命令:netstat -ap | grep ssh

輸出:

代碼如下:


[root@andy ~]# netstat -ap | grep ssh
tcp 0 0 *:ssh *:* LISTEN 2570/sshd
tcp 0 0 ::ffff:192.168.120.206:ssh ::ffff:10.2.1.205:54508 ESTABLISHED 13883/14
tcp 0 0 ::ffff:192.168.120.206:ssh ::ffff:10.2.0.68:62886 ESTABLISHED 20900/6
tcp 0 0 ::ffff:192.168.120.206:ssh ::ffff:10.2.2.131:52730 ESTABLISHED 20285/sshd: root@no
unix 2 [ ACC ] STREAM LISTENING 194494461 20900/6 /tmp/ssh-cXIJj20900/agent.20900
unix 3 [ ] STREAM CONNECTED 194307443 20285/sshd: root@no
unix 3 [ ] STREAM CONNECTED 194307441 20285/sshd: root@no
[root@andy ~]#

實(shí)例17:在 netstat 輸出中顯示 PID 和進(jìn)程名稱

命令:netstat -pt

輸出:

代碼如下:


[root@localhost ~]# netstat -pt
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 248 192.168.120.204:ssh 10.2.0.68:62420 ESTABLISHED 15725/0
[root@localhost ~]#

說明:

netstat -p 可以與其它開關(guān)一起使用,就可以添加 “PID/進(jìn)程名稱” 到 netstat 輸出中,這樣 debugging 的時(shí)候可以很方便的發(fā)現(xiàn)特定端口運(yùn)行的程序。

實(shí)例18:找出運(yùn)行在指定端口的進(jìn)程

命令:netstat -anpt | grep ':16064'

輸出:

代碼如下:


[root@andy ~]# netstat -anpt | grep ':16064'
tcp 0 0 :::16064 :::* LISTEN 24594/java
tcp 0 0 ::ffff:192.168.120.20:16064 ::ffff:192.168.119.201:6462 ESTABLISHED 24594/java
tcp 0 0 ::ffff:192.168.120.20:16064 ::ffff:192.168.119.20:26341 ESTABLISHED 24594/java
tcp 0 0 ::ffff:192.168.120.20:16064 ::ffff:192.168.119.20:32208 ESTABLISHED 24594/java
tcp 0 0 ::ffff:192.168.120.20:16064 ::ffff:192.168.119.20:32207 ESTABLISHED 24594/java
tcp 0 0 ::ffff:192.168.120.20:16064 ::ffff:10.2.1.68:51303 ESTABLISHED 24594/java
tcp 0 0 ::ffff:192.168.120.20:16064 ::ffff:10.2.1.68:51302 ESTABLISHED 24594/java
tcp 0 0 ::ffff:192.168.120.20:16064 ::ffff:10.2.1.68:50020 ESTABLISHED 24594/java
tcp 0 0 ::ffff:192.168.120.20:16064 ::ffff:10.2.1.68:50019 ESTABLISHED 24594/java
tcp 0 0 ::ffff:192.168.120.20:16064 ::ffff:10.2.1.68:56155 ESTABLISHED 24594/java
tcp 0 0 ::ffff:192.168.120.20:16064 ::ffff:10.2.1.68:50681 ESTABLISHED 24594/java
tcp 0 0 ::ffff:192.168.120.20:16064 ::ffff:10.2.1.68:50680 ESTABLISHED 24594/java
tcp 0 0 ::ffff:192.168.120.20:16064 ::ffff:10.2.1.68:52136 ESTABLISHED 24594/java
tcp 0 0 ::ffff:192.168.120.20:16064 ::ffff:10.2.1.68:56989 ESTABLISHED 24594/java
tcp 0 0 ::ffff:192.168.120.20:16064 ::ffff:10.2.1.68:56988 ESTABLISHED 24594/java
[root@andy ~]#

說明:

運(yùn)行在端口16064的進(jìn)程id為24596,再通過ps命令就可以找到具體的應(yīng)用程序了。

上述內(nèi)容就是如何在Linux中使用netstat命令,你們學(xué)到知識(shí)或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識(shí)儲(chǔ)備,歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI