How to monitor your Linux machine with netstat कैसे netstat के साथ अपने Linux मशीन पर नजर रखने के लिए

by Sukrit Dhandhania on January 19, 2009 Sukrit Dhandhania द्वारा 19 जनवरी 2009 पर

लिनक्ससुरक्षा

Netstat is an extremely useful Linux command line tool that allows you to check which service is connecting to a port on your machine. Netstat एक अत्यंत उपयोगी Linux कमांड लाइन उपकरण है जो आपको देखने के लिए जो सेवा अपने मशीन पर एक बंदरगाह से जोड़ने के लिए है की अनुमति देता है. It is very useful to analyze what's going on on your machine when you are facing or trying to to prevent an attack on it. यह बहुत विश्लेषण क्या पर अपना जब तुम सामना कर रहे हैं मशीन पर जा रहा है या उस पर हमले रोकने के लिए कोशिश कर रहा उपयोगी है. You can find information such as how many connection are being made on a port, which IP addresses these connections originate from, and much more. तुम ऐसे कितने कनेक्शन एक बंदरगाह पर किए जा रहे हैं, जो आई पी पतों को इन कनेक्शनों से उत्पन्न है, और के रूप में जानकारी प्राप्त कर सकते हैं और अधिक. Netstat ships with most distributions of Linux so it should already be installed on yours. Linux के सर्वाधिक वितरण के साथ Netstat जहाज तो यह पहले से ही तुम्हारा पर स्थापित किया जाना चाहिए.

Launch a shell terminal on your machine and run the following command: आपकी मशीन पर एक खोल टर्मिनल लांच और निम्न कमांड चलायें:

# netstat -ant # Netstat-चींटी
Active Internet connections (servers and established) सक्रिय इंटरनेट कनेक्शन सर्वर (और स्थापित)
Proto Recv-Q Send-Q Local Address Foreign Address State आद्य Recv-क्यू भेजें-क्यू स्थानीय पता विदेश राज्य पता
tcp 0 0 ::ffff:192.168.1.19:80 ::ffff:192.168.1.240:63049 TIME_WAIT 0 0 टी सी पी:: ffff: 192.168.1.19:80:: ffff: 192.168.1.240:63049 TIME_WAIT
tcp 0 0 ::ffff:192.168.0.19:80 ::ffff:192.168.1.240:62793 TIME_WAIT 0 0 टी सी पी:: ffff: 192.168.0.19:80:: ffff: 192.168.1.240:62793 TIME_WAIT
tcp 0 0 ::ffff:192.168.1.19:80 ::ffff:192.168.1.240:62795 TIME_WAIT 0 0 टी सी पी:: ffff: 192.168.1.19:80:: ffff: 192.168.1.240:62795 TIME_WAIT

The output will most likely be very long. सबसे अधिक उत्पादन होने की संभावना बहुत देर हो जाएगा. I've just given a snapshot of the output above. मैं अभी ऊपर उत्पादन का एक स्नैपशॉट दिया है. As you can see in the data above there is a connection made from 192.168.1.240 to my server's port 80 using the TCP protocol and the connection in the a state of TIME_WAIT. जैसा कि आप उपरोक्त डेटा में देख सकता हूँ वहाँ एक 192.168.1.240 से अपने सर्वर 80 बंदरगाह के लिए TCP प्रोटोकॉल और TIME_WAIT के एक राज्य में कनेक्शन का उपयोग कर बनाया संबंध है. The out put that you get for your server will have information about all the ports on your machine, not just port 80. बाहर रखा है कि आप अपने सर्वर के लिए मिल अपने मशीन पर सभी बंदरगाह, 80 बस बंदरगाह के बारे में जानकारी नहीं होगा.

The first thing you realize is that an output this big is not of too much use. पहली बात तुम्हें पता है कि एक उत्पादन इस बड़े बहुत काम का नहीं है. So let's organize it a bit. तो चलो यह एक बिट का आयोजन. Here are a few tricks I use to analyze the nature of the connections being made to of from my server. यहाँ कुछ गुर मैं कनेक्शन की प्रकृति का विश्लेषण का प्रयोग कर रहे हैं मेरे सर्वर से के लिए किया जा रहा है. the first thing I do is figure out which services I want to analyze. पहली बात मैं कर आंकड़ा जो बाहर सेवाओं मैं विश्लेषण करना चाहते है. Usually it is port 80 as that's the default port for the web server to run on, and port 3306 which is the default port for MySQL to run on. आमतौर पर यह है कि बंदरगाह के रूप में वेब सर्वर पर चलाने के लिए डिफ़ॉल्ट बंदरगाह है 80, बंदरगाह और 3,306 जो MySQL के लिए डिफ़ॉल्ट बंदरगाह पर चलाया जाता है. So i use the following query to see what's going on on port 80: मैं तो निम्न क्वेरी के उपयोग के लिए क्या 80 बंदरगाह पर चल रहा है देखें:

# netstat -ant | grep 80 # Netstat-चींटी | 80 grep

