Skip to content

Instantly share code, notes, and snippets.

@RPDiep
Created February 11, 2014 12:46
Show Gist options
  • Save RPDiep/8934233 to your computer and use it in GitHub Desktop.
Save RPDiep/8934233 to your computer and use it in GitHub Desktop.
A simple script to show the ip addresses for a host
#!/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