How To Configure DNS Server In Linux OS In 9 Simple Steps? | Zindagi Technologies (2024)

What is DNS?

How To Configure DNS Server In Linux OS In 9 Simple Steps? | Zindagi Technologies (1)

The Domain Name System (DNS) turns domain names into IP addresses, which browsers use to load internet pages. Every device connected to the internet has its own IP address, which is used by other devices to locate the device.

How DNS works?

In the first step DNS resolver, also called recursive resolver designed to receive DNS queries from a web browser and other applications. The resolver receives a hostname, for example, www.zindagi.com, and is responsible for tracking down the IP addresses for that hostname.

After that root server is translating human-readable hostname into IP addresses. There are 13 logical root servers worldwide, denoted by letter A through M controlled by Cogen, the University of Maryland, and the U.S arm lab. The TLD nameserver takes the domain provided in the query and provides the IP of an authoritative name server. The authoritative name server takes the domain name and subdomain, and it returns the correct IP address to the DNS resolver.

9 Steps Of DNS Configuration

Let’ see how to configure a DNS server in 9 easy steps.

Step 1

Install bind packages with their dependencies.BIND stands for Berkley Internet Naming Daemon. BIND is the most common program used for maintaining a name server on Linux.

 # Yum install –y bind*

Step 2

Assign a static IP address in Linux OS. Configure network file.

 # Vim /etc/sysconfig/network-scripts/ifcfg-eth0
How To Configure DNS Server In Linux OS In 9 Simple Steps? | Zindagi Technologies (2)

Step 3

Add a host entry in the host file. Just add your local machine IP address with the domain name of the website which you are hosting on a local server. After the edit, the host file restarts the network and ping the specified IP address to see whether the data is exchanged or not.

 # vim /etc/hosts
How To Configure DNS Server In Linux OS In 9 Simple Steps? | Zindagi Technologies (3)

Step 4

Add server IP to the resolv.conf file.

 # Vim /etc/resolv.conf
How To Configure DNS Server In Linux OS In 9 Simple Steps? | Zindagi Technologies (4)

Step 5

Configure /etc/named.conf file and edit the following lines.

 # Vim /etc/named.conf

Step 6

Open /etc/amed.rfc1912.zones file. Next, we need to add zone records for the forward zone file and reverse zone file. In this file, we set up a master forward record and master reverse DNS record.

How To Configure DNS Server In Linux OS In 9 Simple Steps? | Zindagi Technologies (5)

Step 7

Configure forward and reverse zones. Now create the forward zones and reverse zone files and replace them with your hostname Forward Zone is where the hostname (or FQDN) to IP address relations is stored; it returns an IP address using the hostname. Note that normal DNS queries are forward lookup queries. On the other hand, a Reverse Zone returns the FQDN of a host based on its IP address.

How To Configure DNS Server In Linux OS In 9 Simple Steps? | Zindagi Technologies (6)
How To Configure DNS Server In Linux OS In 9 Simple Steps? | Zindagi Technologies (7)

Step 8

Change the group ownership for forward zone and reverse zone files.

 # chgrp named /var/named/forward. Zone
 # chgrp named /var/named/reverse. Zone

Step 9

Restart the DNS service.

 # Service named restart

In the next step, you should use the ns lookup utility to query the IP using the hostname and vice versa. You can also use dig to test DNS servers.

Zindagi Technologies is a leading IT Consulting company and has been performing under the best circ*mstances for more than half a decade. We have delivered solutions and to all the issues and challenges that are presented to us by different organizations. Giving the top class managed IT services, we have gained a good and reputed clientele in the private and public sectors. If you require services related to IoT, Data Centre, Cloud, Managed IT, Security then give us a call or WhatsApp us on +919773973971 or drop us a mail, we’ll be happy to serve you.

Author
Pankaj Bakshi
Associate Consultant

Post Views: 87,642

How To Configure DNS Server In Linux OS In 9 Simple Steps? | Zindagi Technologies (2024)

FAQs

How To Configure DNS Server In Linux OS In 9 Simple Steps? | Zindagi Technologies? ›

To configure the DNS server in Linux, we can modify the /etc/resolv. conf file. This is a plain text file that contains the IP address of the DNS server that the system should use for hostname resolution. To add a DNS server, we simply need to insert a “nameserver” line followed by the IP address of the DNS server.

How to configure DNS in Linux step by step? ›

Steps of DNS Configuration
  1. Step - 1: Determine Your Linux Distribution.
  2. Step - 2: Install DNS Server Software.
  3. Step - 3: Configure Bind DNS Server.
  4. Step - 4: Define DNS Zones and Records.
  5. Step - 5: Update the name.conf File with Zone Information.
  6. Step - 6: Restart and Update DNS Resolvers.
  7. Step - 7: Testing the DNS Server.

How to configure DNS server in Linux RHEL 9? ›

Procedure to change DNS ip address in RHEL
  1. Edit the /etc/resolv.conf file with an editor, such as nano or vim in RHEL: ...
  2. Set the name servers (DNS IP) that you want to use on RHEL : ...
  3. Save and close the file in RHEL.
  4. Test new settings.
  5. On a modern RHEL 8/9 use the nmcli command instead of editing the /etc/resolc.
Sep 12, 2022

How to configure DNS server in CentOS 9? ›

How to Change CentOS DNS Server [CentOS DNS Setting]
  1. First, you'll need to open up the /etc/resolv. ...
  2. Next, locate the line that starts with "nameserver" and replace the IP address that follows with the new DNS server's IP address. ...
  3. Finally, save your changes and exit the text editor.
