Bash get external IP!
Get external IP
## Below command outputs external ip
dig +short myip.opendns.com @resolver1.opendns.com
To add this to bash_profile for quick access
## To copy external ip to clipboard
alias getmyipc='dig +short myip.opendns.com @resolver1.opendns.com|pbcopy'
## Outputs external ip
alias getmyip='dig +short myip.opendns.com @resolver1.opendns.com'
After adding the above live to .bash_profile
. Try source ~/.bash_profile
.
Now you can try getmyip
for getting the ip in terminal. getmyipc
to copy external ip to clipboard.
Updated: 02/09/2013
## Outputs external IP
curl ifconfig.me
To add it to bash_profile for quick access
## To copy external ip to clipboard
alias getmyipc='curl ifconfig.me|pbcopy'
## Output external ip
alias getmyip='curl ifconfig.me'
Written by Samar Panda
Related protips
3 Responses

or even quicker:
curl ifconfig.me
over 1 year ago
·

Thanks @joshhunt. Will update my protip.
over 1 year ago
·

curl -N ifconfig.me
will not show output stream. more clear :)
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ip
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#