Get IPs of your Network Interfaces plus your External Address
This goes into your bash config:
ip() {
  INTERFACE=`ifconfig -l`
  for IT in $INTERFACE
  do
    IP=`ifconfig "$IT" | grep 'inet ' | awk '{print $2}'`
    if [[ $IP ]]; then
      echo $IT $IP
    fi
  done
  echo "ext" `dig +short myip.opendns.com @resolver1.opendns.com`
}
Now you just type ip and get a list like this:
lo0 127.0.0.1
en0 192.168.0.31
en1 192.168.0.32
ext 17.35.192.29Written by Thorsten Basse
Related protips
1 Response
grep is not needed for this:
grep 'inet ' | awk '{print $2}'`
This can be done in awk
awk '/inet/ {print $2}'`
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
 #Shell 
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#