Last Updated: February 25, 2016
·
1.97K
· samarpanda

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'

3 Responses
Add your response

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 ·