您好,登錄后才能下訂單哦!
這篇文章將為大家詳細(xì)講解有關(guān)netstat的1基本用法有哪些,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。
顯示當(dāng)前所有的鏈接
root@ts:~# netstat -a Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 localhost:domain *:* LISTEN tcp 0 0 testforpaas.21vi:domain *:* LISTEN tcp 0 0 localhost:5433 *:* LISTEN tcp 0 0 localhost:smtp *:* LISTEN tcp 0 0 localhost:6010 *:* LISTEN
root@ts:~# netstat -tau
默認(rèn)情況下 netstat 會通過反向域名解析技術(shù)查找每個(gè) IP 地址對應(yīng)的主機(jī)名。這會降低查找速度。如果你覺得 IP 地址已經(jīng)足夠,而沒有必要知道主機(jī)名,就使用 -n 選項(xiàng)禁用域名解析功能
root@ts:~# netstat -ant Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN tcp 0 0 172.16.16.1:53 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:5433 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:8123 0.0.0.0:* LISTEN
任何網(wǎng)絡(luò)服務(wù)的后臺進(jìn)程都會打開一個(gè)端口,用于監(jiān)聽接入的請求。這些正在監(jiān)聽的套接字也和連接的套接字一樣,也能被 netstat 列出來。使用 -l 選項(xiàng)列出正在監(jiān)聽的套接字
root@ts:~# netstat -tnl Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN tcp 0 0 172.16.16.1:53 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:5433 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:8123 0.0.0.0:* LISTEN
root@ts:~# netstat -tlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 localhost:domain *:* LISTEN 1080/dnsmasq tcp 0 0 testforpaas.21vi:domain *:* LISTEN 1080/dnsmasq tcp 0 0 localhost:5433 *:* LISTEN 11237/postgres tcp 0 0 localhost:smtp *:* LISTEN 1371/sendmail: MTA: tcp 0 0 localhost:6010 *:* LISTEN 9389/6
root@ts:~# netstat -tlpe Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name tcp 0 0 localhost:domain *:* LISTEN root 15870 1080/dnsmasq tcp 0 0 testforpaas.21vi:domain *:* LISTEN root 15868 1080/dnsmasq tcp 0 0 localhost:5433 *:* LISTEN postgres 130080 11237/postgres tcp 0 0 localhost:smtp *:* LISTEN root 17826 1371/sendmail: MTA
root@ts:~# netstat -tlpen Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 0 15870 1080/dnsmasq tcp 0 0 172.16.16.1:53 0.0.0.0:* LISTEN 0 15868 1080/dnsmasq tcp 0 0 127.0.0.1:5433 0.0.0.0:* LISTEN 116 130080 11237/postgres tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 0 17826 1371/sendmail: MTA
netstat 可以打印出網(wǎng)絡(luò)統(tǒng)計(jì)數(shù)據(jù),包括某個(gè)協(xié)議下的收發(fā)包數(shù)量
root@ts:~# netstat -tns IcmpMsg: InType0: 93 InType3: 14674 InType11: 27391 OutType3: 18230 OutType8: 38060 Tcp: 23583 active connections openings 139747 passive connection openings 21350 failed connection attempts 1512 connection resets received 4 connections established 4263613 segments received 4716472 segments send out 171992 segments retransmited 55 bad segments received. 151266 resets sent
root@ts:~# netstat -rn Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 0.0.0.0 172.16.16.62 0.0.0.0 UG 0 0 0 ens160 10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 br-9547a5f0faec 10.20.0.0 10.20.101.9 255.255.0.0 UG 0 0 0 ppp0
netstat 也能打印網(wǎng)絡(luò)接口信息,-i 選項(xiàng)就是為這個(gè)功能而生
root@ts:~# 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 br-9547a5f0faec 1500 0 55883292 0 0 0 89519216 0 0 0 BMRU docker0 1500 0 49 0 0 0 16 0 0 0 BMU ens160 1500 0 152552760 0 611 0 60254997 0 0 0 BMRU lo 65536 0 583345 0 0 0 583345 0 0 0 LRU ppp0 1354 0 2157 0 0 0 1679 0 0 0 MOPRU veth6dd978f 1500 0 12751092 0 0 0 18590019 0 0 0 BMRU
輸出友好信息
root@ts:~# netstat -ei Kernel Interface table br-9547a5f0faec Link encap:Ethernet HWaddr 02:42:ee:4b:21:05 inet addr:10.0.0.1 Bcast:10.0.0.255 Mask:255.255.255.0 inet6 addr: fe80::42:eeff:fe4b:2105/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:55883460 errors:0 dropped:0 overruns:0 frame:0 TX packets:89519456 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:7839329499 (7.8 GB) TX bytes:199950345292 (199.9 GB) docker0 Link encap:Ethernet HWaddr 02:42:8f:b2:de:7a inet addr:172.17.0.1 Bcast:172.17.255.255 Mask:255.255.0.0 inet6 addr: fe80::42:8fff:feb2:de7a/64 Scope:Link UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:49 errors:0 dropped:0 overruns:0 frame:0 TX packets:16 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:1372 (1.3 KB) TX bytes:1368 (1.3 KB)
root@ts:~# netstat -cu Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State udp6 0 0 localhost:37429 localhost:37429 ESTABLISHED
netstat -atnp | grep ESTA
watch -d -n0 "netstat -atnp | grep ESTA"
關(guān)于“netstat的1基本用法有哪些”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學(xué)到更多知識,如果覺得文章不錯(cuò),請把它分享出去讓更多的人看到。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。