lee-pai-long
1/20/2016 - 5:03 PM

get-stripped-ip_linux.md

[LINUX] get stripped IP

Get only private IP address from an interface

$ ip a | grep <interface> | grep inet | cut -f1 -d/ | awk '{print $2}'

or if your locale is set to english

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

replace addr by adr may work in other languages like french

Get only public IP address

$ wget -qO - checkip.dyndns.org | sed -e 's/[^0-9^.]//g'

You can also use ifconfig.co service

$ wget -qO - ifconfig.co