2009-08-20 12:21

To know the IP address you use to go out on the Internet, you can use a site like http://www.whatismyip.com

In text mode with no Web browser, it’s a bit more complicated. You can use the following command:

wget --user-agent="Mozilla/5.0" -O - http://www.whatismyip.com 2>/dev/null | grep -o "Your IP Address Is: [0-9.]*"

We have to simulate a real browser, or the site refuses us.

UPDATE 14/01/2010

To find your external IP address, an even more elegant way:

dig +short myip.opendns.com @resolver1.opendns.com

UPDATE 06/05/2010

The best way:

curl icanhazip.com

http://www.commandlinefu.com/commands/view/2966/return-external-ip

2009-08-20 12:21 · Tags: ,

Leave a Reply

Your email address will not be published. Required fields are marked *

You may 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>