Skip to content

Instantly share code, notes, and snippets.

@nhr
Created September 24, 2014 13:33
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 nhr/f86974c733cd5edeb8b2 to your computer and use it in GitHub Desktop.
Save nhr/f86974c733cd5edeb8b2 to your computer and use it in GitHub Desktop.
Bash helper functions for capturing eth0 IP addr and public IP addr
function get_eth0_ipaddr() {
eth0_ip=$(ip addr list eth0 | grep 'inet ' | tr -s ' ' | cut -d ' ' -f 3 | cut -d '/' -f 1)
echo "${eth0_ip}"
}
function get_public_ipaddr() {
public_ip=$(curl -s ipecho.net/plain)
echo "${public_ip}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment