/build/static/layout/Breadcrumb_cap_w.png

Setting DNS server statically before joining domain script

In my lab testing, I always have to change my DNS servers manually before I can join to my domain since I use my router’s DHCP server, so I can’t tell what DNS servers my test machines use.

I finally got around to doing a simple google search and voila! I found the below .bat  file that queries for the adapter name, and sets the DNS servers for you. Very nicely written bat script. 

 

Tested this on Windows 10 and worked perfectly on my e6420.

 

SOURCE: http://superuser.com/questions/463096/change-dns-with-script


Just change the IP Addresses in teh code below and run this script before your join domain post install task runs on your K2000. 

NOTE: I tested this on Windows 10 successfully


.bat file code:


:: Set primary and alternate DNS for IPv4 on Windows Server 2000/2003/2008 & 
:: Windows XP/Vista/7
@ECHO OFF
SETLOCAL EnableDelayedExpansion
SET adapterName=
FOR /F "tokens=* delims=:" %%a IN ('IPCONFIG ^| FIND /I "ETHERNET ADAPTER"') DO (
SET adapterName=%%a
REM Removes "Ethernet adapter" from the front of the adapter name
SET adapterName=!adapterName:~17!
REM Removes the colon from the end of the adapter name
SET adapterName=!adapterName:~0,-1!
netsh interface ipv4 set dns name="!adapterName!" static 10.0.0.120 primary
netsh interface ipv4 add dns name="!adapterName!" 8.8.8.8 index=2
)
ipconfig /flushdns
:EOF


Comments

This post is locked
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