Skip to content

Instantly share code, notes, and snippets.

@evgv
Last active April 27, 2018 06:28
Show Gist options
  • Save evgv/a17ca812c43bf0ec72a1a26bd0d5c8f1 to your computer and use it in GitHub Desktop.
Save evgv/a17ca812c43bf0ec72a1a26bd0d5c8f1 to your computer and use it in GitHub Desktop.
Ubuntu. Get your IP address

Ubuntu get IP address

Some ways to get your ip address both local and public.

Local

    hostname -I    
    ip route get 8.8.8.8 | awk '{print $NF; exit}'     
    ifconfig | grep inet

Public

Curl

    curl ipinfo.io/ip
    curl icanhazip.com
    curl ipv4.icanhazip.com
    curl ipecho.net/plain ; echo
    curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
    curl http://checkip.amazonaws.com

Wget

      wget -qO- http://ipecho.net/plain ; echo
    wget -qO- icanhazip.com

Dig

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

Telnet

    telnet myip.gelma.net

Lynx

    lynx bot.whatismyipaddress.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment