I am trying to find how to change the default gateway on a Windows 7 machine from the DOS prompt.


4 Answers 4


Not sure if things have changed with Windows 7 but on XP you could just do something like this.

route add mask

  • 5
    You can replace "add" with "change": route change mask That is only active until the next DHCP lease renewal or reboot. For a permanent change you need netsh with the correct interface name.
    – mivk
    Commented Jul 7, 2013 at 14:37
  • this will NOT SET gateway, this will ADD a gateway, therefore if a gateway is already set, windows will have now two gateways, and produce confusion in a OS that is already screwd up ... GOOD (right now, and ALWAYS, nasty problems in network configuration, for example I set up gw in graphical system, then see it in details, but if I reedit settings, gateway is not set), real answer is the above comment with route change Commented Apr 16, 2020 at 5:40
netsh interface ipv4 set route "Local Area Connection" 

The name of the network adapter is likely "Local Area Connection".

  • 1
    When I run this command with "Local Area Connection" used for the name, I get the error: "Element not found". Do I need to use a different name?
    – laconicdev
    Commented Jul 22, 2011 at 13:53
  • run netsh interface show interface to list the available interfaces. you can pick the right one from the list Commented Jul 22, 2011 at 13:58
  • the show interface returns the following interface names: Local Area Connection and VirtualBox Host-Only Network. If I try to use Local Area Connection instead of ipv4 I get the following error: "The following command was not found: interface "Local Area Connection" set route "Local Area Connection"
    – laconicdev
    Commented Jul 22, 2011 at 14:01
  • you need to use ipv4 too. See update in my answer.
    – HostBits
    Commented Jul 22, 2011 at 14:34
  • 5
    +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.
    – Lewis
    Commented Jul 22, 2011 at 14:37

The command line given by Cheekaleak does not work for me, this one does:

netsh int ip set address "Local Area Connection" address= mask= gateway=

You have to specify every field (address, mask and gateway). Otherwise they will be reset.


A persistent way to change the configuration:

route -p add mask     
route -p change mask
  • this is much better than netsh, thank you ! Commented Apr 16, 2020 at 5:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .