carlessanagustin
7/5/2016 - 8:45 AM

SHELL: Get IP address from command line

SHELL: Get IP address from command line

Public

curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'

curl ipinfo.io/ip

from Ubuntu

ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/'

ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{print $1}'

ifconfig | grep -A 1 'eth0' | tail -1 | cut -d ':' -f 2 | cut -d ' ' -f 1

from Mac

ipconfig getifaddr en0