1. Anasayfa
  2. PowerShell

Windows İşletim Sisteminde Netstat Komutu ile Ağ Bağlantı ve İstatistiklerini İzlemek


Günümüzün dijital dünyasında ağ bağlantılarını izlemek ve yönetmek bilgisayar güvenliği ve performansı açısından büyük önem taşımaktadır. Windows işletim sistemlerinde kullanılan netstat komutu sisteminizdeki aktif TCP bağlantılarını, dinlenen portları, ağ kartı istatistiklerini ve IP yönlendirme tablolarını görüntülemek için kullanılan güçlü bir araçtır.

Bu makalemde netstat komutunun nasıl kullanıldığını ve çeşitli parametrelerini detaylı bir şekilde açıklayacağım.

Netstat (Network Statistics) bir bilgisayarın ağ bağlantılarını ve ilgili istatistikleri görüntülemek için kullanılan bir komut satırı aracıdır. TCP/IP protokolü kurulu olan sistemlerde çalışır ve sistem yöneticileri için oldukça faydalıdır.

Eğer komut herhangi bir parametre olmadan kullanılırsa o sistemdeki sadece aktif TCP bağlantılarını görüntüler.

Aşağıdaki temel parametreler kullanılarak netstat komutu çalıştırılabilir;

netstat [-a] [-b] [-e] [-n] [-o] [-p <Protocol>] [-r] [-s] [<interval>]

Her bir parametre belirli bir ağ bilgisi sağlar. Şimdi bu parametrelerin ne anlama geldiğini inceleyelim.

ParametreAçıklama
-aTüm aktif TCP bağlantılarını ve dinlenen TCP, UDP portlarını gösterir.
-bHer bağlantı veya dinleme portu için ilgili yürütülebilir dosyayı gösterir. Yetki gerektirebilir.
-eGönderilen ve alınan bayt ve paket sayısı gibi Ethernet istatistiklerini gösterir.
-nIP adreslerini ve port numaralarını isimlendirme yapmadan sayısal olarak görüntüler.
-oAktif TCP bağlantılarıyla ilişkili Process ID (PID) numaralarını görüntüler.
-pBelirtilen protokol için bağlantıları gösterir (örneğin: tcp, udp, tcpv6, udpv6).
-rIP yönlendirme tablosunu görüntüler.
-sTCP, UDP, ICMP ve IP protokollerine ait istatistikleri görüntüler.
Belirli aralıklarla bilgiyi tekrar göstermeye devam eder. Durdurmak için CTRL + C kullanılır.

Netstat Komutu Kullanımı ve Örnekler

Tüm Ağ kartlarındaki istatistiklerini ve protokol bilgilerini görüntülemek için;

netstat -e -s

Bu komut Ethernet istatistikleriyle birlikte TCP, UDP, ICMP ve IP protokollerine ait verileri görüntüler.

Örnek komut çıktısı;

C:\Windows\System32>netstat -e -s
Interface Statistics

                           Received            Sent

Bytes                    3864427863       958224255
Unicast packets           222781871       111116559
Non-unicast packets          776000          393208
Discards                          0               0
Errors                            0               0
Unknown protocols                 0

IPv4 Statistics

  Packets Received                   = 28071551
  Received Header Errors             = 0
  Received Address Errors            = 1084
  Datagrams Forwarded                = 0
  Unknown Protocols Received         = 0
  Received Packets Discarded         = 35374
  Received Packets Delivered         = 28129459
  Output Requests                    = 18215212
  Routing Discards                   = 0
  Discarded Output Packets           = 25361
  Output Packet No Route             = 66
  Reassembly Required                = 0
  Reassembly Successful              = 0
  Reassembly Failures                = 0
  Datagrams Successfully Fragmented  = 0
  Datagrams Failing Fragmentation    = 0
  Fragments Created                  = 0

