Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


share|improve this question
up vote 1 down vote accepted

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

route add mask

share|improve this answer
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 Jul 7 '13 at 14:37
netsh interface ipv4 set route "Local Area Connection" 

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

share|improve this answer
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 Jul 22 '11 at 13:53
run netsh interface show interface to list the available interfaces. you can pick the right one from the list – Michael Lowman Jul 22 '11 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 Jul 22 '11 at 14:01
you need to use ipv4 too. See update in my answer. – HostBits Jul 22 '11 at 14:34
+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 Jul 22 '11 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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.