Ss: Difference between revisions

From ICO wiki
Jump to navigationJump to search
Toolup (talk | contribs)
Toolup (talk | contribs)
Line 69: Line 69:
<pre>ss -lp | grep 5037</pre>
<pre>ss -lp | grep 5037</pre>
<pre>tcp    LISTEN    0      4            127.0.0.1:5037                  *:*        users:(("adb",6962,7))
<pre>tcp    LISTEN    0      4            127.0.0.1:5037                  *:*        users:(("adb",6962,7))
</pre>
==Ajaline võit netstati ees==
laseme käima käsud:
<pre>time netstat -at</pre>
<pre>
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address          Foreign Address        State     
tcp        0      0 localhost:5037          *:*                    LISTEN   
tcp        0      0 localhost:ipp          *:*                    LISTEN   
time ss -tcp        0      0 10.0.2.15:60669        185.31.17.196:http      ESTABLISHED
tcp        0      0 10.0.2.15:56441        185.31.17.134:http      ESTABLISHED
tcp        0      0 10.0.2.15:41429        fra07s27-in-f25.1:https ESTABLISHED
tcp        0      0 localhost:37715        localhost:5037          ESTABLISHED
tcp        0      0 10.0.2.15:33566        fra02s17-in-f2.1e1:http ESTABLISHED
tcp        0      0 10.0.2.15:37794        track.adform.net:https  ESTABLISHED
tcp        0      0 10.0.2.15:41433        fra07s27-in-f25.1:https ESTABLISHED
tcp        0      0 10.0.2.15:37796        track.adform.net:https  ESTABLISHED
tcp        0      0 localhost:5037          localhost:37715        ESTABLISHED
tcp        0      0 10.0.2.15:60670        185.31.17.196:http      ESTABLISHED
tcp        0      0 10.0.2.15:37795        track.adform.net:https  ESTABLISHED
tcp6      0      0 [::]:http              [::]:*                  LISTEN   
tcp6      0      0 ip6-localhost:ipp      [::]:*                  LISTEN   
real 0m30.294s
user 0m0.000s
sys 0m0.012s
</pre>
<pre>time ss -atr</pre>
<pre>State      Recv-Q Send-Q      Local Address:Port          Peer Address:Port 
LISTEN    0      4              localhost:5037                    *:*     
LISTEN    0      128            localhost:ipp                      *:*     
ESTAB      0      0              10.0.2.15:60669        185.31.17.196:http   
ESTAB      0      0              10.0.2.15:56441        185.31.17.134:http   
ESTAB      0      0              localhost:37715            localhost:5037   
ESTAB      0      0              10.0.2.15:33566  fra02s17-in-f2.1e100.net:http   
ESTAB      0      0              10.0.2.15:37794    track.adform.net:https 
ESTAB      0      0              10.0.2.15:37796    track.adform.net:https 
ESTAB      0      0              localhost:5037            localhost:37715 
ESTAB      0      0              10.0.2.15:60670        185.31.17.196:http   
ESTAB      0      0              10.0.2.15:37795    track.adform.net:https 
LISTEN    0      128                    :::http                    :::*     
LISTEN    0      128        ip6-localhost:ipp                    :::*     
real 0m25.034s
user 0m0.000s
sys 0m0.008s
</pre>
</pre>

Revision as of 14:26, 22 May 2015

Autor

Nimi: Tammo Oolup

Rühm: A32


Sissejuhatus

Ss on käsurea tööriist, mille abil saab vaadata võrgus toimuvat. Sarnane tööriist on ka netstat aga ss on uuem ja ka kiirem kuna võtab informatsiooni otse kerneli ruumist, mitte /proc failidest nagu netstat. Lisaks kuvab ta rohkem informatsiooni TCP ja UDP ja teiste pesade infot kui mistahes teine tööriist.

Kasutamine

TCP pesa info jaoks:

ss -s
Total: 567 (kernel 636)
TCP:   7 (estab 2, closed 1, orphaned 0, synrecv 0, timewait 0/0), ports 0

Transport Total     IP        IPv6
*	  636       -         -        
RAW	  0         0         0        
UDP	  21        12        9        
TCP	  6         4         2        
INET	  27        16        11       
FRAG	  0         0         0   

Kõikide võrgu portide vaatamiseks:

ss -l

Parema lugemise huvides võib tulemuse suunata lessi:

