Reputation: 33
I am creating a batch file for our laptops that sets a series of static ipaddresses onto the Ethernet interface for configuring machines with multiple networks.
I can easily set static ip addresses to the interface by the commands:
netsh interface ip set address Ethernet xxx.xxx.xxx.xxx 255.255.255.0 xxx.xxx.xxx.1 1
netsh interface ip add address Ethernet xxx.xxx.yyy.xxx
netsh interface ip add address Ethernet xxx.xxx.zzz.xxx
This works flawlessly.
However, i want an option to remove them all from the interface and reset the Ethernet interface to 'Obtain Network Settings Automatically' for both IPv4 and DNS.
I have individually tried variations of all the following:
netsh interface ip set address Ethernet dhcp
netsh interface ip set address Ethernet source=dhcp
netsh interface ipv4 set address Ethernet dhcp
netsh interface ipv4 set address Ethernet source=dhcp
netsh int ip set address Ethernet dhcp
netsh int ipv4 set address Ethernet source=dhcp
They all return DHCP is already enabled on this interface
And when I open the network adapter settings GUI in windows and configure the IPv4 settings, all the static ip addresses are still there and it hasn't reversed to autoconfigure.
I would prefer to not have to use the flush, renew etc commands as they all require the PC to be restarted.
What am I doing wrong?
Upvotes: 0
Views: 69