Skip to content

Instantly share code, notes, and snippets.

@ludo237
Created June 4, 2015 07:37
Show Gist options
  • Save ludo237/1a24269ce11a912f5e23 to your computer and use it in GitHub Desktop.
Save ludo237/1a24269ce11a912f5e23 to your computer and use it in GitHub Desktop.
Grab all networks and show the associated IP
# -------------------------------------------------------------------
# myIP address
# -------------------------------------------------------------------
function myip() {
ifconfig lo0 | grep 'inet ' | sed -e 's/:/ /' | awk '{print "lo0 : " $2}'
ifconfig en0 | grep 'inet ' | sed -e 's/:/ /' | awk '{print "en0 (IPv4): " $2 " " $3 " " $4 " " $5 " " $6}'
ifconfig en0 | grep 'inet6 ' | sed -e 's/ / /' | awk '{print "en0 (IPv6): " $2 " " $3 " " $4 " " $5 " " $6}'
ifconfig en1 | grep 'inet ' | sed -e 's/:/ /' | awk '{print "en1 (IPv4): " $2 " " $3 " " $4 " " $5 " " $6}'
ifconfig en1 | grep 'inet6 ' | sed -e 's/ / /' | awk '{print "en1 (IPv6): " $2 " " $3 " " $4 " " $5 " " $6}'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment