netstat etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
netstat etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

20 Mart 2020 Cuma

netstat komutu

Giriş
Bu komut artık eskidi. netstat yerine ss komutu kullanılabilir. Açıklaması şöyle
NOTE
   This program is obsolete.  Replacement for netstat is ss.   Replacement
   for  netstat -r is ip route.  Replacement for netstat -i is ip -s link.
   Replacement for netstat -g is ip maddr.
Seçenekler şöyle
NAME
  netstat  -  Print  network connections, routing tables, interface statistics, 
    masquerade connections, and multicast memberships

SYNOPSIS
  netstat 
    [address_family_options]
    [--tcp|-t]
    [--udp|-u]
    [--raw|-w]
    [--listening|-l]
    [--all|-a]  
    [--numeric|-n]  
    [--numeric-hosts]  
    [--numeric-ports] 
    [--numeric-users]
    [--symbolic|-N] 
    [--extend|-e
    [--extend|-e]]  
    [--timers|-o]  
    [--program|-p]  
    [--verbose|-v]
    [--continuous|-c]

-a seçeneği
All anlamına gelir. netstat -t ile sadece dışarı giden bağlantıları görebiliriz.  Tüm bağlantıları görmek icin netstat - a -t yaparız.

-g seçeneği
Şöyle yaparız. Sunucunun dahil olduğu multicast gruplarını gösterir.
netstat -g
-l seçeneği
Listening anlamına gelir. Açıklaması şöyle
-l, --listening
   Show only listening sockets.  (These are omitted by default.)
Örnek
Dinleme yapan TCP sunucularını görmek için şöyle yaparız.
netstat -lptn
Çıktı olarak şunu alırız. -l ile sadece LISTEN durumundaki, -p ile PID, -t ile TCP ve -n ile metin yerine IP numaraları gösterilir.
Proto Recv-Q Send-Q Local Address     Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:9092    0.0.0.0:*               LISTEN      18949/java
tcp        0      0 127.0.0.1:38021   0.0.0.0:*               LISTEN      3518/java
tcp        0      0 0.0.0.0:8081      0.0.0.0:*               LISTEN      18949/java
tcp        0      0 0.0.0.0:38417     0.0.0.0:*               LISTEN      3518/java
tcp        0      0 127.0.0.1:53      0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:41623   0.0.0.0:*               LISTEN      15189/code
tcp        0      0 127.0.0.1:631     0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:43097   0.0.0.0:*               LISTEN      18949/java
-n seçeneği
Bağlantıların IP ve port numaralarını sayısal olarak gösterir. Açıklaması şöyle
--numeric, -n
   Show numerical addresses instead of trying to determine symbolic host,
   port or user names.
Örnek
Şöyle yaparız Linux'ta Listening TCP portları listelenmesi anlatılmış.
-t : Tcp only
-l : listening ports
-n : just numbers
-p : show process info
me@myhost:~$ sudo netstat -tlnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address   Foreign Address   State    PID/Program name
tcp        0      0 127.0.0.1:53    0.0.0.0:*         LISTEN   1004/dnsmasq    
tcp        0      0 0.0.0.0:22      0.0.0.0:*         LISTEN   380/sshd        
tcp        0      0 127.0.0.1:631   0.0.0.0:*         LISTEN   822/cupsd       
tcp6       0      0 :::22           :::*              LISTEN   380/sshd        
tcp6       0      0 ::1:631         :::*              LISTEN   822/cupsd 
-p seçeneği

Linux'ta process numaralarını gösterir. Açıklaması şöyle
-p, --program
   Show the PID and name of the program to which each socket belongs.
Örnek
Şöyle yaparız. 2401 process numarasıdır.
# netstat -apn | grep fe80::cef1:3
tcp6       0      0 fe80::cef1:12345 fe80::cef1:34660 ESTABLISHED 2401/xxxx
Örnek
Şöyle yaparız. En sağdaki sütunda process numaraları görülebilir.
$ netstat -tulpen
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode      PID/Program name    
tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN      112        62240      -                   
tcp        0      0 127.0.0.1:8000          0.0.0.0:*               LISTEN      1000       65495      48618/python        
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      101        23068      -                   
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      0          27689      -                   
tcp6       0      0 :::5432                 :::*                    LISTEN      112        62241      -                   
tcp6       0      0 :::9090                 :::*                    LISTEN      0          71091      -                   
tcp6       0      0 :::22                   :::*                    LISTEN      0          27691      -                   
udp        0      0 127.0.0.53:53           0.0.0.0:*                           101        23067      -                   
udp        0      0 192.168.0.15:68         0.0.0.0:*                           100        23071      -                   
udp6       0      0 fe80::224:e8ff:fe22:546 :::*                                100        23086      -  
-t seçeneği
TCP protokolü içindir.  Açıklaması şöyle
--tcp|-t

--udp|-u

-l, --listening
   Show only listening sockets.  (These are omitted by default.)

-p, --program
   Show the PID and name of the program to which each socket belongs.

--numeric, -n
   Show numerical addresses instead of trying to determine symbolic host,
   port or user names.
Örnek
TCP ve UDP dinleyen uygulamaları görmek için şöyle yaparız.
netstat -tulpn
-u seçeneği
UDP protokolü içindir. Açıklaması şöyle
--udp|-u
Örnek
netstat -antup ile şuna benzer bir çıktı alırız.
13:tcp        0      0 0.0.0.0:3333 0.0.0.0:*  LISTEN      26566/./test