Dec 17, 2023

How do I manually configure DNS? ›

Android
  1. Open “Settings” and go to “Network & Internet.”
  2. Tap on “Wi-Fi”.
  3. Tap and hold your current Wi-Fi network.
  4. Select “Modify network”.
  5. Toggle on “Advanced options.”
  6. In the “DNS” field, enter the new DNS server IP addresses.
  7. Save your changes.

How to configure DNS and hostname in Linux? ›

To configure the DNS server in Linux, we can modify the /etc/resolv. conf file. This is a plain text file that contains the IP address of the DNS server that the system should use for hostname resolution. To add a DNS server, we simply need to insert a “nameserver” line followed by the IP address of the DNS server.

Where is DNS config in Linux? ›

The DNS configuration files are stored in the /etc/bind directory. The primary configuration file is /etc/bind/named.conf , which in the layout provided by the package just includes these files. The root nameservers used to be described in the file /etc/bind/db.root .

How to set DNS server in Linux server? ›

Using Network Manager
  1. Open Settings, then select either Network or Wi-Fi based on your network type.
  2. Click the gear button and go to the IPv4 tab.
  3. Next to DNS, disable the Automatic toggle.
  4. In the DNS field enter 103.86.96.100 and 103.86.99.100 separated by a comma: ...
  5. Click Apply.

What is the command for DNS server in Linux? ›

The dig command in Linux is used to gather DNS information. It stands for Domain Information Groper, and it collects data about Domain Name Servers. The dig command is helpful for troubleshooting DNS problems, but is also used to display DNS information.

How to set DNS in Linux Ubuntu? ›

How to customize DNS servers in network settings
  1. Step 1: Launch the system Settings and select the Network menu.
  2. Step 2: Enter the desired DNS server in the IPv4 and IPv6 pop-up in the appropriate format. ...
  3. Step 3: To ensure that the switch has worked, cut the server connection for a moment.
Aug 25, 2023

How to add DNS in Linux command line? ›

Firstly, you can use the method of changing systemd configurations to change the DNS changes permanently. To do this, again with sudo privileges open /etc/systemd/resolved. conf. Then, uncomment the DNS and Fallback DNS lines and add your considered name servers and save the file to change the nameservers.

How to set DNS to 8.8 8.8 in Linux? ›

Setup the DNS Server using Network Manager

Click the Network Configuration or Network Setting. Choose your network connection and click the gear icon. Now, depending on the network configuration, select the IP version – IPv4 or IPv6. Select the “Manual” in the DNS Section and add 8.8.

How to check DNS in Linux command line? ›

The nslookup command in Linux is used to query DNS servers and get information about domain names and their corresponding IP addresses. The syntax used for the command is as follows, nslookup [options] domainname.com .

How to set DNS by command line? ›

How to Change DNS Servers With Command Prompt
  1. Open an elevated Command Prompt.
  2. Type netsh and press Enter.
  3. At the netsh> prompt, type interface ip show config, then press Enter.
  4. Locate the network connection for which you want the DNS server changed.
  5. Enter interface ip set dns "Ethernet0" static 8.8.
Jul 26, 2022

What is the DNS configuration file in Linux? ›

On most Linux operating systems, the DNS servers that the system uses for name. resolution are defined in the /etc/resolv.conf file. That file should. contain at least one nameserver line. Each nameserver line defines a DNS.

What is the command for DNS configuration? ›

To see your current DNS settings, type ipconfig /displaydns and press Enter. To delete the entries, type ipconfig /flushdns and press Enter. To see your DNS settings again, type ipconfig /displaydns and press Enter. You should see blank records or you might get the message "Could not display the DNS Resolver Cache."

How to set DNS to 8.8.8.8 in Linux? ›

Setup the DNS Server using Network Manager

Click the Network Configuration or Network Setting. Choose your network connection and click the gear icon. Now, depending on the network configuration, select the IP version – IPv4 or IPv6. Select the “Manual” in the DNS Section and add 8.8.

How to use DNS command in Linux? ›

The nslookup command in Linux is used to query DNS servers and get information about domain names and their corresponding IP addresses. The syntax used for the command is as follows, nslookup [options] domainname.com .

How to enable DNS in Linux? ›

9 Steps Of DNS Configuration
  1. Install bind packages with their dependencies. ...
  2. Assign a static IP address in Linux OS. ...
  3. Add a host entry in the host file. ...
  4. Add server IP to the resolv. ...
  5. Configure /etc/named. ...
  6. Open /etc/amed. ...
  7. Configure forward and reverse zones.
Oct 11, 2021

How to configure DNS cache in Linux? ›

To configure the DNS servers that systemd-resolved will query to resolve domains, we need to edit the systemd-resolved configuration file and include the necessary public or private DNS address pair. For this article, we'll use Google's Public DNS address pair – it's free and supports both DoT and DNSSEC: 8.8. 8.8.

Top Articles
Latest Posts
Article information

Author: Gov. Deandrea McKenzie

Last Updated:

Views: 5774

Rating: 4.6 / 5 (46 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Gov. Deandrea McKenzie

Birthday: 2001-01-17

Address: Suite 769 2454 Marsha Coves, Debbieton, MS 95002

Phone: +813077629322

Job: Real-Estate Executive

Hobby: Archery, Metal detecting, Kitesurfing, Genealogy, Kitesurfing, Calligraphy, Roller skating

Introduction: My name is Gov. Deandrea McKenzie, I am a spotless, clean, glamorous, sparkling, adventurous, nice, brainy person who loves writing and wants to share my knowledge and understanding with you.