Created
September 24, 2014 13:33
-
-
Save nhr/f86974c733cd5edeb8b2 to your computer and use it in GitHub Desktop.
Bash helper functions for capturing eth0 IP addr and public IP addr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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