This article is a step by step tutorial on how to install and configure a DNS Server on Windows Server 2016 /2012 R2. Also we will show you how to create forward and reverse lookup zones. For a start, we’ll also take a look at what’s the DNS service and what it is used for.
DNS (Domain Name System) is a system that allows you to find the IP address of a host by a domain name and vice versa. DNS server—this network service provides and supports DNS operation. The DNS server may be responsible for the specific zone in which the corresponding computers are located. Since the DNS system is hierarchical system, the DNS server can redirect the request to the upstream server if it cannot determine the IP address of the host by the domain name.
Most often, the DNS server role is installed along with the installation of the Active Directory domain controller role. If you don’t need AD, you can install the DNS server role separately.
Important! Before install, make sure your DNS server has a static IP-address.
Now let’s begin.
The fastest way is to install the DNS server role in Windows Server 2016 using the following PowerShell command (run it with an administrator permissions):
Install-WindowsFeature DNS -IncludeManagementTools
You can also install the DNS server role from the Server Manager GUI. Open Server Manager and click on Add Roles and Features.
Select Role-based or feature-based installation option and click on Next.
Here you need to select desired server you’d like to install DNS Server (usually this is the current server).
From Server Roles lists select DNS server and click on Next. Click Add Features on the popup window—in this case, the DNS management console and PowerShell DNS module will be installed automatically. If you want to manage this DNS server remotely, you can not install these tools.
Now you can see that item DNS is checked.
No additional features required for this step, but we want to be sure that DNS Server Tools is already selected. To check this, click on Remote Server Administration > Role Administration Tools. Then click on Next.
Here just click on Next.
To confirm installation press Install.
Installation process started, it may take few minutes.
DNS Server Installation is successfully completed, click on Close.
So, the server role of the DNS server is installed. Now you can configure your DNS Server. To run DNS server management tools, click on Tools in the upper right corner of Server Manager and click on DNS in the drop-down list.
Select your server on the left side of DNS Manager window to open zone list.
Currently there are no zones configured on your DNS server. This server is called caching. Zones are parts of the namespace for which the server is responsible. Forward lookup zones are used to convert a name to an IP address. The reverse lookup zone, on the contrary, matches the IP address with the hostname. The presence of a reverse lookup zone on the DNS server is not necessary, but it is easy to configure and provides the full functionality of the DNS service.
Right-click on Forward Lookup Zones and click on New Zone from context menu to bring up the New Zone Wizard.
In this window click Next.
In this step you can select the type of DNS you want to use. The primary zone will be located on your server, the secondary zone will be located on another server. The secondary zone is used in large networks for load balancing. Choose Primary zone and click on Next to continue.
Enter any name for new zone file and click on Next button.
Specify the name of the zone file.
Dynamic updates allow DNS clients register their resource records in DNS database automatically, but if the network is small we can make updates of DNS database manually. It is recommended to allow dynamic updates, but only if DNS will be used exclusively on your local network. Otherwise, this item may entail security risks, as the “New Zone Wizard” will warn you about.
On the next window just click on Finish.
That’s all, forward zone created. Setting the zone is done by adding DNS records to the zone. There are several types of DNS records. Consider the main types of DNS records:
- A-record (AAAA-record)—matches the hostname and IP address;
- CNAME-record—used to forward to another name;
- MX—mail entry, points to mail servers;
- NS—points to DNS server.
If earlier you have chosen Do not to allow dynamic updates, you should add records to zone manually. To do this right click on zone name and click on New Host (A or AAAA).
Here enter name and IP-address of your DNS Server in appropriate fields and then click Add Host.
A message appears stating that the node has been created.
The host record was successfully created.
You can also create an A record using PowerShell:
Add-DnsServerResourceRecordA -Name 'client1' -ZoneName 'test.contoso.com’ -IPv4Address 192.168.0.100
As you can see on the right side of the DNS Manager window, the new host is now created. You can create records for client computers in exactly the same way.
Now you should add Reverse Lookup Zone. To do this right click on Reverse Lookup Zone and click on New Zone from the action menu to bring up the New Zone Wizard.
Next steps will be the same as for Forward Lookup Zone, click Next.
Choose Primary zone and click on Next to continue.
Here you need to select the type of IP-address, check on IPv4 and click on Next to continue.
In Network ID field enter the first three octets of your DNS Server IP-address.
Just click on Next.
Check Do not allow dynamic updates and press Next.
Click on Finish button and your DNS server is now configured and ready for use.
As you can see on the right side of DNS Manager window, Reverse Lookup Zone is now created.
In order to obtain domain name or IP address mapping using the command nslookup:
Tip. Don’t forget to check which DNS server is specified in the settings of the network interface (it should be, respectively, the IP address of the current server).
In order for a DNS server to resolve addresses in other zones, you need to configure DNS Forwarders. To do this, in the DNS Manager console, open the properties of your server.
Go to the Forwarders tab, click the Edit button and add the address of the external DNS server to which you want to forward requests (for example, 184.108.40.206).
You can also configure DNS Forwarders using the command:
Add-DnsServerForwarder -IPAddress 220.127.116.11 –PassThru