Ubuntu Geek

Ubuntu Linux Tips,Howtos&Tutorials|Feisty,Gutsy,Hardy,Intrepid

  • RSS Feed

    subscribe to the ubuntu Geek RSS feed


  • Sponsor

  • Categories

  • Meta

  • Sponsor

  • Archives

  • Support Ubuntugeek

    Amount $:
    Website(Optional):


  • Favourite Sites

Howto Check you external IP Address from the command line

Posted by admin on November 7th, 2007 Email This Post Email This Post

You know about the possibility to find out your IP Address by using visiting the site whatismyip.com .

For this, you need the packages wget, grep and sed so make sure you have them by checking for them in Synaptic or running the following in a terminal

sudo apt-get install wget grep sed

Then, as long as whatismyip.com prints out the IP-Address in the HTML page title, you can use this.

Create shell script

cd ~

mkdir bin

vi bin/whatismyip.sh

Insert the following lines into the file

#!/bin/bash

echo Your external IP Address is:
wget http://Www.whatismyip.com -O - -o /dev/null | grep '<TITLE>' | sed -r 's/<TITLE>WhatIsMyIP\.com \- //g' | sed -r 's/<\/TITLE>//g'

exit 0

Save and exit the file

Now you need to change the permissions using the following command

chmod u+x bin/whatismyip.sh

Now you can check your external IP Address by running

~/bin/whatismyip.sh

Share/Save/Bookmark

If you want to be notified the next time we write something please subscribe to our RSS feed.Thanks for Visiting!

Related Articles

3 Responses to “Howto Check you external IP Address from the command line”

  1. blog.sudosu.net Says:

    Correction to Ubuntu Geek’s “How To Check Your External IP Address From The Command Line”…

    I follow the Ubuntu Geek blog, and have found some very useful tips there. However, there’s a problem with their latest tip, “Howto Check you (sic) external IP Address from the command line.”
    Some background: There’s a very usef…

  2. moonsoup Says:

    try

    lynx -dump http://whatismyip.com | awk ‘/Your/{print $5}’

    that seems to work on my system.

  3. daaawg Says:

    Try either of these in a script or terminal:

    wget -qO - http://cfaj.freeshell.org/ipaddr.cgi
    or
    lynx -dump http://whatismyip.org/

    Of course these will only work if you have wget or lynx installed on your system. Be aware that as written, the wget command returns a string without a newline character, so deal with that quirk accordingly. Can anybody correct that to return a newline?

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>