Skip to content

Instantly share code, notes, and snippets.

@jasenmichael
Created January 7, 2019 02:16
Show Gist options
  • Save jasenmichael/46db9ab56daaac16fe636364781b9886 to your computer and use it in GitHub Desktop.
Save jasenmichael/46db9ab56daaac16fe636364781b9886 to your computer and use it in GitHub Desktop.
get public ip from terminal/bash

get public ip from terminal/bash

using dig

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

using wget

wget http://ipecho.net/plain -O - -q ; echo

using curl

curl ipecho.net/plain; echo

curl icanhazip.com

curl ifconfig.me

in bash script

#!/bin/bash

PUBLIC_IP=`wget http://ipecho.net/plain -O - -q ; echo`
echo $PUBLIC_IP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment