Created
June 5, 2025 03:42
-
-
Save jstangroome/3c7c427c12e8bbaf3e6b1ad71340d438 to your computer and use it in GitHub Desktop.
Determine the default route gateway IPv4 address without `ip` installed.
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/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