Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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
echo "${public_ip}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.