use netsh to reset the default gateway?

I am using the following command in an automated rerouting script.

     netsh interface ip set address name="Local Area Connection" gateway=172.20.2.252 gwmetric=0

 To restore the route, I want to return the interface to full DHCP, and  I use:

    netsh interface ip set address name="Local Area Connection" source= dhcp

The interface changes back to dhcp, but the default gateway does not change back to the dhcp value. If you open the network connections TCP/IP properties, the interface is set to DHCP, but there is a "ghost" value in the default gateway box. I want to clear all values and let DHCP restore them.

HilltownHealthCenterAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
QlemoConnect With a Mentor Batchelor, Developer and EE Topic AdvisorCommented:
Seems as your DHCP server does not provide a default gateway. Try to reset it prior to switching to DHCP:
netsh interface ip set address name="Local Area Connection" gateway=none
netsh interface ip set address name="Local Area Connection" source=dhcp
0
 
rsoly777Commented:
did you try this? netsh interface ipv4 set address name=”Local Area Connection” source=dhcp
0
 
woolmilkporcCommented:
Just a guess:

ipconfig /renew

wmp
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
tlecsoCommented:
First, remove TCP/IP  service from Local Area Connection. Then add it back and maybe it works. If this method does not work, remove your Network Card and re-install it.
0
 
rsoly777Commented:
Unfortunately I don't think your script would uninstall and re-install the NIC card every time it may be possible to script the ipconfig/renew.
Maybe: http://www.emergingtechs.com/posts/create-batch-file-easily-refresh-network-settings/
http://msdn.microsoft.com/en-us/library/aa394595%28v=vs.85%29.aspx
http://www.visualbasicscript.com/renew-IP-address-in-login-script-m25435.aspx

All these have possibilities but just depends on what type of script you are running

0
 
Don ThomsonCommented:
Have you tried -

 netsh interface ip set address name="Local Area Connection" source= dhcp
ipconfig /release
ipconfig /renew
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.