Skip to content

Instantly share code, notes, and snippets.

@haukurk
Created October 3, 2018 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save haukurk/6cefc02f9751a13090c14987887294f3 to your computer and use it in GitHub Desktop.
Save haukurk/6cefc02f9751a13090c14987887294f3 to your computer and use it in GitHub Desktop.
cli myips
# return my IP addresses
function myip() {
ExtIP=`dig TXT +short o-o.myaddr.l.google.com @ns1.google.com`
echo $ExtIP | tr -d '"' | awk '{print "external : " $1}'
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