Skip to content

Instantly share code, notes, and snippets.

@jstangroome
Created June 5, 2025 03:42
Show Gist options
  • Save jstangroome/3c7c427c12e8bbaf3e6b1ad71340d438 to your computer and use it in GitHub Desktop.
Save jstangroome/3c7c427c12e8bbaf3e6b1ad71340d438 to your computer and use it in GitHub Desktop.
Determine the default route gateway IPv4 address without `ip` installed.
#!/bin/sh
awk '$2 == "00000000" {
gw = $3;
for (i=4; i>0; i--) {
printf "%d", "0x" substr(gw, 2*i-1, 2);
if (i>1) printf ".";
}
print ""
}' /proc/net/route
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment