How to find your public IP address with the Linux command line कैसे Linux कमांड लाइन के साथ अपने सार्वजनिक आईपी पता लगाने के लिए

by Sukrit Dhandhania on April 7, 2009 Sukrit Dhandhania द्वारा 7 अप्रैल 2009 पर

लिनक्स

Sometimes I need to find out what the public IP address of a particular machine is. कभी कभी मुझे पता लगाना क्या एक विशेष मशीन के सार्वजनिक आईपी पता है की जरूरत है. If I have access to a web browser on that machine I just hope over to a service such as अगर मैं उस मशीन मैं बस एक सेवा के लिए अधिक उम्मीद है कि इस तरह के रूप में एक वेब ब्राउज़र का उपयोग किया है http://www.whatismyip.com http://www.whatismyip.com or या myip.dk myip.dk to find this information. यह जानकारी प्राप्त करें. However, on a remote Linux server it is not practical to use the web browser method. हालांकि, एक रिमोट लिनक्स सर्वर पर यह व्यावहारिक के लिए वेब ब्राउज़र की विधि का उपयोग नहीं है. So, instead, I use the following hack. तो, के बजाय, मैं निम्नलिखित हैक का उपयोग करें.

I enter the following line into a Linux command line: मैं एक Linux कमांड लाइन में निम्नलिखित पंक्ति दर्ज करें:

# curl -s myip.dk | grep '"Box"' | egrep -o '[0-9.]+' # कर्ल-myip.dk S | 'grep "बॉक्स"' | egrep-o '[0-9.] +'
122.172.9.222 122.172.9.222

Pretty useful stuff this. काफ़ी उपयोगी सामग्री यह. If you need to use this command often it might be a good idea to create a script with the command so that you need not have to remember it. यदि आप इस कमांड का प्रयोग अक्सर यह एक अच्छा विचार करने के आदेश के साथ एक स्क्रिप्ट बनाने की जरूरत है ताकि आप इसे याद नहीं हो सकता है की जरूरत है. Create a new file using your favorite text editor. एक नया अपने पसंदीदा पाठ संपादक का उपयोग कर फ़ाइल बनाएँ. Enter the following lines: निम्नलिखित लाइनों दर्ज करें:

#!/bin/bash ! # / bin / मार
curl -s myip.dk | grep '"Box"' | egrep -o '[0-9.]+' कर्ल-myip.dk S | 'grep "बॉक्स"' | egrep-o '[0-9.] +'

Now save the file as something like /usr/bin/myipaddress . अब ऐसा कुछ के रूप में फ़ाइल सहेजें / usr / bin / myipaddress. Grant it executable privileges like this: यह अनुदान इस तरह निष्पादन योग्य विशेषाधिकार:

# chmod +x /usr/bin/myipaddress # + Chmod x / usr / bin / myipaddress

Now you have a script that you can access from anywhere on your computer by running myipaddress in the command line. अब तुम एक स्क्रिप्ट है कि आप अपने कंप्यूटर पर कहीं से भी कमांड लाइन में myipaddress चलाकर का उपयोग कर सकते हैं. It will output your current public IP address. यह आपके मौजूदा सार्वजनिक आईपी पता उत्पादन होगा. This can be quite useful if you use things like IP-based authentication, or if you use a dynamic DNS service. यह बहुत उपयोगी है अगर आप की तरह बातें आईपी-प्रमाणीकरण आधारित है, या यदि आप एक गतिशील DNS सेवा का उपयोग का प्रयोग हो सकता है.

Although the above example should work most of the time, there might be times when the service that gives you your public IP address is down or has changed the format with which they display the data, thus breaking the script. हालांकि इसके बाद के संस्करण उदाहरण के समय का सबसे अधिक काम करना चाहिए, कई बार ऐसा हो सकता है जब सेवा देता है कि आप अपने सार्वजनिक आईपी पता नीचे है या प्रारूप जिसके साथ वे डेटा का प्रदर्शन बदल गया है, इस प्रकार स्क्रिप्ट को तोड़ने. Here's a backup method in case the command shown earlier does not work for you. यहाँ एक बैकअप विधि है मामले में पहले आप के लिए काम नहीं करता है दिखाया कमान. It used the service यह सेवा का उपयोग किया http://www.formyip.com/ http://www.formyip.com/ . .

# links -dump http://www.formyip.com/ | awk "/IP is/{print $NF}" लिंक #-http://www.formyip.com/ | awk "/ आईपी है / प्रिंट ($ NF) डंप"

You could also use this with lynx : तुम भी लिंक्स के साथ इस इस्तेमाल कर सकते हैं:

# lynx -dump http://www.formyip.com/ | awk "/IP is/{print $NF}" # लिंक्स-http://www.formyip.com/ डंप | / awk "आईपी है / प्रिंट ($ NF)"

Again, feel free to enter this command into a script like I showed you earlier. फिर से, के लिए एक पटकथा में इस कमान में प्रवेश नि: शुल्क लगता है कि मैं तुम्हें पहले से पता चला. It will make using the command a breeze. यह आदेश एक हवा का उपयोग करेंगे.

Related Posts: संबंधित पोस्ट:
  • Linux command line magic – find and replace Linux कमांड लाइन जादू - खोजें और जगह
  • How to post to Twitter from the Linux command line कैसे Linux कमांड लाइन से चहचहाना पोस्ट करने के लिए
  • How to SSH to your remote server without entering a password every time कैसे एक कूटशब्द हर बार प्रवेश करने के बिना अपने दूरस्थ सर्वर से ssh को
  • How to send email from the Linux command line कैसे Linux कमांड लाइन से ईमेल भेजने के लिए
  • How to determine your IP or MAC address in Windows कैसे आपके अपने आईपी या Windows में मैक पते का निर्धारण करने के
  • 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. तुम हमेशा इस ईमेल सदस्यता से बाहर किसी भी समय विकल्प चुन सकते हैं.

    { 1 trackback } (1) Trackback

    Find your external IP from the CLI « Linux & Stuff CLI «लिनक्स और सामग्री से अपने बाहरी आईपी खोजें
    05.10.09 at 4:00 am 4:00 पर 05.10.09 हूँ

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

    1 1 Mike माइक 05.31.09 at 8:09 pm 8:09 पर 05.31.09

    When I copy-pasted the script into my own file, I saw that your quote marks don't match up. जब मैं कॉपी-मेरी अपनी फ़ाइल में स्क्रिप्ट चिपकाया, मैंने देखा है कि आपके उद्धरण चिह्न अप मैच नहीं है.

    … '[0-9.]+' ... '0-9 [.] +'

    I changed the first quote before the [ character to ', making the final product read: मैं पहले पहली बोली बदल [चरित्र, जिससे अंतिम उत्पाद पढ़ने 'के लिए:

    #!/bin/bash ! # / bin / मार
    curl -s myip.dk | grep '"Box"' | egrep -o '[0-9.]+' कर्ल-myip.dk S | 'grep "बॉक्स"' | egrep-o '[0-9.] +'

    By the way, I apologize for the slight messiness of this, but it's very difficult to quote a quote mark. वैसे, मैं इस के सा messiness के लिए क्षमा चाहते हैं, लेकिन यह बहुत से एक उद्धरण चिह्न बोली मुश्किल है. ;)

    2 2 spuffler 06.03.09 at 9:36 pm 9:36 पर 06.03.09 spuffler

    … evidently, the author doesn't read our replies, otherwise, I'd have had a successful execution of the script file, because I would have copied corrected text. ... जाहिर है, लेखक हमारे जवाब पढ़ नहीं है, अन्यथा, मैं स्क्रिप्ट फ़ाइल के सफल निष्पादन किया होगा, क्योंकि मैं पाठ सही होता है नकल की. ...

    3 3 Tom 06.03.09 at 9:56 pm 9:56 पर टॉम 06.03.09

    Using ifconfig works just as well, you'll still need to grep for the proper lines, and then possibly use sed to extract the actual IP address as this script does, and it doesn't rely on a specific site actually being up… Ifconfig का उपयोग कर बस के रूप में अच्छी तरह से काम करता है, तब भी आप उचित लाइनों के लिए grep की जरूरत है, और तो संभवतः इस कहानी है, और यह एक विशिष्ट साइट पर भरोसा नहीं है के रूप में वास्तविक IP पता निकालने sed उपयोग वास्तव में ऊपर जा रहा है ...

    4 4 Sukrit D Sukrit डी 06.03.09 at 10:22 pm 10:22 पर 06.03.09

    Sorry for the delayed reply. देर से उत्तर के लिए क्षमा करें. You can also use the following command to get your public IP: तुम भी निम्न कमांड का प्रयोग कर अपने सार्वजनिक आईपी प्राप्त कर सकते हैं:

    wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'

    5 5 Sionide21 06.16.09 at 4:23 pm 4:23 पर Sionide21 06.16.09

    You can use आप उपयोग कर सकते हैं
    http://www.whatismyip.org/ http://www.whatismyip.org/
    To get just the ip in plaintext form. Plaintext के रूप में ही आई पी जाओ.

    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>