Override a single external hostname with internal DNS-entry
Company.com has an exernal dns-record for service.company.com which should be resolved to an inernal IP by internal clients.
Let’s say that service.company.com resolves to 18.104.22.168 by the external DNS but when computers are connecting to this URL from inside the company network the internal DNS servers at ad.company.com needs to resolve service.company.com to 172.16.51.25.
Adding an entry to the hosts-file on each client computer to override service.company.com will not work when clients connect on exteral networks like from home or a coffeeshop.
The solution is to add a new Forward Lookup Zone named service.company.com and add a new Host-record, enter the internal IP-address but leave the Name blank.
On a DNS server running Windows Server 2012 this is of course achieved by using PowerShell!
First off, create a new DNS Forward Lookup Zone using PowerShell:
Add-DnsServerPrimaryZone -Name service.company.com -ReplicationScope Forest #Then add a host record to the zone: Add-DnsServerResourceRecordA -IPv4Address 172.16.51.25 -ZoneName service.company.com -Name service.company.com
By specifying service.company.com as both ZoneName and Name a record with the name “(same as parent folder)” will be created.
This will only override DNS queries for the FQDN service.company.com and will not affect other records in company.com