z47tvw
Last Updated: February 25, 2016
·
1.896K
· iambaird
Profile3

Getting Public IP from Shell

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

or bind to an alias:

alias ip="dig +short myip.opendns.com @resolver1.opendns.com"

In my experience I've found this to be considerably faster than many of the cURL / ifconfig.me solutions.

Say Thanks
Respond

4 Responses
Add your response

4002
12003957 10206752435102297 2524621803006121539 n

Nice! I use the following for my LAN IP:

alias myip="ifconfig | grep 'inet ' | grep -v 127.0.0.1 | cut -d\   -f2"
over 1 year ago ·
4009
Profile3

@mdeiters Great! Thanks for that, will add to my growing alias file.

over 1 year ago ·
4040
B61ce134adf2d6eb1d1f1d11122d6142

I generally use this:

curl http://remoteip.me

To add to the clipboard on OS X:

curl http://remoteip.me | pbcopy
over 1 year ago ·
4151
D701f7f21f653de92e5a57cd2e2a0e79

curl ifconfig.me

over 1 year ago ·