Skip to content

Output of Private IP Address

Nice trick to show private address of linux machine | Isolated.

Bash
ip route get 8.8.8.8 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}'

Output Public IP address

Bash
ip route get 1 | sed -n 's/^.*src \([0-9.]*\) .*$/\1/p'

or even better

Bash
curl ifconfig.io
Back to top