ss -l | less
Netid  State      Recv-Q Send-Q   Local Address:Port       Peer Address:Port   
tcp    UNCONN     0      0         fe80::a00:27ff:fe5c:c5c1:ipproto-123              :::*       
tcp    UNCONN     0      0         fe80::a00:27ff:fe25:7a4d:ipproto-123              :::*       
tcp    UNCONN     0      0                  ::1:ipproto-123              :::*       
tcp    UNCONN     0      0                   :::ipproto-123              :::*       
tcp    UNCONN     0      0                   :::ipproto-5353              :::*       
tcp    UNCONN     0      0                   :::ipproto-52490              :::*       
tcp    LISTEN     0      4            127.0.0.1:5037                  *:*       
tcp    LISTEN     0      128          127.0.0.1:ipp                   *:*       
tcp    LISTEN     0      128                 :::http                 :::*       
tcp    LISTEN     0      128                ::1:ipp                  :::*  

Ainult TCP portide vaatamiseks (näitab ainult mis on Connected või Established, mida vaikimisi kuulatakse, neid ei kuvata): muutes võtmeväärtuse -t -> -u, kuvatakse udp pordid

ss -t
State      Recv-Q Send-Q      Local Address:Port          Peer Address:Port   
ESTAB      0      0               127.0.0.1:37715            127.0.0.1:5037    
ESTAB      0      0               10.0.2.15:48251         85.235.246.2:https   
ESTAB      0      0               10.0.2.15:42362         37.157.6.226:http    
ESTAB      0      0               127.0.0.1:5037             127.0.0.1:37715

Kuulatavate portide vaatamiseks (Näitab ainult neid mida kuulatakse, näiteks Apache veebiserver avab ühenduse porti 80 sissetulevate ühenduste kuulamiseks): n keelab ip aadressi nimeteisenduse, et tulemust kuvatakse kiiremini, t tähistab tcp ühendusi, ja l tähistab listening ehk kuulamist

ss -ltn
State      Recv-Q Send-Q        Local Address:Port          Peer Address:Port 
LISTEN     0      4                 127.0.0.1:5037                     *:*     
LISTEN     0      128               127.0.0.1:631                      *:*     
LISTEN     0      128                      :::80                      :::*     
LISTEN     0      128                     ::1:631                     :::*    

Mingi konkreetse pordi järgi otsimiseks võime kasutada grepi, näiteks:

ss -lp | grep 5037
tcp    LISTEN     0      4            127.0.0.1:5037                  *:*        users:(("adb",6962,7))

Ajaline võit netstati ees

laseme käima käsud:

time netstat -at
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 localhost:5037          *:*                     LISTEN     
tcp        0      0 localhost:ipp           *:*                     LISTEN     
time ss -tcp        0      0 10.0.2.15:60669         185.31.17.196:http      ESTABLISHED
tcp        0      0 10.0.2.15:56441         185.31.17.134:http      ESTABLISHED
tcp        0      0 10.0.2.15:41429         fra07s27-in-f25.1:https ESTABLISHED
tcp        0      0 localhost:37715         localhost:5037          ESTABLISHED
tcp        0      0 10.0.2.15:33566         fra02s17-in-f2.1e1:http ESTABLISHED
tcp        0      0 10.0.2.15:37794         track.adform.net:https  ESTABLISHED
tcp        0      0 10.0.2.15:41433         fra07s27-in-f25.1:https ESTABLISHED
tcp        0      0 10.0.2.15:37796         track.adform.net:https  ESTABLISHED
tcp        0      0 localhost:5037          localhost:37715         ESTABLISHED
tcp        0      0 10.0.2.15:60670         185.31.17.196:http      ESTABLISHED
tcp        0      0 10.0.2.15:37795         track.adform.net:https  ESTABLISHED
tcp6       0      0 [::]:http               [::]:*                  LISTEN     
tcp6       0      0 ip6-localhost:ipp       [::]:*                  LISTEN     

real	0m30.294s
user	0m0.000s
sys	0m0.012s
time ss -atr
State      Recv-Q Send-Q      Local Address:Port          Peer Address:Port   
LISTEN     0      4               localhost:5037                     *:*       
LISTEN     0      128             localhost:ipp                      *:*       
ESTAB      0      0               10.0.2.15:60669        185.31.17.196:http    
ESTAB      0      0               10.0.2.15:56441        185.31.17.134:http    
ESTAB      0      0               localhost:37715            localhost:5037    
ESTAB      0      0               10.0.2.15:33566   fra02s17-in-f2.1e100.net:http    
ESTAB      0      0               10.0.2.15:37794     track.adform.net:https   
ESTAB      0      0               10.0.2.15:37796     track.adform.net:https   
ESTAB      0      0               localhost:5037             localhost:37715   
ESTAB      0      0               10.0.2.15:60670        185.31.17.196:http    
ESTAB      0      0               10.0.2.15:37795     track.adform.net:https   
LISTEN     0      128                    :::http                    :::*       
LISTEN     0      128         ip6-localhost:ipp                     :::*       

real	0m25.034s
user	0m0.000s
sys	0m0.008s