Last Updated: February 25, 2016
· iambaird

Getting Public IP from Shell

dig +short

or bind to an alias:

alias ip="dig +short"

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

4 Responses
Add your response

Nice! I use the following for my LAN IP:

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

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

over 1 year ago ·

I generally use this:


To add to the clipboard on OS X:

curl | pbcopy
over 1 year ago ·


over 1 year ago ·