Created
August 29, 2021 07:36
-
-
Save Spotlightsrule/34f3df10b2d56b193858fc223ae6f816 to your computer and use it in GitHub Desktop.
This file contains 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
Default Gateway | |
Linux/Unix (for gateway): Determine which to use via "type netstat", skipping to the second if this check fails (contains the word "not found") | |
netstat -nr -f inet | grep "UG" | tail -1 | awk "{print $2}" | |
ip route | grep "^default" | head -1 | awk "{print $3}" | |
Linux/Unix (for base addr): Determine which to use via "type netstat", skipping to the second if this check fails (contains the word "not found") | |
netstat -nr -f inet | grep "U " | tail -1 | awk "{print $1}" | |
ip route | tail -1 | awk "{print $1}" | |
MacOS (for gateway): | |
netstat -nr -f inet | grep "^default" | head -1 | awk "{print $2}" | |
Windows (for cmd/W7 and up): | |
netstat -nr -p icmp | for /f "tokens=3" %a in ('findstr -R "0\.0\.0\.0.*0\.0\.0\.0"') do @echo %a | |
Windows (for powershell/W7 and up): | |
(Get-wmiObject Win32_networkAdapterConfiguration | ?{$_.IPEnabled}).DefaultIPGateway | select -first 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment