Windows 10 batch file dns

2

I have two batch-files, one to change my DNS to Unblock-US, and one to reset it to DHCP. These worked perfectly in Windows 7 and 8/8.1, but after upgrading to Windows 10 i can no longer reset it to DHCP.

Unblock-US batch:

netsh interface ipv4 set dns "Ethernet 2" static 208.122.23.22
netsh interface ipv4 add dns "Ethernet 2" 208.122.23.23 index=2
ipconfig /flushdns

DHCP batch:

netsh interface ipv4 set dns "Ethernet 2" static dhcp
netsh interface ipv4 add dns "Ethernet 2" dhcp index=1
ipconfig /flushdns

Anyone have an idea what may be wrong?

Jens-Christian Christiansen

Posted 2015-10-15T07:30:28.570

Reputation: 21

1Do you get an error message? Have you tried running as Admin? – DavidPostill – 2015-10-15T07:32:15.350

1Is the adapter definitely called Ethernet 2? – CharlesH – 2015-10-15T08:03:14.613

@DavidPostill: No error message, it just won't change it to DHCP. I'm running as admin – Jens-Christian Christiansen – 2015-10-15T08:06:35.440

@CharlesH: Yes, it is Ethernet 2. It will change to Unblock-US, but not back to DHCP – Jens-Christian Christiansen – 2015-10-15T08:07:31.767

In netsh interface ipv4 set dns "Ethernet 2" you should use either static or dhcp but not both together, see netsh interface ipv4 set dns /? – JosefZ – 2015-10-15T10:20:42.563

Answers

1

change this:

netsh interface ipv4 set dns "Ethernet 2" static dhcp

to

netsh interface ipv4 set dns "Ethernet 2" dhcp

remember to execute this with Admin privileges and the second line is superfluous.

Roberto Bani

Posted 2015-10-15T07:30:28.570

Reputation: 11