Site, Server Genel » Genel Makaleler

Netstat Nedir ve Nasıl Kullanılır?

http://forum.whmdestek.com/

Go Back   WHM/cPanel Support Platform » Türkçe » Site, Sunucu Sorunlarınız ve Çözümleri » Site, Server Genel » Genel Makaleler
 


Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 21.07.08, 00:10
Ni-Osman's Avatar
Linux HelpDesk
 
Join Date: Feb 2008
Location: Denizli
Posts: 274
Rep Power: 7013
Ni-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond repute
Send a message via MSN to Ni-Osman Send a message via Yahoo to Ni-Osman Send a message via Skype™ to Ni-Osman
Netstat Nedir ve Nasıl Kullanılır?

Netstat konusunda kısa giriş bilgileri vereceğim. Netstat (network statistics) Network bağlantıları, routing tablosu, ara birim istatistikleri ve benzeri ağ bağlantısı bilgileri ile ilgili ayrıntılı bilgiler verebilen bir konsol komutudur.

Netstat komutu çeşitli parametrelerle kullanılmaktadır. Bu parametrelerin anlamları şunlardır:

-a Tüm TCP ve UDP bağlantıları ekrana basar
-e Gelen ve giden paket sayısını istatistiklerini görüntüler
-n Tüm bağlantıları rakamsal olarak görüntüler
-o Tüm bağlantıları PID numarası ve uygulama adına göre listeler
-p Bağlantıların kullandığı uygulama ve PID numarasını ekrana basar
-s Kurallara göre istatistiksel verileri ekrana basar
-r IP Yönlendirme tablosunu içeriğini görüntüler.

Netstat çıktısında yer alan bağlantı durumlarının anlamları da şunlardır:

ESTABLISHED : Soket bağlantı gerçekleştirmiş durumdadır.
SYN_SENT : Soket bağlantı kurmaya çalışıyordur.
SYN_RECV : Ağdan bir bağlantı isteği gelmiştir.
FIN_WAIT1 : Soket kapatılmış , bağlantı sonlandırılmak üzeredir.
FIN_WAIT2 : Bağlantı sonlandırılmıştır. Soket karşı ucun bağlantıyı sonlandırmasını beklemektedir.
TIME_WAIT : Soket kapndıktan sonra gelebilecek paketleri alabilmek için beklemektedir.
CLOSED : Soket kullanılmamaktadır.
CLOSE_WAIT : Karşı uç bağlantıyı kapatmıştır. Soketin kapanması beklenmektedir.
LAST_ACK : Karşı uç bağlantıyı sonlandırmış ve soketi kapatmıştır. Onay beklenmektedir.
LISTEN : Soket gelebilecek bağlantılar için dinleme konumundadır.
CLOSING : Yerel ve uzak soketler kapatılmış fakat tüm verilerini göndermemiş durumdadırlar. Tüm veriler gönderilmeden soketler kapanmazlar.

SSH üzerinde netstat çıktılarını almak için bazı örnek komutlar..

netstat -ntu


tüm TCP ve UDP bağlantıları listeler (rakamsal olarak)

netstat -ntu | grep SYN


tüm TCP ve UDP bağlantılar içinde SYN_SENT ve SYN_RECV bağlantı durumlarını ekrana basar

grep sonrasında yer alan kısmı kendi isteğinize göre değiştirebilirsiniz. Örnek komut yazacak olursak

netstat -ntu | grep ESTABLISHED


ekrana sadece ESTABLISHED olan bağlantı durumlarını basar..

netstat -ntu | awk '{print $5}' | awk '{sub("::ffff:","");print}' | cut -f1 -d ':' | sort | uniq -c | sort -n | grep -v -e server -e Address -e 127.0.0.1 -e 0.0.0.0


Yukarıda yer alan komut ffff tablosu ile ekrana basılan değerler dahil tüm ip listesini küçükten büyüye göre sıralar. Yine komuta grep ekleyerek bağlantı durumuna göre listeleme yapabiliriz.

for i in $(netstat -ntu | awk '{print $5}' | awk '{sub("::ffff:","");print}' | cut -f1 -d ':' | sort | uniq -c | sort -n | grep -v -e server -e Address -e 127.0.0.1 -e 0.0.0.0 | awk '{ if ($1 > 30) print $2 }'); do /usr/sbin/csf -d $i;done


Yukarıda yer alan komut ise 30 rakamından büyük bağlantı sayısı oluşturan tüm ipleri csf firewall yazılımı aracılığı ile banlayarak sunucudan uzaklaştırılır. Son awk yazılımında yer alan 30 değerini yükselterek limiti arttırabilir yine netstat sonrası grep ekleyerek sıralamayı belirli bağlantı durumlarına göre listeleyebilirsiniz.

netstat ile bunun dışında birçok yazılımınızın istatistik toplayarak kullanacağı en yararlı ağ komutlarından biridir.

netstat ile ilgili sormak istediklerinizi yazabilirsiniz.

İyi çalışmalar.

