Howto Check you external IP Address from the command line
Posted by admin on November 7th, 2007
Email This Post
If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!
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



December 8th, 2007 at 8:43 pm
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…
September 25th, 2008 at 5:01 pm
try
lynx -dump http://whatismyip.com | awk ‘/Your/{print $5}’
that seems to work on my system.
October 10th, 2008 at 6:05 pm
Try either of these in a script or terminal:
wget -qO - http://cfaj.freeshell.org/ipaddr.cgior
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?
November 25th, 2008 at 4:43 pm
voila mon commentaire