How to permanently change the default gateway on Windows
I'm trying to change default gateway in both Windows 7 and Windows XP by deleting previous gateway and assigning a new one.
After reboot the changes are reverted and I get the deleted gateway assigned.
My commands in cmd were:
route.exe delete 0.0.0.0 mask 0.0.0.0 [old_ip_gatway]
route.exe add 0.0.0.0 mask 0.0.0.0 [new_ip-gateway]
I've tried also the same command but with -p
before delete
or add
, without success.
Any ideas why is this happening and how to fix it?
Not sure if things have changed with Windows 7 but on XP you could just do something like this.
route add 0.0.0.0 mask 0.0.0.0 192.168.1.1
or
netsh interface ipv4 set route 0.0.0.0/0 "Local Area Connection" 192.168.1.1
netsh is the right way - doing it with a route add will require you to re-add the route each time you reboot the OS or this
netsh int ip set address "Local Area Connection" address=192.168.1.64 mask=255.255.255.0 gateway=192.168.1.1
You have to specify every field (address, mask and gateway). Otherwise they will be reset.