DNS Server IP Address change in Client Systems through Group Policy
Scenario:
Recently our network team, restructure IP segments & it
is recommended to change the IP address of our DNS server. It is an AD
integrated DNS server & around 1000 desktops & laptops are in the
network – all have static IP addresses. We need to change the DNS IP for all
the systems.
Procedure:
We can change the DNS IP through Group Policy with the help
of a simple *.bat file. We will apply the GPO in Startup as Computer base policy. But here tricky part is, we need
run the batch file in "Run as Administrator" mode. Most of the
Computer-based Startup GPO is not run in normal mode.
The batch file as below, suppose it name DNSIP_Change.bat
: Replace your DNS Server “set dnsserver=X.X.X.X”
@echo off
set
dnsserver=10.10.10.31
set
dnsserver2=10.10.10.30
for /f
"tokens=1,2,3*" %%i in ('netsh interface show interface') do (
if %%i EQU Enabled (
rem echo change "%%l" : %dnsserver%
netsh interface ipv4 set dnsserver
name="%%l" static %dnsserver% both
netsh interface ipv4 add dnsserver
name="%%l" %dnsserver2% index=2
)
)
1.
Create a GPO: "GPO_DNS Server IP Change”
2. Note its Unique ID for the GPO : {A013DF9D-E86D-4E15-ABA6-377F23485315}
Pix-01: GPO Unique ID (i.e. GUID) |
Pix-02: Go to the "Startup" Properties |
4. Click on “Show Files” > Note down the path > Browse the path & copy the “DNSIP_Change.bat” into this location.
Pix-03: Path of "Startup" location |
5. Now click on “Add” in Startup properties window > Browse the location of “DNSIP_Change.bat” > OK > Apply.
Pix-04: Startup Properties |
Pix-05: Browse the batch file |
Pix-06: DNSIP_Change.bat in Startup Properties window |
Pix-07: Browse the file for Startup in a normal way |
6. Now link the GPO to intended Computer OU.
Link: https://www.wincert.net/windows-server/set-dns-servers-via-gpo-server-2012-r2/
Hi, thank you.
ReplyDeleteI also used a similar method with powershell to change DNS servers. this allow to update DNs servers IPs.
https://itdungeon.blogspot.com/2021/11/update-dns-static-servers-in-your-local.html
best regards!