Created
February 11, 2014 12:46
-
-
Save RPDiep/8934233 to your computer and use it in GitHub Desktop.
A simple script to show the ip addresses for a host
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
#!/bin/bash | |
# Find the device with the default route | |
default_eth=$(ip r | awk '/default via/ {print $5}') | |
# Show the IP addresses for this device | |
ip a s ${default_eth} | awk '/global/ {print $2}' | cut -d'/' -f1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment