Last Updated: April 09, 2016
·
2.868K
· jjbohn

How to get your public IP address from the terminal

Came across this little command the other day. This does a simple GET request to http://ifconfig.me, which returns your IP address.

curl ifconfig.me

There are also a few other commands that can give you other information including your hostname, user agent, etc. You can get it return in json, xml or plain text. I encourage you to checkout http://ifconfig.me on the web to see them all.

There are a few services to retrieve your public facing IP address, but I think this one is the nicest/easiest to remember.

From: http://jjbohn.info/cheat-sheet/how-to-get-your-public-ip-address-from-the-terminal/

3 Responses
Add your response

This has already been shared, but it's good nonetheless. :)

https://coderwall.com/p/-t2lwa

over 1 year ago ·

icanhazip.com responds a lot faster here. Same script-friendly format. :)

over 1 year ago ·

I usually use curl ipecho.net/plain

Thanks for sharing anyway!

over 1 year ago ·