Setting DNS servers using NETSH


I have just faced an interesting problem at work. When I log onto work's WiFi network I have to use a DNS server that is assigned by DHCP. After logging in, there is some bug that does not allow me access to company's web page that is public on the Internet. So I came up with this little trick:

And all of this can easily be done using NETSH command (everything is in a ".bat" file. It requires to be run with administrator priviliges):


ECHO Setting DNS to DHCP mode... netsh interface ip set dns name="WiFi" DHCP ECHO ...done. Press ENTER to set DNS back to Google's servers


ECHO Setting primary DNS server... netsh interface i set dns "WiFi" static ECHO ...done. Setting secondary DNS server... netsh interface ip add dns name="WiFi" addr= index=2

ECHO ...done.


NOTE: My wireless connection name is "WiFi". Adjust it to match yours accordingly.

CMD output

© Vaidas Sirtautas.RSS