Skip to content

Instantly share code, notes, and snippets.

@mohclips
Created March 22, 2022 10:50
Show Gist options
  • Save mohclips/285afa4839254af73aebda6a0ab37568 to your computer and use it in GitHub Desktop.
Save mohclips/285afa4839254af73aebda6a0ab37568 to your computer and use it in GitHub Desktop.
default route in bash
# try to use the least complex commands available in bash to get the default route
# used when ip r, ifconfig are not available
# like when in a compromised container :)
printf '%d.%d.%d.%d\n' $(echo $(cat /proc/net/route | grep "00000000.*00000000" | cut -b15-22 | grep -o .. | tac | paste -sd '' -) | sed 's/../0x& /g')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment