Page 4 of 5 FirstFirst ... 2345 LastLast
Results 31 to 40 of 47

Thread: HOWTO: Check you external IP Address from the command line

  1. #31
    Join Date
    May 2006
    Location
    Switzerland
    Beans
    2,541
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: HOWTO: Check you external IP Address from the command line

    Quote Originally Posted by Cheesehead View Post
    All the cron-based approaches are a bit troubling - it can be rude to add unecessary load to somebody else's server.
    Not if you do it right. And web sites such as whatismyip.com explictly don't mind if you query their site. They even give instructions on how to do it via scripting:

    http://forum.whatismyip.com/f14/our-...on-rules-t241/

    And I bet they have firewalls and what not in place to prevent anyone from overdoing it.

    So if you follow their instructions and let your automated script hit this URL: http://www.whatismyip.com/automation/n09230945.asp

    ... then nothing bad should happen. That URL will only spit out your IP address and nothing more, so the traffic that a script would be causing is very very small.

  2. #32
    Join Date
    Jan 2009
    Location
    Buenos Aires, Argentina
    Beans
    669

    Re: HOWTO: Check you external IP Address from the command line

    Also,

    wget -qO - icanhazip.com
    or

    curl icanhazip.com
    I didn't find info on how often it can be used, but here it reads: "visitors can use the response in scripts or other applications very easily".

    Supports IPv6 too.

  3. #33
    Join Date
    Mar 2007
    Location
    Scotland
    Beans
    1,111
    Distro
    Ubuntu Development Release

    Re: HOWTO: Check you external IP Address from the command line

    automation url is now:-

    http://automation.whatismyip.com/n09230945.asp

    They request 300 seconds/5 minutes between automated enquiries.
    Itch: Think Hula hoop, positive on top, negative on bottom, roll it. Is it a wave or a particle? Is it a photon? Is a photon a dipole? Are we all made of light!

  4. #34
    Join Date
    Jan 2010
    Location
    No longer SoFl
    Beans
    Hidden!
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: HOWTO: Check you external IP Address from the command line

    Finding old threads I see! Changes to the original code:

    Code:
    #!/bin/bash
    #
    #  From: http://ubuntuforums.org/showthread.php?t=526176
    #
    echo Your external IP Address is:
    wget http://automation.whatismyip.com/n09230945.asp -O - -o /dev/null
    echo 
    exit 0
    Posting that change is useful because my conky script no longer worked with whatsmyip. This should fix it.



  5. #35
    Join Date
    May 2009
    Location
    Bulgaria
    Beans
    3
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: HOWTO: Check you external IP Address from the command line

    Work for me too ty all

  6. #36
    Join Date
    Dec 2005
    Beans
    38
    Distro
    Kubuntu 10.04 Lucid Lynx

    Re: HOWTO: Check you external IP Address from the command line

    I added this to my crontab at a headless, remote server, so that I get confirmation once every morning that it's up and online, and how to reach it:

    Code:
    echo Internal `ifconfig eth0 |grep "inet addr" |awk '{print $2}'`, external addr:`wget http://automation.whatismyip.com/n09230945.asp -O - -o /dev/null` | mail myemail@example.com -s IP addresses

  7. #37
    Join Date
    Jan 2012
    Beans
    342

    Re: HOWTO: Check you external IP Address from the command line

    necromancy .. mia culpa!

    I see alot of 'grep | cut | awk' etc .. all of this can by achieved with one command:

    Code:
    awk '/inet addr:/{print (substr($2,6,15))}' <(ifconfig eth0)
    or similarly to preface it with 'eth0 IP:'

    Code:
    awk '/inet addr:/ {print "eth0 IP: "(substr($2,6,15))}' <(ifconfig eth0)
    HTH ... khay

  8. #38
    Join Date
    Nov 2006
    Beans
    11

    Thumbs up Re: HOWTO: Check you external IP Address from the command line

    I have made a WAN IP Logger years ago for windows and for Linux (gtk2 is needed).
    I know that it is not command line but you might fit at your needs.



    The main page is here :
    http://www.trustfm.net/GeneralTools/...ANIPLogger.php
    And the download page is here :
    http://www.trustfm.net/GeneralTools/...?page=Download

    It is completely free for personal and commercial use.

    Let me know if you have problems.
    Last edited by kitsaros; February 23rd, 2012 at 07:00 PM.

  9. #39
    Join Date
    Apr 2012
    Beans
    2

    Re: HOWTO: Check you external IP Address from the command line

    I see that this post has been answered in various replies, but I thought it wouldn't hurt to add another option.

    You can also use wget with ipogre.com.
    Code:
    wget -q -O - ipogre.com/linux.php|sed -e 's/.*IP Address: //' -e 's/<.*$//'
    Last edited by jacobt777; May 2nd, 2012 at 01:49 PM.

  10. #40
    Join Date
    Oct 2008
    Beans
    3,509

    Re: HOWTO: Check you external IP Address from the command line

    Code:
    curl ifconfig.me

Page 4 of 5 FirstFirst ... 2345 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •