network

Need to know your public IP?

Some times you may need to know your public IP address. With this simple command you can find it out:

$ curl -s http://checkip.dyndns.org/ | egrep -o "[0-9.]+"

There are some other sites where we can discover it like whatismyip or whatismyipaddress, but the user-agent needs to be spoofed beacuse they ban curl, so the solution is using the -A option:

$ curl -A "Mozilla/4.0" -s http://whatismyip.com

With the above command you will get the entire page bypassing the ban. But as the HTML of this pages is more complex and we do not want to fool them spoofing the user agent, we prefer the first command :-)

speak up

Add your comment below, or trackback from your own site.

Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

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

*Required Fields