Yuav siv li cas Netstat hais kom ua

Cov txheej txheem:

Yuav siv li cas Netstat hais kom ua
Yuav siv li cas Netstat hais kom ua
Anonim

Cov lus txib netstat, lub ntsiab lus ntawm kev txheeb xyuas network, yog Command Prompt hais kom siv los tso saib cov ntaub ntawv ntxaws ntxaws txog seb koj lub khoos phis tawj sib txuas lus nrog lwm lub khoos phis tawj lossis cov khoom siv hauv network.

Tshwj xeeb, nws tuaj yeem qhia cov ntsiab lus hais txog kev sib txuas ntawm tus kheej, tag nrho thiab cov txheej txheem kev sib tham tshwj xeeb hauv kev txheeb xyuas, thiab ntau ntxiv, txhua yam tuaj yeem pab daws teeb meem qee yam teeb meem kev sib tham.

Image
Image

Netstat Command Availability

Cov lus txib no muaj los ntawm hauv Command Prompt hauv feem ntau ntawm Windows, suav nrog Windows 11, Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server operating systems, thiab qee qhov qub ntawm Windows, too.

Netstat yog ib qho kev hais kom ua cross-platform, uas txhais tau tias nws tseem muaj nyob rau hauv lwm cov kev khiav hauj lwm xws li macOS thiab Linux.

Qhov muaj ntawm qee qhov netstat hais kom hloov pauv thiab lwm yam netstat hais kom ua syntax yuav txawv ntawm kev khiav hauj lwm rau kev ua haujlwm.

Netstat Command Syntax

