Skip to content

Instantly share code, notes, and snippets.

@menixator
Created June 29, 2017 04:56
Show Gist options
  • Save menixator/24dc207bd2d2fdd8c9235f0a2298dbb2 to your computer and use it in GitHub Desktop.
Save menixator/24dc207bd2d2fdd8c9235f0a2298dbb2 to your computer and use it in GitHub Desktop.
alias wanip='dig +short myip.opendns.com @resolver1.opendns.com'
alias lanip='_lanip | column -t'
function _lanip(){
for dev in $(ls /sys/class/net); do
echo -n $dev " "
net=$(ip -f inet addr show $dev | grep --color=never -Po 'inet \K[\d.]+?\/\d+')
if [[ -n $net ]]; then
echo -n $net
else
echo -n 'nil'
fi
echo -n "\t"
mac=$(ip -f link addr show $dev | grep --color=never -Po 'link/[\w\d]+\s*\K[\da-f]{2}(:[\da-f]{2}){5}');
if [[ -n $mac ]] && [ "$mac" != "00:00:00:00:00:00" ]; then
echo -n $mac
else
echo -n 'nil'
fi
echo
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment