You are here

Usefull variables

Host IP address(es)

HOSTIP=$(ip addr | sed -e '/' -e 's/ *inet *\([^\/]*\).*/\1/;tx;d;:x')

This gets interface information using ip command, sed is used to remove everything except the inet4 ip address.

Internet IP address

As this involves screen scraping it's prone to failure if the remote site changes

MYGLOBALIP=$(curl 2>/dev/null |
    sed -n 's/.*>\([0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\).*/\1/p')