Last active
September 12, 2017 02:41
-
-
Save yujunz/4684c4157adc661ab668a7cb325feac0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
HOST_IFACE=$(ip route | grep "^default" | head -1 | awk '{ print $5 }') | |
LOCAL_IP=$(ip addr | awk "/inet/ && /${HOST_IFACE}/{sub(/\/.*$/,\"\",\$2); print \$2}") | |
cat << EOF | sudo tee -a /etc/hosts | |
${LOCAL_IP} $(hostname) | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment