How to permanently change the default gateway on Windows

9,584

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.

Share:
9,584

Related videos on Youtube

user471219
Author by

user471219

Updated on September 18, 2022

Comments

  • user471219
    user471219 over 1 year

    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?

  • user471219
    user471219 over 8 years
    Can you please explain : 1. The difference between the last two netsh commands? 2. Its seems that the third isn't equivalent to the first, can you explain why?
  • Narzan Q.
    Narzan Q. over 8 years
    Here you go, your full guide to netsh commands from Microsoft :) [link]technet.microsoft.com/en-us/library/bb490943.aspx [/link]
  • eri
    eri over 5 years
    0.0.0.0/32??? Shure?