Windows Routing

From DN Wiki
Jump to navigation Jump to search

Summary

It's often useful to use a wired laptop to test wifi somewhere else. I'll RDP to it and then join wifi to make sure it's working correctly or to see first-hand whatever symptoms are showing up. The issue with this is that Windows will prefer the wired connection so I can't use the laptop's wifi to get to the internet or other resources, but I need the wired connection to access the laptop so I can't disconnect it. Routing to the rescue! I can add a route to the laptop so that it uses wired to reach my IP but uses wifi for everything else.

You can view the routing table but you need an admin CLI to make changes.

Warning: The following commands use example IPs. If you don't know what the real IPs should be you shouldn't be doing this.

Commands

 route print -4

Will show you the current IPv4 routing table.

 route add 203.0.113.67 mask 255.255.255.255 192.0.2.1

Will add a route to my IP address via the wired default gateway. Add -p after "add" to make it persistent, meaning it survive a reboot.

 route delete 0.0.0.0

Will remove ALL the default routes, both the wired and the wifi.

 route add 0.0.0.0 mask 0.0.0.0 198.51.100.1

Will add the wifi default route back to the routing table.

Timed Shutdown

Also useful is put in a timed reload so that if you hose the routing table the laptop reboots and you can get in without sending someone to reboot for you.

 shutdown /r /t 300

Will reboot in 300 seconds (5 minutes). Feel free to use 600 to give yourself a little more time. Surprisingly, this does not need an admin window.

 shutdown /a

Will abort the shutdown if you made the change everything is still working.