Quantcast
Channel: Windows Server Archives - WinCert
Viewing all articles
Browse latest Browse all 64

Set DNS servers via GPO Server 2012 R2

$
0
0

Windows Server,access,permission,ipsec fails,printers offline,printer installation,trusted sites,item,installation file missing,user profiles,terminal services,dhcp superscope,client certificates,server storage,terminal server failed,ci files,volume license

We are currently in the migration process of Windows Server 2003 Single Label DNS domain to Windows Server 2012 R2 domain. We are also migrating our Windows XP clients to Windows 7.

After successful migration of computer and server objects we had to transfer our DNS  Group policy object which we used to set our primary and secondary DNS servers.

Unfortunately this policy was valid only for Windows XP and Windows Server 2003 machines and it was located at:

Computer Configuration | Administrative Templates | Network |DNS Client | DNS Servers

dns_old

 

As you can see in the picture above, this setting is supported on Windows XP Professional only so it won’t work with Windows 7 or Windows Server 2008 and newer clients. Have in mind that Microsoft recommends using DHCP for setting up DNS servers, but since this option is not fully applicable in our environment we had to find another way to achieve this.

We have tried to set DNS servers using our .bat script syntax:

set address [name=]InterfaceName [source=]{dhcp | static [addr=]IPAddress [mask=]SubnetMask [gateway=]{none | DefaultGateway [[gwmetric=]GatewayMetric]}}

Unfortunately that didn’t work either so we’ve found another way to do this. Here’s the script that is working with Windows 7, Windows 8 and 8.1, Windows Server 2008/R2 and Windows Server 2012 R2.

@echo off
set dnsserver=192.168.1.1
set dnsserver2=192.168.1.2
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
 )
)

You should change bold values with your DNS server addresses.

You should save this script as a .bat file and create a new Group Policy Object.

Define GPO to start this script at:

Computer configuration | Policies | Windows Settings | Scripts | Startup

dnsupdate1

dnsupdate2

There you go. Your clients should now receive DNS servers via Group policy.

Feel free to leave your comments below.

The post Set DNS servers via GPO Server 2012 R2 appeared first on WinCert.


Viewing all articles
Browse latest Browse all 64

Trending Articles