Netstat Nedir? Nasıl Kullanılır? | linux10.net
__________________
Netinternet Telekom
Artık daha çok zamanınız var!


Üyelik ve Partnerlikler :cPanel INC. , Parallels , DirectAdmin , Netenberg , RIPE , Redhat , Microsoft(Bitmedi) ,GeoTurst
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2  
Old 21.07.08, 00:13
Ni-Osman's Avatar
Linux HelpDesk
 
Join Date: Feb 2008
Location: Denizli
Posts: 274
Rep Power: 7013
Ni-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond repute
Send a message via MSN to Ni-Osman Send a message via Yahoo to Ni-Osman Send a message via Skype™ to Ni-Osman
Konu ile ilgili

netstat -nap | grep httpd

yazmanız durumunda elde edilecek PID numaralarını apache status üzerinde aratarak hangi ip adresinin hangi siteye girdiğini kolayca bulabilirsiniz.

Çok fazla istek yapan 10.0.0.7 ip sini

netstat -nap | grep 10.0.0.7 | grep httpd

şeklinde aratmanız durumunda aldığınız PID numaralarını apache status da aratarak hangi siteye istekler gönderdiğini rahatca bulabilirsiniz.
__________________
Netinternet Telekom
Artık daha çok zamanınız var!


Üyelik ve Partnerlikler :cPanel INC. , Parallels , DirectAdmin , Netenberg , RIPE , Redhat , Microsoft(Bitmedi) ,GeoTurst
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old 04.09.08, 04:11
Celeron
 
Join Date: Jan 2008
Location: Gonya
Posts: 97
Rep Power: 2
aydin is on a distinguished road
TIME_WAIT oranının yüksek olması ve bunun tek bir yerden olması siteye oradan saldırı geliyor olabilecegine işaret olurmu ?

aşagıda sadece kücük bir kısmı var gecenin 5 i cok fazla oranda bu lesaweb denen yerden var

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old 04.09.08, 04:14
Ni-Osman's Avatar
Linux HelpDesk
 
Join Date: Feb 2008
Location: Denizli
Posts: 274
Rep Power: 7013
Ni-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond reputeNi-Osman has a reputation beyond repute
Send a message via MSN to Ni-Osman Send a message via Yahoo to Ni-Osman Send a message via Skype™ to Ni-Osman
Bu çıktıyı hangi komut ile aldınız

netstat -ntu da RDNS ler yazmaz..

yazdıgınız komudu söylerseniz güzel bir komut veirim bu konu ile ilgil.
__________________
Netinternet Telekom
Artık daha çok zamanınız var!


Üyelik ve Partnerlikler :cPanel INC. , Parallels , DirectAdmin , Netenberg , RIPE , Redhat , Microsoft(Bitmedi) ,GeoTurst
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old 04.09.08, 06:17
Celeron
 
Join Date: Jan 2008
Location: Gonya
Posts: 97
Rep Power: 2
aydin is on a distinguished road
netstat -a olarak sunucuya baglı reselleri yazdım

-ntu çıktısının bir kısmı aşagıda bu seferde ip olarak fakat yine leaseweb e ait ipiler



