I have a number of (windows 7) laptops that normally connect via wireless. We also have a wired network for special purposes. When one of these laptops plugs in to the wired network, at the moment, it makes the wired network the default route. Instead, I would like it to keep the wireless network the default, and route only 10...* through the wired. I can achieve this with: route delete 0.0.0.0 IF 22 route add 10.0.0.0 ... IF 22 (where IF 22 is the wired network interface).
But how can I get this to stick? Currently, if the wired network is unplugged then re-plugged, it grabs the default route again. So I want a way of making the wireless network not get the default route, and to make the 10...* network persistent.
Is there a hook to run commands after a network connection is established in windows? In linux I would use post-up hooks.
This probably belongs on Superuser, but I think you just want to add a -p to your ROUTE ADD command to make it persistent.
Perhaps try changing the binding order so that wireless is higher in the list than wired.
http://windows7news.com/forum/general-windows-7-help/how-do-i-change-the-network-binding-order-in-windows-7/msg5234/?PHPSESSID=20008fc86dff21b3f724c3038ee9ce26#msg5234
You can try to change the wireless connexion metric, to an higher metric than your wired connection. This way, your wireless connection default route will always be used if you're connected to the wireless network.
routing metrics can be changed via Network Sharing centre -> Adapter settings -> (choose connection) -> properties -> TCP/IP v4 -> properties -> advanced -> Automatic Metric