IPv6 Statistics

  Packets Received                   = 35122
  Received Header Errors             = 0
  Received Address Errors            = 4026
  Datagrams Forwarded                = 0
  Unknown Protocols Received         = 0
  Received Packets Discarded         = 5
  Received Packets Delivered         = 80738
  Output Requests                    = 58186
  Routing Discards                   = 0
  Discarded Output Packets           = 0
  Output Packet No Route             = 0
  Reassembly Required                = 0
  Reassembly Successful              = 0
  Reassembly Failures                = 0
  Datagrams Successfully Fragmented  = 0
  Datagrams Failing Fragmentation    = 0
  Fragments Created                  = 0

ICMPv4 Statistics

                            Received    Sent
  Messages                  10274       14095
  Errors                    0           0
  Destination Unreachable   9804        13551
  Time Exceeded             226         0
  Parameter Problems        0           0
  Source Quenches           0           0
  Redirects                 0           0
  Echo Replies              242         2
  Echos                     2           542
  Timestamps                0           0
  Timestamp Replies         0           0
  Address Masks             0           0
  Address Mask Replies      0           0
  Router Solicitations      0           0
  Router Advertisements     0           0

ICMPv6 Statistics

                            Received    Sent
  Messages                  26583       63
  Errors                    0           0
  Destination Unreachable   0           0
  Packet Too Big            0           0
  Time Exceeded             0           0
  Parameter Problems        0           0
  Echos                     0           0
  Echo Replies              0           0
  MLD Queries               1295        0
  MLD Reports               0           0
  MLD Dones                 0           0
  Router Solicitations      0           21
  Router Advertisements     25256       0
  Neighbor Solicitations    14          21
  Neighbor Advertisements   18          21
  Redirects                 0           0
  Router Renumberings       0           0

TCP Statistics for IPv4

  Active Opens                        = 19429
  Passive Opens                       = 92
  Failed Connection Attempts          = 311
  Reset Connections                   = 5582
  Current Connections                 = 40
  Segments Received                   = 26774720
  Segments Sent                       = 17447761
  Segments Retransmitted              = 25840

TCP Statistics for IPv6

  Active Opens                        = 185
  Passive Opens                       = 3
  Failed Connection Attempts          = 182
  Reset Connections                   = 6
  Current Connections                 = 0
  Segments Received                   = 2358
  Segments Sent                       = 1758
  Segments Retransmitted              = 600

UDP Statistics for IPv4

  Datagrams Received    = 1459026
  No Ports              = 7342
  Receive Errors        = 0
  Datagrams Sent        = 675730

UDP Statistics for IPv6

  Datagrams Received    = 174033
  No Ports              = 5
  Receive Errors        = 0
  Datagrams Sent        = 49000

C:\Windows\System32>

Sadece TCP istatistiklerini göstermek için;

netstat -s -p tcp udp

Bu komut sadece TCP protokolleriyle ilgili istatistikleri listeler.

Örnek komut çıktısı;

C:\Windows\System32>netstat -s -p tcp

TCP Statistics for IPv4

  Active Opens                        = 19432
  Passive Opens                       = 92
  Failed Connection Attempts          = 311
  Reset Connections                   = 5582
  Current Connections                 = 33
  Segments Received                   = 26778211
  Segments Sent                       = 17449094
  Segments Retransmitted              = 25841

Active Connections

  Proto  Local Address          Foreign Address        State
  TCP    127.0.0.1:49669        view-localhost:49670   ESTABLISHED
  TCP    127.0.0.1:49670        view-localhost:49669   ESTABLISHED
  TCP    127.0.0.1:49672        view-localhost:49673   ESTABLISHED
  TCP    127.0.0.1:49673        view-localhost:49672   ESTABLISHED
  TCP    192.168.100.122:56775  20.199.120.182:https   ESTABLISHED
  TCP    192.168.100.122:56788  sof04s05-in-f10:https  ESTABLISHED
  TCP    192.168.100.122:56801  20.199.120.182:https   ESTABLISHED
  TCP    192.168.100.122:56953  relay-85da32ac:https   ESTABLISHED
  TCP    192.168.100.122:58526  en-in-f188:5228        ESTABLISHED
  TCP    192.168.100.122:59959  whatsapp-cdn-shv-01-sof1:https  ESTABLISHED
  TCP    192.168.100.122:63261  40.101.70.194:https    ESTABLISHED
  TCP    192.168.100.122:63288  ec2-54-236-104-103:https  ESTABLISHED
  TCP    192.168.100.122:63547  52.109.104.3:https     ESTABLISHED
  TCP    192.168.100.122:64074  52.112.100.57:https    ESTABLISHED
  TCP    192.168.100.122:64110  52.123.135.34:https    ESTABLISHED
  TCP    192.168.100.122:64153  52.97.168.178:https    ESTABLISHED
  TCP    192.168.100.122:64236  20.199.120.151:https   ESTABLISHED
  TCP    192.168.100.122:64297  40.99.150.98:https     TIME_WAIT
  TCP    192.168.100.122:64878  52.98.253.82:https     ESTABLISHED
  TCP    192.168.100.122:65101  172.64.155.209:https   ESTABLISHED

Sadece TCP istatistiklerini göstermek için;

netstat -s -p udp

Bu komut sadece TCP protokolleriyle ilgili istatistikleri listeler.

Örnek komut çıktısı;

C:\Windows\System32>netstat -s -p udp

UDP Statistics for IPv4

  Datagrams Received    = 1459855
  No Ports              = 7345
  Receive Errors        = 0
  Datagrams Sent        = 676184

Active Connections

  Proto  Local Address          Foreign Address        State

C:\Windows\System32>

Her 5 Saniyede Bir Aktif TCP Bağlantılarını ve PID’lerinin Listelenmesi

netstat -o 5

Bu komut her 5 saniyede bir sistemdeki aktif TCP bağlantılarını ve bu bağlantılarla ilişkili işlem kimliklerini (PID) gösterir.

Örnek komut çıktısı;

C:\Windows\System32>netstat -o 5

Active Connections

  Proto  Local Address          Foreign Address        State           PID
  TCP    127.0.0.1:49669        view-localhost:49670   ESTABLISHED     6660
  TCP    127.0.0.1:49670        view-localhost:49669   ESTABLISHED     6660
  TCP    127.0.0.1:49672        view-localhost:49673   ESTABLISHED     6660
  TCP    127.0.0.1:49673        view-localhost:49672   ESTABLISHED     6660
  TCP    192.168.100.122:56775  20.199.120.182:https   ESTABLISHED     18968
  TCP    192.168.100.122:56788  sof04s05-in-f10:https  ESTABLISHED     18904
  TCP    192.168.100.122:56801  20.199.120.182:https   ESTABLISHED     6628
  TCP    192.168.100.122:56953  relay-85da32ac:https   ESTABLISHED     6284
  TCP    192.168.100.122:58526  en-in-f188:5228        ESTABLISHED     2612
  TCP    192.168.100.122:59959  whatsapp-cdn-shv-01-sof1:https  ESTABLISHED     2612
  TCP    192.168.100.122:63261  40.101.70.194:https    ESTABLISHED     25468
  TCP    192.168.100.122:63288  ec2-54-236-104-103:https  ESTABLISHED     20080
  TCP    192.168.100.122:63547  52.109.104.3:https     ESTABLISHED     20568
  TCP    192.168.100.122:64074  52.112.100.57:https    ESTABLISHED     22052

Sayısal IP Adresleri ve PID ile Aktif Bağlantılarının Listelenmesi

Aşağıdaki komut bağlantıları sayısal IP adresleriyle birlikte gösterir ve aynı zamanda ilgili işlem kimliklerini (PID) içerir.

netstat -n -o
C:\Windows\System32>netstat -n -o

