How to configure DNS Server in Linux

This tutorial explains how to configure DNS name servers on Linux. Learn how to set up a virtual practice lab on VMware to configure, test, and verify DNS name servers on Linux.

There are mainly four types of DNS name servers caching-only, forwarding, primary or master, and secondary or slave.

  • A caching-only DNS name server performs recursive queries on behalf of end devices and saves the results in a cache file.
  • A forwarding DNS name server forwards all queries to the caching-only name server and saves the result in a cache file.
  • A primary or master name server resolves queries for the domain. It reads zone files to resolve queries. It does not accept recursive queries.
  • A secondary or slave name server resolves queries when the primary or master name server fails. It also reads zone files to resolve queries and does not accept recursive queries.

To explain how to configure, test, and verify these name servers, I will use a pre-built RHCE practice lab. In this lab, I have three RHEL Linux systems. I will configure name servers on two systems and use the reaming system for testing.

The following image shows this lab.

lab setup on vmware

I used VMware Workstation to set up this lab. It doesn't matter whether you use physical or virtual systems to set up this practice Lab, the instructions and configuration steps for DNS name servers are the same on all platforms. If you want to replicate this lab on physical systems, you need three systems.

The following image shows this lab's layout with physical systems.

lab setup on physical systems

To learn how to set up this lab, you can use the following tutorials. These tutorials explain the steps to set up this lab on VMware Workstation and VirtualBox.

I prepared this LAB exclusively to explain RHCE exam topics. Since the RHCE exam does not allow candidates to use the Internet, I did not configure this LAB to use the Internet. To perform the exercises explained in this tutorial series, we need to connect all virtual machines to the Internet.

To do this, we need to change the network connection type. Currently, the network connection type of all three systems is NAT. We need to change it to Bridged. A Bridged connection allows the virtual system to access the host's internet connection.

To change the network connection type, power off the virtual machine, open its settings and click the Network Adaptor option. On the opened window, select the network connection type to Bridged and click OK. Repeat this process on all three virtual machines.

The following image shows this process.

lab set up on vmware

We also need to update IP configurations on all systems. For this, power on the virtual machine, log in from the root account and update the IP configuration as the following.

  • Configure Modem's IP address as the default gateway IP address. My modem's IP address is 192.168.29.1. So, I will use this IP address as the gateway IP address on all virtual machines.
  • Use an IP address from the gateway IP address's network for each system. I will use the IP addresses 192.168.29.100/24, 192.168.29.101/24, and 192.168.29.102/24 for RHELServer1, RHELServer2, and RHELClient.
  • Configure the IP address 8.8.8.8 as the DNS server's IP address. If you know your ISP's DNS server's IP address, you can use it. If you do not know that, you can this address. This IP address belongs to Google's public DNS server.
  • Disable IPv6 configuration. To keep this tutorial series simple, I will use only IPv4 addresses. The configuration steps for both IPv4 and IPv6 are the same.
  • Activate the connection and access any website to verify the system can access the Internet

There are many ways to configure IP addresses on Linux. I have already explained them in the following tutorials.

On RHELServer1, I installed the GUI environment. If the GUI environment is installed, you can use its tool to configure and verify the IP address.

The following image shows this process on RHELServer1.

ip configuration

The following image verifies the system can access the Internet.

verify internet

If the GUI environment is not installed, you can use the nmtui command to configure IP addresses and activate connections.

The following image shows the IP configuration on RHELServer2.

nmtui on rhelserver2

The following image shows the IP configuration on RHELClient.

ip configuration on rhelclient

To test and verify the system can access the Internet, you can use the ip addr show and ping command.

testing internet

We also need to make sure that all systems have proper connectivity. To verify it, we can send ping requests from any one computer to two remaining computers. If we get replies, it verifies that all systems have proper connectivity.

testing connectivity

Checkpoints

  • All systems can access the Internet.
  • IP addresses of all systems must belong to the gateway IP address's network.
  • All systems must have proper connectivity. Use the ping command to test connectivity between systems.

If your lab meets the above criteria, it is ready for the DNS name server configuration.

Prerequisites

DNS is one of the most complex topics. It uses many confusing terms and naming conventions. I have already explained them in the following tutorials. I recommend you check them before you start configuring DNS name servers.

DNS Basic concepts, Fundamentals, and Terminology

This tutorial explains the basic concepts and fundamentals of DNS.

DNS Server and Query Types Explained

This tutorial explains DNS name server types and DNS queries.

DNS Resolver Explained

This tutorial explains how resolver systems function in DNS.

DNS zone file Format, Configuration, and Directives

This tutorial series explains how to create DNS zone files for forward and reverse mapping.

DNS name server configuration

As mentioned earlier, there are mainly four types of DNS name servers caching-only, forwarding, primary or master, and secondary or slave. The following tutorials explain how to configure, test, and verify each type in this lab.

ComputerNetworkingNotes Linux Tutorials How to configure DNS Server in Linux