Quickly set or change DNS via a bat-script

When running Windows and you want a quick way to change DNS server, you can use a simple script in a *.bat file.

I have several DNS settings that I might want to use, depending if I the situation.

Where the “Ethernet” is the name of my network card name, change this if necessary.

nicname

When you want to change the DNS setting, just right-click, select run as administrator and you are done.

 

Script 1:

lan-dns-dhcp.bat
netsh interface ipv4 set dns "Ethernet" dhcp
ipconfig /flushdns

 

Script 2:

lan.dns-google.bat
 netsh interface ipv4 set dns "Ethernet" static 8.8.8.8
 netsh interface ipv4 add dns "Ethernet" 8.8.4.4 index=2
 ipconfig /flushdns

 

Script 3:

 lan-dns-dhcp.bat
 netsh interface ipv4 set dns "Ethernet" static 208.122.23.23
 netsh interface ipv4 add dns "Ethernet" 208.122.23.22 index=2
 ipconfig /flushdns