Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

Thanks!

share|improve this question
add comment

3 Answers

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 0.0.0.0 mask 0.0.0.0 192.168.0.1

share|improve this answer
    
You can replace "add" with "change": route change 0.0.0.0 mask 0.0.0.0 192.168.0.1. 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
add comment
netsh interface ipv4 set route 0.0.0.0/32 "Local Area Connection" 192.168.1.1 

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 0.0.0.0/32 "Local Area Connection" 192.168.1.1 –  laconicdev Jul 22 '11 at 14:01
    
you need to use ipv4 too. See update in my answer. –  Cheekaleak Jul 22 '11 at 14:34
4  
+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
add comment

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

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|improve this answer
add comment

Your Answer

 
discard

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.