or61ta
Last Updated: February 25, 2016
·
892
· samarpanda
71567ac844954fdcf48dac4efaca8a3d

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

9045
C8ca32e8bda3076abe185e4718836336

or even quicker:

curl ifconfig.me
over 1 year ago ·
9046
71567ac844954fdcf48dac4efaca8a3d

Thanks @joshhunt. Will update my protip.

over 1 year ago ·
9048
8a9a42904c08eae1adcad32de8ae9dd6

curl -N ifconfig.me

will not show output stream. more clear :)

over 1 year ago ·