Skip to content

Instantly share code, notes, and snippets.

@kogakure
Forked from warthurton/myip
Created June 3, 2013 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kogakure/5697361 to your computer and use it in GitHub Desktop.
Save kogakure/5697361 to your computer and use it in GitHub Desktop.
#!/bin/bash
active_interface=`netstat -rn | grep 'default' | awk '{print $6}'`
ifconfig | grep -A 1 $active_interface | grep 'inet ' | awk '{printf $2}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment