Skip to content

Instantly share code, notes, and snippets.

@zmarffy
Last active May 23, 2020 18:00
Show Gist options
  • Save zmarffy/c60a1c630e99d858840d9b32ae4075ab to your computer and use it in GitHub Desktop.
Save zmarffy/c60a1c630e99d858840d9b32ae4075ab to your computer and use it in GitHub Desktop.
Display public and private IPs of your machine
echo "Hostname is: $(hostname)"
echo "Public IP address is: $(dig +short myip.opendns.com @resolver1.opendns.com)"
echo "Private IP addresses are: $(hostname -I | sed 's/ /, /g' | sed 's/.\{2\}$//')"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment