Change Gateway from registry

tistou77

Moderator
Staff member
Messages
1,226
Reaction score
243
Hello

Is it possible to change/modify the "DefaultGateway" from the registry (not with a command prompt) ?
It's ok for IP, DNS, Mask, but "Gateway" is not applied

Thanks
 
Each network interface, whether physical or virtual, can have its own default gateway. The real problem is Windows dynamically creates a random GUID for each interface. So you can't find the unique GUID until after Windows finishes setting up the interface.

Searching the reg tree for the interface is possible, but you have to check the interface details to know it's the right GUID. Normally it's easier to list interfaces using netsh or PowerShell commands (recommended), and use them to configure your network settings.

If you have IPv6 enabled, then every interface will have both a IPv4 and IPv6 instance and have separate gateways.

Adding the default gateway in the registry will only take effect on the next reboot. A reg change by itself doesn't force any changes to the current routing tables in memory.
 
Ah ok, maybe that's why by applying the registry keys, the gateway is not applied in the network settings, I would look with a reboot
Thanks

PS : No need to reboot for IP, DNS and Mask
 
When you use the network settings to add the gateway, it's applying routing changes for you. You could do a "route add" at the same time of the reg change. For most people, it's easier to tell them to reboot if they're not network experts.
 
Indeed, after a reboot, the gateway is displayed in the setting
Otherwise, by applying the registry keys, even if the gateway isn't "visible" in the settings (before the reboot), it still works.

But yes, since the GUID changes with each installation, registry keys are not the best choice.
 
Back
Top