Quickly Configure DNS Server IPs From Windows Command Prompt

The common way to set IP addresses for primary and secondary DNS  servers in Windows is through Network and Sharing Center > Change Adapter Settings followed by selecting “Properties” of the specific adapter and then configuring IP settings.

Common way of modifying properties of network connections in Windows

All of the above can be done through just two lines from Windows command prompt. Suppose DNS server IPs to be set are and (these are OpenDNS IPs, here is the related post on that), then to do this :

Open Windows command prompt as and administrator (Right click and select “Run as administrator” for Accessories > Command prompt).

Open Windows command prompt as administrator

then enter the following :

netsh interface ip set dns name="Local Area Connection" static

This will set the IP address of primary DNS server as

To set the secondary DNS IP :

netsh interface ip add dns name="Local Area Connection" index=2

Setting DNS server IP addresses through Windows command prompt

So now, the primary and secondary DNS servers will be having IP addresses : and

Same can be verified through the adapter properties :

Configured DNS server IP addresses

Short and sweet. 🙂

Comments are closed.