The following function is used to determine a few basics about the network of the user, such as, external and internal IP addresses, subnet, the default gateway, and who's logged in. Note that the 3-liner, ext_ip_info.py
is also attached to this gist.
function host_information(){
export GATEWAY=$(netstat -nr | perl -lne 'print $1 if m/default\s+(.+?)\s+?.+?en0/g')
export MY_EXT_IP=$(curl -s https://icanhazip.com)
export EXT_IP_OWNER=$(python3 bin/ext_ip_info.py $MY_EXT_IP)
export MY_INT_IP=$(nmap --iflist |perl -lne 'print "$1" if m/en0\s+\S+\s+(\S+)\/(\S+)\s+ethernet/g'|head -n1)