netstat [- a] [- b] [- e] [- f] [- n] [- o] [- p raws tu qauv] [- r] [- s] [- t] [- x] [- y] [time_interval] [ /?

Netstat Command List
Option piav qhia
netstat Ua tiav cov lus txib netstat ib leeg los qhia cov npe yooj yim ntawm txhua qhov kev sib txuas TCP uas, rau txhua tus, yuav qhia tus IP chaw nyob hauv zos (koj lub khoos phis tawj), tus IP chaw nyob txawv tebchaws (lwm lub computer lossis network ntaus ntawv), nrog rau lawv tus lej chaw nres nkoj, nrog rau lub xeev TCP.
- a Qhov kev hloov no qhia txog kev sib txuas TCP, TCP kev sib txuas nrog lub xeev mloog, nrog rau UDP cov chaw nres nkoj uas tau mloog.
- b Qhov kev hloov netstat no zoo ib yam li - o hloov npe hauv qab no, tab sis tsis txhob tso saib PID, yuav tso tawm cov txheej txheem cov npe ntawm cov ntaub ntawv. Siv - b dhau - o tej zaum zoo li nws tau txuag koj ib kauj ruam lossis ob tab sis siv nws qee zaum tuaj yeem ncua sij hawm nws siv netstat kom ua tiav..
- e Siv qhov hloov pauv no nrog cov lus txib netstat los qhia cov txheeb cais txog koj qhov kev sib txuas hauv network. Cov ntaub ntawv no suav nrog bytes, pob ntawv unicast, pob ntawv tsis yog unicast, muab pov tseg, yuam kev, thiab cov txheej txheem tsis paub tau txais thiab xa txij li kev sib txuas tau tsim.
- f Tus - f hloov yuav yuam cov lus txib netstat kom tso saib Lub Npe Tag Nrho Tsim Nyog (FQDN) rau txhua tus IP chaw nyob txawv teb chaws thaum ua tau.
- n Siv lub - n hloov los tiv thaiv netstat los ntawm kev sim txiav txim siab lub npe tswv rau txawv teb chaws IP chaw. Nyob ntawm koj qhov kev sib txuas hauv network tam sim no, siv qhov hloov pauv no tuaj yeem txo lub sijhawm nws siv rau netstat kom ua tiav tag nrho.
- o Ib qho kev xaiv yooj yim rau ntau yam kev daws teeb meem, qhov - ohloov qhia cov txheej txheem tus cim (PID) cuam tshuam nrog txhua qhov kev sib txuas tau pom. Saib cov piv txwv hauv qab no kom paub ntxiv txog kev siv netstat -o.
- p Siv lub - p hloov los qhia kev sib txuas lossis kev txheeb cais tsuas yog rau ib qho kev cai tshwj xeeb. Koj tsis tuaj yeem txhais ntau tshaj ib txoj cai ib zaug, thiab koj tsis tuaj yeem ua netstat nrog - p yam tsis tau txhais cov txheej txheem.
protocol Thaum qhia meej txog tus txheej txheem nrog - p kev xaiv, koj tuaj yeem siv tcp, udp, tcpv6, or udpv6 Yog koj siv - s nrog - p txhawm rau saib cov txheeb cais los ntawm cov txheej txheem, koj tuaj yeem siv icmp, ip, icmpv6, lossis ipv6 ntxiv rau thawj plaub kuv tau hais.
- r Execute netstat nrog - r los qhia IP routing table. Qhov no yog tib yam li kev siv txoj kev hais kom ua route print.
- s Qhov - s kev xaiv tuaj yeem siv nrog cov lus txib netstat los qhia cov ncauj lus kom ntxaws los ntawm cov txheej txheem. Koj tuaj yeem txwv cov txheeb cais tau pom rau ib qho kev cai tshwj xeeb los ntawm kev siv - sxaiv thiab qhia qhov kev cai ntawd, tab sis nco ntsoov siv - sua ntej- p raws tu qauv thaum siv cov keyboards ua ke.
- t Siv lub - t hloov los qhia qhov tam sim no TCP chimney offload xeev nyob rau hauv qhov chaw ntawm lub xeev TCP feem ntau tso tawm.
- x Siv qhov - x kev xaiv los qhia txhua tus neeg mloog NetworkDirect, kev sib txuas, thiab cov ntsiab lus sib koom.
- y Tus - y hloov tuaj yeem siv los qhia TCP kev sib txuas qauv rau txhua qhov kev sib txuas. Koj siv tsis tau - y nrog lwm qhov kev xaiv netstat.
sijhawm_in terval Nov yog lub sijhawm, hauv vib nas this, uas koj xav kom netstat hais kom rov ua tiav, nres tsuas yog thaum koj siv Ctrl-C los xaus lub voj.
/? Siv cov kev pab hloov los qhia cov ntsiab lus ntawm netstat hais kom ua ntau txoj kev xaiv.

Ua kom tag nrho cov ntaub ntawv netstat hauv kab hais kom ua haujlwm yooj yim dua los ntawm kev tso tawm qhov koj pom ntawm lub vijtsam mus rau cov ntawv nyeem siv tus neeg teb xov tooj rov qab. Saib Yuav Ua Li Cas Redirect Command Output rau Cov Ntaub Ntawv kom tiav cov lus qhia.

Netstat Command Piv txwv

Ntawm no yog ob peb yam piv txwv qhia tias yuav siv netstat li cas:

Show Active TCP Connections


netstat -f

Hauv qhov piv txwv thawj no, peb ua netstat los qhia txhua qhov kev sib txuas TCP. Txawm li cas los xij, peb xav pom cov khoos phis tawj uas peb txuas nrog hauv FQDN hom [- f] es tsis yog qhov chaw nyob IP yooj yim.

Nov yog ib qho piv txwv ntawm qhov koj yuav pom:


Kev sib txuas ua ke

Proto Chaw Nyob Hauv Chaw Nyob txawv teb chaws Xeev

TCP 127.0.0.1:5357 VM-Windows-7: 49229 TIME_WAIT TCP 127.0.0.1:49225 VM-Windows-7:12080 TIME_WAIT TCP 192.168.1.14:49194 75.125.212.75:http CLOSE_WAIT TCP 192.168.1.14:49196 a795sm.avast.com:http CLOSE_WAIT

91. TCP 49197 a795sm.avast.com:http CLOSE_WAIT

TCP 192.168.1.14:49230 TIM-PC:wsd TIME_WAIT

TCP 192.168.1.1.14:4923:icslap ESTABLISHED TCP 192.168.1.14:49232 TIM-PC:netbios-ssn TIME_WAIT TCP 192.168.1.14:49233 TIM-PCs:nnetbios- TIME_WAIT TCP [::1]:2869 VM-Windows-7:49226 ESTABLISHED TCP [::1]:49226 VM-Windows-7: icslap ESTABLISHED

Raws li koj tuaj yeem pom, muaj 11 qhov kev sib txuas TCP nquag thaum lub sijhawm netstat raug tua hauv qhov piv txwv no. Tib txoj cai (hauv Proto kem) tau teev tseg yog TCP, uas xav tau vim peb tsis siv - a.

Koj tuaj yeem pom peb qhov chaw nyob IP nyob rau hauv kab Chaw Nyob Hauv Zos-qhov tseeb IP chaw nyob ntawm 192.168.1.14 thiab IPv4 thiab IPv6 versions ntawm qhov chaw nyob loopback, nrog rau qhov chaw nres nkoj txhua qhov kev sib txuas siv. Kab lus Chaw Nyob txawv teb chaws sau cov FQDN (75.125.212.75 tsis daws vim qee yam) nrog rau qhov chaw nres nkoj ib yam.

Thaum kawg, Lub Xeev kab teev npe TCP lub xeev ntawm qhov kev sib txuas tshwj xeeb.

Qhia kev sib txuas thiab cov txheej txheem qhia txog


netstat -o

Hauv qhov piv txwv no, netstat yuav ua haujlwm ib txwm yog li nws tsuas yog qhia TCP kev sib txuas, tab sis peb kuj xav pom cov txheej txheem sib txuas [- o] rau txhua qhov kev sib txuas yog li uas peb tuaj yeem txiav txim siab seb qhov program twg hauv lub khoos phis tawj pib txhua tus.

Ntawm no yog yam uas lub computer tso tawm:


Kev sib txuas ua ke

Proto Local Chaw Nyob txawv teb chaws Lub Xeev PID

TCP 192.168.1.14:49194 75.125.212.75:http CLOSE_WAIT 2948

TCP 192.168.1.14:49196 a795sm:http CLOSE_WAIT 2948

TCP 192.168.1.14:49197 a795WA9

Tej zaum koj yuav pom kab PID tshiab. Hauv qhov no, PIDs yog tib yam, txhais tau hais tias tib txoj haujlwm ntawm lub khoos phis tawj qhib cov kev sib txuas no.

Txhawm rau txiav txim siab seb qhov program twg yog tus sawv cev los ntawm PID ntawm 2948 ntawm lub khoos phis tawj, txhua yam koj yuav tsum ua yog qhib Task Manager, xaiv lub Processes tab, thiab nco ntsoov lub npe duab teev nyob ib sab ntawm PID peb tab tom nrhiav rau hauv kab PID.1

Siv cov lus txib netstat nrog rau - o kev xaiv tuaj yeem pab tau zoo thaum taug qab qhov kev pab cuam twg siv ntau dhau ntawm koj qhov bandwidth. Nws kuj tseem tuaj yeem pab nrhiav qhov chaw uas qee yam malware, lossis txawm tias ib qho kev cai lij choj ntawm software, tej zaum yuav xa cov ntaub ntawv yam tsis tau koj tso cai.

Thaum qhov no thiab cov piv txwv yav dhau los yog ob qho tib si khiav ntawm tib lub khoos phis tawj, thiab hauv ib feeb ntawm ib leeg, koj tuaj yeem pom tias daim ntawv teev cov kev sib txuas TCP muaj qhov sib txawv heev. Qhov no yog vim koj lub khoos phis tawj txuas mus tas li, thiab tsis txuas nrog, ntau yam khoom siv hauv koj lub network thiab hauv internet.

Qhia tshwj xeeb kev sib txuas nkaus xwb


netstat -0 | findstr 28604

Cov piv txwv saum toj no zoo ib yam li peb twb tau saib lawm, tab sis tsis txhob tso tawm txhua qhov kev sib txuas, peb tab tom qhia cov lus txib netstat kom pom tsuas yog cov kev sib txuas uas siv ib qho tshwj xeeb PID, 28604 hauv qhov piv txwv no.

Ib qho lus txib zoo sib xws tuaj yeem siv los lim tawm cov kev sib txuas nrog lub xeev CLOSE_WAIT, los ntawm kev hloov PID nrog ESTABLISHED.

Show Protocol-Specific Stats


netstat -s -p tcp -f

Hauv qhov piv txwv no, peb xav pom cov kev txheeb cais tshwj xeeb [- s] tab sis tsis yog txhua tus ntawm lawv, tsuas yog TCP stats [- ptcp]. Peb kuj xav kom cov chaw nyob txawv teb chaws tso tawm ua FQDN hom [-f ].

Qhov no yog qhov netstat hais kom ua, raws li qhia saum toj no, ua rau hauv lub computer piv txwv:


TCP Statistics rau IPv4

Active Opens=77

Passive Opens=21

Kev Sib Txuas Tsis Txaus Siab=2 Rov pib dua kev sib txuas=25 Kev sib txuas tam sim no=5 ntu tau txais=7313 Segments xa=4824

ntu Retransmitted=5 Kev sib txuas ua ke Proto Chaw Nyob Hauv Zos Chaw Nyob txawv teb chaws State TCP 127.0.0.1:2869 VM-Windows-7:49235 TIME_WAIT TCP 127.0.0.1:2869 VM-Windows-7:49238 ESTABLISHED TCP 127.0. 0.1:49238 VM-Windows-7:icslap ESTABLISHED TCP 192.168.1.14:49194 75.125.212.75:http CLOSE_WAIT TCP 195.1914 a68:.avast.com:http CLOSE_WAIT TCP 192.168.1.14:49197 a795sm.avast.com:http CLOSE_WAIT

Raws li koj tuaj yeem pom, ntau yam kev txheeb cais rau TCP raws tu qauv tau tshwm sim, zoo li txhua qhov kev sib txuas ntawm TCP thaum lub sijhawm.

Show Updated Network Stats


netstat -e -t 5

Hauv qhov piv txwv kawg no, netstat hais kom ua tiav los qhia qee qhov kev sib tham hauv network yooj yim [- e] thiab kom cov txheeb cais no txuas ntxiv hloov kho hauv qhov hais kom ua txhua tsib vib nas this [- t 5].

Ntawm no yog qhov tsim tawm ntawm qhov screen:


Interface Statistics

Tau txais xa

Bytes 22132338 1846834

pob ntawv Unicast 19113 9869

Cov pob ntawv uas tsis yog unicast 0 0

Muab pov tseg 0 0

yuam kev 0 0

Unknown protocols 0Interface Statistics Tau txais xa Bytes 22134630 1846834

Unicast packets 19128 9869

Cov pob ntawv uas tsis yog unicast 0 0

Muab pov tseg 0 0

yuam kev 0 0 Unknown protocols 0^C

Ntau yam ntaub ntawv, uas koj tuaj yeem pom ntawm no thiab peb tau teev nyob rau hauv - e syntax saum toj no, tau tshwm sim.

Cov lus txib netstat tsuas yog ua tiav ib zaug ntxiv, raws li koj tuaj yeem pom los ntawm ob lub rooj hauv qhov tshwm sim. Nco ntsoov lub ^C hauv qab, qhia tias Ctrl + C rho tawm cov lus txib tau siv los nres qhov rov ua haujlwm ntawm cov lus txib.

Netstat Related Commands

Cov lus txib netstat feem ntau yog siv nrog lwm yam kev sib tham txog kev hais kom ua raws li cov lus txib xws li nslookup, ping, tracert, ipconfig, thiab lwm yam.

[1] Tej zaum koj yuav tsum tau manually ntxiv PID kem rau Task Manager. Koj tuaj yeem ua qhov no los ntawm kev xaiv PID tom qab txoj cai-nias kab lus hauv kab ntawv Process tab. Yog tias koj siv Windows 7 lossis ntawm Windows OS qub, xaiv qhov PID (Process Identifier) checkbox los ntawm View > Select Kab hauv Task Manager. Koj kuj tseem yuav tau xaiv Qhia cov txheej txheem los ntawm txhua tus neeg siv los ntawm hauv qab ntawm Processes tab yog tias PID koj tab tom nrhiav tsis tau teev tseg.

Pom zoo: