We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – Install and Configure DNS Server on Windows Server 2022

Learn how to – Install and Configure DNS Server on Windows Server 2022.

DNS is an abbreviation of Domain Name System. It translates domain names, such as google.com or facebook.com, into IP addresses (numerical values computers use to identify and communicate with each other over the Internet). Each device connected to the internet has its own unique IP address, however, these numbers so have for humans to memorize. For that reason, domain names were created to provide an easier way of accessing websites and online services.

DNS works by maintaining a database of domain names and their corresponding IP addresses, which can be distributed across a global network of servers.

There are two main types of DNS services:

  • Private DNS: This is used within an organization’s internal network to translate domain names into IP addresses for devices on that network. It is typically used for devices and services that are not intended to be accessed from outside the organization’s network. Private DNS servers are often managed by the organization’s IT department and are not accessible from the Internet.
  • Public DNS: This is used by devices and services that are accessible from the Internet. Public DNS servers are typically managed by Internet Service Providers (ISPs) or third-party companies, and they translate domain names into IP addresses for devices outside of an organization’s network. Public DNS servers are accessible from the Internet and can be used by anyone to resolve domain names into IP addresses. The popular public DNS servers are Google Public DNS, OpenDNS, Cloudflare DNS etc.

For any organization, it is so important to have a DNS server to translate domain names into IP addresses for devices on its internal network. Below are some of the reasons why a DNS server is required:

  • Control: through managing its own DNS server, an organization has more control over the DNS resolution process, including the ability to configure DNS records, monitor DNS activity, and enforce security policies.
  • Efficiency: they also cache previously resolved queries, allowing for faster resolution of frequently accessed domain names.
  • Scalability: they can be scaled up to handle large amounts of traffic, ensuring that DNS resolution remains reliable even during periods of high demand.
  • Security: DNS servers can be configured to block access to malicious or inappropriate websites, providing an additional layer of security for the organization’s network.
  • Convenience: DNS allows users to access resources on the Internet using easy-to-remember domain names instead of numerical IP addresses.

This guide aims to help you Configure DNS Server on Windows Server 2022.

Prerequisites

For this guide, you will need the following:

  • A computer running a support version of Windows Server.
  • A static IP.
  • An account that is a member of the Administrators group, or equivalent.

Step 1: Install DNS Server on Windows Server 2022

There are two ways of installing the DNS Server on Windows Server 2022. These are:

  • Using the GUI
  • Using PowerShell

Method 1 – Install DNS Server on Windows Server 2022 using GUI

From the start menu, launch Server Manager.

Navigate to Manage and select Add Roles and Features.

Select  Role-based or feature-based

Choose your destination server 

While here, select Install DNS Server and click Add Features:

Confirm the selection and install the DNS Server

Install the DNS server.

Method 2 – Install DNS Server on Windows Server using PowerShell

It is also possible and easier to install a DNS Server on Windows Server using PowerShell. Launch PowerShell as an administrator and execute the below command:

Install-WindowsFeature -Name DNS -IncludeManagementTools

Sample Output:

Step 2: Configure DNS Server on Windows Server 2022

Once you have installed it, there are several configurations you need to do for the DNS Server to resolve requests as desired. Here, there is the concept of zones. A zone is used to organize and manage DNS records for a particular domain or set of domains.

The types of DNS zones are:

  • Primary zone: This type of zone is the main DNS zone( acts as the authoritative source for DNS records) for a particular domain. The primary zone is typically hosted on the organization’s DNS server, and changes to the DNS records must be made on this server.
  • Secondary zone: This type of zone contains a read-only copy of the DNS records from the primary zone. Secondary zones are typically hosted on a separate DNS server and are used for redundancy and load balancing.
  • Stub zone: This type of zone contains only the name servers (NS) of a primary zone/a subset of the DNS records from the primary zone. It is used to speed up DNS resolution by caching frequently accessed DNS records.
  • Active Directory-integrated zone: This type of zone is used in Windows Server environments and is integrated with Active Directory. DNS records are stored in the Active Directory database, providing enhanced security and replication capabilities.

All the above DNS zones can have:

  • Forward Lookup Zone: also known as a regular DNS zone. resolves names and, sometimes, services to IP addresses.
  • Reverse Lookup Zone: also known as a PTR (Pointer) record. It resolves IP addresses to domain names.

We will configure forward and Reverse lookups in the Primary DNS zone. This can be done in two ways:

Method 1. Configure DNS Server on Windows Server 2022 Using GUI

To configure the DNS Server on Windows Server 2022 with this method, press WIN+R and type in dnsmgmt.msc to launch the DNS manager console:

Forward Lookup Zone

Once launched, we will start by creating the Foward Lookup Zone:

Create a Primary zone by checking the below boxes:

Provide the Zone name(domain_name):

Now create a zone file(will be saved in the C:WindowsSystem32dns directory)

On this page, select Do nor Dynamic updates:

