Monday 1 September 2014

Adding mutiple DNS servers with "netsh int ip" batch command in Windows 8.1

I needed a CMD batch file to change DNS servers for some testing but couldn't find the correct syntax to add more than one DNS server, eg set a primary DNS and a secondary DNS.

The basic command (don't forget to use an elevated Run As Administrator command shell or batch file) is
   netsh int ip set dns "Ethernet connection" static 8.8.8.8

I'm sure on older versions of Windows you could specify multiple servers in one lines using a space or string or comma (or something like that) - maybe I made that up. I googled and tracked down an index option which let you specify a secondary dns server - but not in Windows 8.1 unfortunately. That option is no longer recognised.

Trick in the end was to use set for the primary and add for the secondary, eg.
   netsh int ip set dns "Ethernet connection" static 8.8.8.8 primary
   netsh int ip add dns "Ethernet connection" 8.8.4.4

HTH

No comments:

Trust 1&1 Internet for your domain name registration, from only £1.99/year!. Check now!