Active Connections

  Proto  Local Address          Foreign Address        State           PID
  TCP    127.0.0.1:49669        127.0.0.1:49670        ESTABLISHED     6660
  TCP    127.0.0.1:49670        127.0.0.1:49669        ESTABLISHED     6660
  TCP    127.0.0.1:49672        127.0.0.1:49673        ESTABLISHED     6660
  TCP    127.0.0.1:49673        127.0.0.1:49672        ESTABLISHED     6660
  TCP    192.168.100.122:56775  20.199.120.182:443     ESTABLISHED     18968
  TCP    192.168.100.122:56788  142.251.140.42:443     ESTABLISHED     18904
  TCP    192.168.100.122:56801  20.199.120.182:443     ESTABLISHED     6628
  TCP    192.168.100.122:56953  92.38.180.105:443      ESTABLISHED     6284
  TCP    192.168.100.122:58526  172.217.218.188:5228   ESTABLISHED     2612
  TCP    192.168.100.122:59959  157.240.9.53:443       ESTABLISHED     2612
  TCP    192.168.100.122:63261  40.101.70.194:443      ESTABLISHED     25468
  TCP    192.168.100.122:63288  54.236.104.103:443     ESTABLISHED     20080
  TCP    192.168.100.122:63547  52.109.104.3:443       ESTABLISHED     20568
  TCP    192.168.100.122:64074  52.112.100.57:443      ESTABLISHED     22052
  TCP    192.168.100.122:64110  52.123.135.34:443      ESTABLISHED     23036
  TCP    192.168.100.122:64153  52.97.168.178:443      ESTABLISHED     20568
  TCP    192.168.100.122:64236  20.199.120.151:443     ESTABLISHED     19256
  TCP    192.168.100.122:64878  52.98.253.82:443       ESTABLISHED     25468
  TCP    192.168.100.122:65104  116.202.53.24:443      ESTABLISHED     2612
  TCP    192.168.100.122:65142  52.98.241.194:443      ESTABLISHED     25468
  TCP    192.168.100.122:65146  216.239.38.223:443     CLOSE_WAIT      18904
  TCP    192.168.100.122:65151  52.111.243.4:443       ESTABLISHED     25468
  TCP    192.168.100.122:65157  2.19.193.57:443        CLOSE_WAIT      13768
  TCP    192.168.100.122:65160  52.97.189.66:443       ESTABLISHED     13768
  TCP    192.168.100.122:65170  52.111.243.13:443      ESTABLISHED     20568
  TCP    192.168.100.122:65181  20.189.173.17:443      TIME_WAIT       0
  TCP    192.168.100.122:65182  142.250.184.138:443    ESTABLISHED     2612
  TCP    192.168.100.122:65183  172.217.17.99:443      ESTABLISHED     2612
  TCP    192.168.100.122:65186  20.50.73.11:443        ESTABLISHED     54984
  TCP    192.168.100.122:65188  52.105.129.39:443      ESTABLISHED     18968
  TCP    192.168.100.122:65190  52.109.89.18:443       ESTABLISHED     53952
  TCP    192.168.100.122:65192  51.116.246.105:443     ESTABLISHED     20636

C:\Windows\System32>

Bu komut çıkıtılarında yer alan;

Proto : Kullanılan protokolün türü. TCP veya UDP şeklindedir.

Local Address : Yerel bilgisayarın IP adresi ve kullanılan portu

Foreign Address : Bağlantının hedef IP adresi ve port numarası.

State : Bağlantının durumu (ESTABLISHED, LISTEN, CLOSE_WAIT, vb.).

PID : Bağlantıyı oluşturan işlemin kimlik numarası (Process ID).

Bağlantı Durumları ve Anlamları

ESTABLISHEDBağlantı başarıyla kurulmuş ve veri transferi devam ediyor.
LISTENBelirtilen port gelen bağlantıları dinliyor.
CLOSE_WAITUzak sunucu bağlantıyı kapatmış ancak yerel sistem henüz tamamen kapatmamış.
CLOSEDBağlantı tamamen kapatılmış.
SYN_SENTİstemci tarafından bağlantı kurulmaya çalışılıyor.
SYN_RECEIVEDSunucu tarafından bağlantı talebi alınmış, ancak henüz tamamlanmamış.
TIME_WAITBağlantının kapanması için belirli bir süre bekleniyor.