Again I get big list of connections, smaller than the first, but still too big to grasp. फिर मैं कनेक्शन की बड़ी सूची जाओ, पहले से छोटा है, लेकिन अभी भी समझ बड़ा है. So I use the “wc -l” command to count the number of lines in the output to see approximately how many connections I have on my port 80: तो मैं "WC-L कमांड का प्रयोग करने के लिए" उत्पादन में लाइनों की संख्या गिनने के लिए लगभग कितने कनेक्शन मैं अपने 80 बंदरगाह पर देखें:

# netstat -ant | grep 80 | wc -l # Netstat-चींटी | grep 80 | L WC -
625 625

And then I do the same for MySQL: और फिर मैं MySQL के लिए ही कार्य करें:

# netstat -ant | grep 3306 | wc -l # Netstat-चींटी | grep 3,306 | L WC -
61 61

Now, if I want to get a complete picture of what's going on on my server in terms of the nature of connections here's what I do: अब, अगर मैं किस पर मेरे सर्वर पर कनेक्शन के स्वरूप के रूप में हो रहा है यहाँ की एक पूरी तस्वीर मिल चाहती है मुझे क्या करना:

# netstat -ant | awk '{print $6}' | sort | uniq -c | sort -n # Uniq netstat-चींटी | 'awk (6 $ प्रिंट)' | तरह |-c | प्रकार-n

1 established) की स्थापना 1)
1 Foreign 1 विदेश
4 FIN_WAIT2 4 FIN_WAIT2
8 LISTEN 8 सुनो
16 CLOSE_WAIT 16 CLOSE_WAIT
134 ESTABLISHED 134 ESTABLISHE डी
409 TIME_WAIT 409 TIME_WAIT

This tells me how many connections of different types of state I have on my machine. यह मेरे राज्य मैं अपने मशीन पर विभिन्न प्रकार के कितने कनेक्शन बताता है. I can run a similar command to see a complete picture of the state of all the connections made to my web server: मैं एक ऐसे ही कमांड चलाने के लिए सब मेरी वेब सर्वर में बनाये गये कनेक्शन के राज्य की एक पूरी तस्वीर देख सकते हैं:

netstat -ant | grep 80 | awk '{print $6}' | sort | uniq -c | sort -n uniq netstat-चींटी | grep 80 | 'awk (6 $ प्रिंट)' | तरह |-c | प्रकार-n

1 FIN_WAIT1 1 FIN_WAIT1
4 LISTEN 4 सुनो
6 FIN_WAIT2 6 FIN_WAIT2
17 CLOSE_WAIT 17 CLOSE_WAIT
94 ESTABLISHED 94 ESTABLISHE डी
534 TIME_WAIT 534 TIME_WAIT

You can perform a lot more complex things using Netstat along with other Linux command line tools. तुम बहुत अधिक जटिल Netstat का उपयोग कर के साथ अन्य Linux कमांड लाइन उपकरण के साथ काम कर सकती है. It can be helpful to be familiar with some tricks to get this kind of information using Netstat, particularly when you are facing an attack on your server. यह कुछ चाल से परिचित होना उपयोगी जानकारी के लिए इस तरह की Netstat का उपयोग कर ले जा सकता, खासकर तब जब आप अपने सर्वर पर एक हमले का सामना कर रहे हैं.

Related Posts: संबंधित पोस्ट:
  • How to monitor your Internet bandwidth usage in Windows कैसे अपने इंटरनेट की निगरानी के लिए Windows में बैंडविड्थ उपयोग
  • How to monitor your Mac laptop's battery health कैसे अपने मैक है लैपटॉप बैटरी के स्वास्थ्य पर नजर रखने के लिए
  • How to use dstat to monitor your Linux/UNIX server कैसे dstat उपयोग के लिए आपके Linux / यूनिक्स सर्वर की निगरानी
  • How to set the date on your Linux machine कैसे आपके Linux मशीन पर स्थापित करने की तारीख
  • How to monitor your Internet bandwidth usage in OS X कैसे अपने इंटरनेट की निगरानी के लिए ओएस एक्स में बैंडविड्थ उपयोग
  • Get Simple Help tutorials just like this one in your email inbox every day - for free! बस अपने ईमेल इनबॉक्स के लिए मुफ्त हर दिन - में यह एक तरह सरल सहायता ट्यूटोरियल जाओ! Just enter your email address below: बस नीचे अपना ईमेल पता दर्ज करें:

    You can always opt out of this email subscription at any time. तुम हमेशा इस ईमेल सदस्यता से बाहर किसी भी समय विकल्प चुन सकते हैं.

    { 2 comments… read them below or (2 टिप्पणियाँ ... उन्हें या नीचे पढ़ें add one एक जोड़ } )

    1 1 Quetzal Quetzal 04.06.09 at 8:39 am 8:39 पर 04.06.09 हूँ

    nice web translation अच्छा वेब अनुवाद :-P

    2 2 Swaroop - India Web Hosting स्वरूप - भारत वेब होस्टिंग 06.18.09 at 12:07 am 12:07 पर 06.18.09 हूँ

    Nice Tutorial! अच्छा ट्यूटोरियल!

    Leave a Comment एक टिप्पणी छोड़ दो

    You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> आप ये HTML टैग और विशेषताएँ: <a href="" उपयोग title=""> <abbr title=""> <acronym कर सकते हैं <blockquote title=""> <b> cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>