Quote:
tcp 0 0 84.16.252.94:59852 85.17.215.67:22 TIME_WAIT
tcp 0 0 84.16.252.94:58065 85.17.213.74:22 TIME_WAIT
tcp 0 0 84.16.252.94:59417 85.17.212.190:22 TIME_WAIT
tcp 0 0 84.16.252.94:59417 85.17.212.190:22 TIME_WAIT
tcp 0 0 84.16.252.94:59655 85.17.212.191:22 TIME_WAIT
tcp 0 0 84.16.252.94:57603 85.17.212.183:22 TIME_WAIT
tcp 0 0 84.16.252.94:59508 85.17.212.190:22 TIME_WAIT
tcp 0 0 84.16.252.94:58770 85.17.213.77:22 TIME_WAIT
tcp 0 0 84.16.252.94:58728 85.17.212.179:22 TIME_WAIT
tcp 0 0 84.16.252.94:57921 85.17.212.180:22 TIME_WAIT
tcp 0 0 84.16.252.94:57242 85.17.213.136:22 TIME_WAIT
tcp 0 0 84.16.252.94:57956 85.17.213.74:22 TIME_WAIT
tcp 0 0 84.16.252.94:59770 85.17.215.67:22 TIME_WAIT
tcp 0 0 84.16.252.94:57218 85.17.212.137:22 TIME_WAIT
tcp 0 0 84.16.252.94:57731 85.17.212.183:22 TIME_WAIT
tcp 0 0 84.16.252.94:59784 85.17.212.191:22 TIME_WAIT
tcp 0 0 84.16.252.94:59616 85.17.212.190:22 TIME_WAIT
tcp 0 0 84.16.252.94:58659 85.17.213.77:22 TIME_WAIT
tcp 0 0 84.16.252.94:58049 85.17.212.180:22 TIME_WAIT
tcp 0 0 84.16.252.94:58827 85.17.212.179:22 TIME_WAIT
tcp 0 0 84.16.252.94:59967 85.17.212.189:22 ESTABLISHED
tcp 0 0 84.16.252.94:58175 85.17.212.180:22 TIME_WAIT
tcp 0 0 84.16.252.94:59425 85.17.212.191:22 TIME_WAIT
tcp 0 0 84.16.252.94:57372 85.17.212.183:22 TIME_WAIT
tcp 0 0 84.16.252.94:57372 85.17.212.183:22 TIME_WAIT
tcp 0 0 84.16.252.94:59634 85.17.215.67:22 TIME_WAIT
tcp 0 0 84.16.252.94:59528 85.17.215.67:22 TIME_WAIT
tcp 0 0 84.16.252.94:57470 85.17.212.183:22 TIME_WAIT
tcp 0 0 84.16.252.94:57210 85.17.213.137:22 TIME_WAIT
tcp 0 0 84.16.252.94:59748 85.17.212.190:22 TIME_WAIT
tcp 0 0 84.16.252.94:58462 85.17.212.179:22 TIME_WAIT
tcp 0 0 84.16.252.94:57165 85.17.212.136:22 TIME_WAIT
tcp 0 0 84.16.252.94:58548 85.17.213.77:22 TIME_WAIT
tcp 0 0 84.16.252.94:58293 85.17.213.74:22 TIME_WAIT
tcp 0 0 84.16.252.94:59837 85.17.212.190:22 TIME_WAIT
tcp 0 0 84.16.252.94:58298 85.17.212.180:22 TIME_WAIT
tcp 0 0 84.16.252.94:58472 85.17.213.77:22 TIME_WAIT
tcp 0 0 84.16.252.94:59541 85.17.212.191:22 TIME_WAIT
tcp 0 0 84.16.252.94:58373 85.17.213.77:22 TIME_WAIT
tcp 0 0 84.16.252.94:59929 85.17.213.67:22 ESTABLISHED
tcp 0 0 84.16.252.94:58596 85.17.212.179:22 TIME_WAIT
tcp 0 0 84.16.252.94:57323 85.17.213.137:22 TIME_WAIT
tcp 0 0 84.16.252.94:58152 85.17.213.74:22 TIME_WAIT
tcp 0 0 84.16.252.94:57286 85.17.212.136:22 TIME_WAIT
tcp 0 0 84.16.252.94:59957 85.17.212.190:22 ESTABLISHED
tcp 0 0 84.16.252.94:57404 85.17.212.180:22 TIME_WAIT
tcp 0 0 84.16.252.94:59180 85.17.212.179:22 TIME_WAIT
tcp 0 0 84.16.252.94:57215 85.17.212.139:22 TIME_WAIT
tcp 0 0 84.16.252.94:57479 85.17.213.74:22 TIME_WAIT
tcp 0 0 84.16.252.94:58209 85.17.212.183:22 TIME_WAIT
tcp 0 0 84.16.252.94:59759 85.17.212.189:22 TIME_WAIT
tcp 0 0 84.16.252.94:59816 85.17.213.67:22 TIME_WAIT
tcp 0 0 84.16.252.94:59314 85.17.213.77:22 TIME_WAIT
tcp 0 0 84.16.252.94:57522 85.17.212.180:22 TIME_WAIT
tcp 0 0 84.16.252.94:59308 85.17.212.179:22 TIME_WAIT
tcp 0 0 84.16.252.94:59216 85.17.213.77:22 TIME_WAIT
tcp 0 0 84.16.252.94:57325 85.17.212.139:22 TIME_WAIT
tcp 0 0 84.16.252.94:58321 85.17.212.183:22 TIME_WAIT
tcp 0 0 84.16.252.94:57379 85.17.213.74:22 TIME_WAIT
tcp 0 0 84.16.252.94:59844 85.17.212.189:22 TIME_WAIT
tcp 0 0 84.16.252.94:59708 85.17.213.67:22 TIME_WAIT
tcp 0 0 84.16.252.94:57833 85.17.213.74:22 TIME_WAIT
tcp 0 0 84.16.252.94:59421 85.17.212.189:22 TIME_WAIT
tcp 0 0 84.16.252.94:57312 85.17.213.116:22 TIME_WAIT
tcp 0 0 84.16.252.94:59105 85.17.213.77:22 TIME_WAIT
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Memcached nedir? Nasıl kurulur? wmaster Genel Soru ve Cevaplar 2 21.12.08 05:09
Nano Nedir? Nasıl Kurulur? Mutlu SSH Makaleler 27 22.11.08 17:50
Safe Mod Nedir, Nasıl Açılır, Joomla Siteler İçin Özel Safe Mod Değeri Vermek ? RAMBilisim Güvenlik Makaleler 20 27.02.08 02:11
Migrasyon Servisi Nedir Nasıl Kullanılır ? prowas Genel Soru ve Cevaplar 1 06.12.07 14:10
SQL Injection nedir ve nasıl korunulur ? CaLViN DB Makaleler 0 14.06.07 18:02




Navigasyon
Menü