Finish the setup and you will have the forward lookup zone created:

Reverse Lookup Zone

Proceed and create a Reverse lookup zone:

Create this on the primary zone:

select reverse lookup zone:

Create an IPv4 reverse zone:

In the zone, provide an IP address if your network is 192.168.205.0/24 then the ID will be 192.168.205

Next, create a file with the provided name:

Also here, select “Do not allow dynamic updates”

Finish the zone creation:

Method 2. Configure DNS Server Using PowerShell

To create the Zone lookup files with this method, launch PowerShell with elevated privileges.

Forward Lookup Zone

Create a Foward DNS zone with the command:

Add-DnsServerPrimaryZone -Name "learnhowto.org" -ZoneFile "learnhowto.org.dns" -DynamicUpdate None -PassThru 

Reverse Lookup Zone

Add a reverse DNS zone using the command with the below syntax:

Add-DnsServerPrimaryZone -NetworkID 192.168.205.0/24 -ZoneFile "205.168.192.in-addr.arpa.dns" -DynamicUpdate None -PassThru 

Check the created zones:

Get-DnsServerZone 

Sample Output:

Create the Zone lookup Files on DNS Server

After creating the forward and reverse zone files, we can add the DNS record types. These include:

  • A – A record
  • SOA – Start of Authority
  • MX – Mail for Exchange
  • NS – Name Server
  • CN – Canonical Name
  • SRV – Services Record
  • PTR – Pointer

Create A record

For this guide, I will demonstrate how to add the A and MX records. To do this, right-click on the Foward lookup zone.

Create a new record, say A record.

Provide the record name, FQDN and the IP address of the server to handle it:

This can also be done on Powershell using the command:

Add-DnsServerResourceRecordA -Name "web" -ZoneName "learnhowto.org" -IPv4Address "192.168.205.11" -TimeToLive 01:00:00 -CreatePtr -PassThru 

Verify the changes:

Get-DnsServerResourceRecord -ZoneName "learnhowto.org" | Format-Table -AutoSize -Wrap

Sample Output:

Create MX record

Using the same process, create another record say MX:

To create a similar MX record on Powershell, the command will be:

Add-DnsServerResourceRecordMX -Name "mail" -MailExchange "web.learnhowto.org" -ZoneName "learnhowto.org" -Preference 10 -TimeToLive 01:00:00 -PassThru 

Once the records have been created, we can verify them as below.

Get-DnsServerResourceRecord -ZoneName "learnhowto.org" | Format-Table -AutoSize -Wrap

Sample Output:

Step 3: Verify DNS Name Resolution

To test if the created DNS server is working as desired. Currently, on the Windows machine, we can check with the command:

nslookup web.learnhowto.org localhost 

Sample output:

That shows that the DNS server is working as desired. We will now see how we can configure a client to use the created DNS server.

On Linux

On Linux systems, provide the address of your DNS server in the below file:

$ sudo vim /etc/resolv.conf
nameserver 192.168.205.21

Save the file and test using the Dig command:

dig web.learnhowto.org

Sample Output:

You can also check the MX record:

dig MX mail.learnhowto.org

Sample Output:

You can also check the reverse lookup:

dig -x 192.168.205.11

Sample Output:

On Windows

To use the DNS server on a Windows system, modify your Internet settings and provide the DNS server as your DNS.

Once the settings have been saved, use the below command on PowerShell to verify:

nslookup web.learnhowto.org
nslookup mail.learnhowto.org

Sample Output:

Step 4: Configure DNS Forwarder on Windows Server 2022

A DNS is responsible for forwarding DNS requests from clients to other DNS servers on the Internet. It works by the recursive DNS resolution process. This means that when a client computer needs to resolve a domain name into an IP address, it sends a DNS request to a DNS resolver. If the DNS resolver does not have the necessary information in its cache, it will forward the request to another DNS server that is authoritative for the domain name in question.

You can configure the DNS server installed to forward the requests to any other DNS server. For this guide, I have two DNS servers configured with different records.

To add a DNS forwarder, you can use two methods.

From the PowerShell(adding 192.168.205.20 as the DNS forwarder)

 Add-DnsServerForwarder -IPAddress 192.168.205.20 -PassThru 

Verify the changes:

Get-DnsServerForwarder 

Sample output:

You can also set the DNS forwarder from the GUI by right-clicking on the Hostname and selecting Properties

Navigate to the Forwarders tab and Click the Edit button.

Provide the Hostname or IP address you’d like to set as a Forwarder.

Now we can test if the forwarder is working. The added DNS forwarder server is configured with a separate domain name learnhowto.lab

So my test results are as shown:

Next article will be on how to configure secondary DNS server:

Final verdict

Today we have learned how to configure a DNS Server on Windows Server 2022. we have learned how to do it from the GUI as well as PowerShell. I hope this was informative.

See more

Cart

Your Cart is Empty

Back To Shop