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?

[Webinar] Streamline your web hosting managementRegister Today

x
 
QlemoConnect With a Mentor DeveloperCommented:
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
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
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
All Courses

From novice to tech pro — start learning today.