Creating Lync DNS records with Server 2012 R2 DNS Cmdlets

Hi Everyone

I have been playing with Skype and Lync in Azure of late for my own personal labs (this is not supported for Production!). As I have been creating quite a few Lync/Skype environments I thought it would be cool to automated DNS record setup. I started playing with dnscmd.exe but then realized there are some DNS cmdlets in 2012 R2 which I could use. My goal was to setup DNS records for internal Skype use and so below examples are for internal records.

In my lab I was going to use a HLB for web services so the 192.168.15.199 is the VIP of the HLB. Also, in my lab my Pool Name FQDN doesn't align with the SIP domain (.org vs .com). While this is workable, you can get issues doing this *but that's another discussion for another day*.

$strDNSZone="contoso.com"
$strFrontEndPoolName="lync-pool.contoso.org"
$strIPAddressOfPoolOrHLBVIP="192.168.15.199"

Add-DnsServerResourceRecordA -ZoneName $strDNSZone -Name "lyncdiscoverinternal" -IPv4Address $strIPAddressOfPoolOrHLBVIP
Add-DnsServerResourceRecord -Srv -Name "_sipinternaltls._tcp" -ZoneName $strDNSZone –DomainName $strFrontEndPoolName –Priority 0 –Weight 0 –Port 5061
Add-DnsServerResourceRecordA -ZoneName $strDNSZone -Name "meet" -IPv4Address $strIPAddressOfPoolOrHLBVIP
Add-DnsServerResourceRecordA -ZoneName $strDNSZone -Name "dialin" -IPv4Address $strIPAddressOfPoolOrHLBVIP
Add-DnsServerResourceRecordA -ZoneName $strDNSZone -Name "lyncadmin" -IPv4Address $strIPAddressOfPoolOrHLBVIP
Add-DnsServerResourceRecordA -ZoneName $strDNSZone -Name "lyncws" -IPv4Address $strIPAddressOfPoolOrHLBVIP

And if you are keen to setup DNS Load Balancing A records for your Pool you can do that too.

#Add Pool DNS Load Balancing Records
$strIP1="192.168.15.151"
$strIP2="192.168.15.152"
$strIP3="192.168.15.153"
$strPoolShortName="lync-pool"
$strDNSZone2="contoso.org"
Add-DnsServerResourceRecordA -ZoneName $strDNSZone2 -Name $strPoolShortName -IPv4Address $strIP1
Add-DnsServerResourceRecordA -ZoneName $strDNSZone2 -Name $strPoolShortName -IPv4Address $strIP2
Add-DnsServerResourceRecordA -ZoneName $strDNSZone2 -Name $strPoolShortName -IPv4Address $strIP3

If you so choose, you can of course even create the contoso.com Primary DNS Zone (of course do this first if you haven't done it already by hand :)).

Add-DnsServerPrimaryZone -ComputerName "dc1" -Name "contoso.com" -ReplicationScope Forest

Finally, if you want to run your Powershell cmds on a machine other than a DC, then have a squiz at the -ComputerName parameter which can be run with all the commands above. This parameter sets the name of the DC that you want to make the changes against. There is extra info here at the TechNet site for the DNS commands. https://technet.microsoft.com/en-us/library/jj649925.aspx

As always test in a dev/test environment first before running in prod, these commands can easily break stuff!

Happy Skype/Lync'ing

Steve