Skip to content

Instantly share code, notes, and snippets.

@steve-taylor
Created February 27, 2013 14:58
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 steve-taylor/5048501 to your computer and use it in GitHub Desktop.
Save steve-taylor/5048501 to your computer and use it in GitHub Desktop.
Assign the name of the Internet facing network interface to a variable in a shell script. Requires Internet access.
#!/bin/sh
IPADDR=`wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'`
NIC=`ip addr show | grep $IPADDR | awk '{ print $(NF) }'`
# Rest of your script here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment