Created
June 6, 2018 04:23
-
-
Save belsander/c7729f760a6a088d7dfc22930251dd6a to your computer and use it in GitHub Desktop.
In case you want to have your default gateway on a higher metric interface (so slower) and only use the lower metric interface for specific routes
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
REM If you want to set metrics on interfaces go to the confguration of the network interface: | |
REM (THIS IS NOT POSSIBLE WITH THE route COMMAND !!) | |
REM Goto: 'Internet Protocol Version 4 (TCP/IPv4)' -> Properties | |
REM Goto: 'General' -> Advanced | |
REM Goto: 'IP Settings' | |
REM Uncheck 'Automatic metric' | |
REM Type in the metric you want for that interface in 'Interface metric' | |
REM Find out what the interface number is | |
route print | |
REM The actual script (copy paste this into a .bat which you run with Administrator privileges) | |
REM It keeps correcting the routes, since Windows constantly updates the routes again to its defaults | |
:loop | |
REM Delete default gateway route on lower metric interface | |
route DELETE 0.0.0.0 IF <INTERFACE NUMBER> | |
REM Add static route on lower metric interface | |
route ADD <NETWORK ADDRESS> MASK <MASK ADDRESS> <INTERFACE GATEWAY ADDRESS> IF <INTERFACE NUMBER> | |
timeout /t 20 | |
goto loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment