How to get your IP from the command line

http://icanhazip.com/ will tell you your IP.

curl http://icanhazip.com/

I previously did this using whatsmyip.org, but it doesn’t work any more.

whatsmyip.org tells you your IP address clearly at the top of their web page. You can also use this tool from the command line by requesting http://automation.whatismyip.com/n09230945.asp. Here are a couple of examples using wget or curl:

wget -q -O - http://automation.whatismyip.com/n09230945.asp

curl http://automation.whatismyip.com/n09230945.asp ; echo

The curl example seems to add a newline at the end, while wget doesn’t.

References:

Last modified: 06/09/2014 Tags: ,

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top