How to Add Host Entry in DNS Server in Linux

Greetings Dev, are you looking to add a new host entry to your DNS server in Linux? This article will provide you with a step-by-step process to help you accomplish that.

Understanding Host Entries

Before we dive into the process of adding a host entry, let’s first understand what it means. A host entry is an identification that your computer uses to locate and communicate with other devices on a network.

When you add a host entry to your DNS server, you are essentially telling it to associate a hostname with an IP address.

What is DNS Server?

DNS stands for Domain Name System, and it is a hierarchical decentralized naming system for computers, services, or any resource connected to the internet or a private network.

A DNS server translates domain names into IP addresses, which allows computers to locate and communicate with each other.

Adding a Host Entry in DNS Server

Now that we have a basic understanding of host entries and DNS servers let’s get started with the process of adding a host entry in DNS server.

Step 1: Access the DNS Server

The first step is to access the DNS server that you want to add the host entry to. This can be done by logging in to the server as a root user.

Step 2: Open the DNS Configuration File

The next step is to open the DNS configuration file, which is located at /etc/bind/named.conf.local.

This file contains the configuration information for the DNS server, and it is where you will add your host entry.

Step 3: Add the Host Entry

To add a host entry, you will need to add a new zone to the configuration file.

A zone is a part of the hierarchical DNS domain name space, which you can think of as a subdomain.

To add a new zone, you will need to use the following format:

Zone Name
IP Address
example.com
192.168.1.1

In this example, we are adding a host entry for the domain example.com with the IP address of 192.168.1.1.

To add this to the configuration file, you would use the following syntax:

zone “example.com” {

type master;

file “/etc/bind/db.example.com”;

};

This tells the DNS server that the zone example.com is a master zone, and it should look for the zone data in the file /etc/bind/db.example.com.

Step 4: Create the Zone File

The next step is to create the zone file that you referenced in the configuration file.

The zone file is where you will define the actual host entry. It is located at /etc/bind/db.example.com in this example.

To create the zone file, you would use the following syntax:

$TTL 86400

@IN SOAns1.example.com. admin.example.com. (

2017020201 ; serial

3600; refresh

1800; retry

604800; expire

86400 ); minimum

; Name Servers

IN NSns1.example.com.

; A Records

wwwIN A192.168.1.1

READ ALSO  Everything You Need to Know About Hosting Server Lookup

In this example, we are adding a host entry for the subdomain www.example.com with the IP address of 192.168.1.1.

Add as many host entries as necessary in the zone file, making sure to use the correct syntax for each one.

Step 5: Reload the DNS Server

Once you have added your host entry and created the zone file, you need to reload the DNS server to apply the changes.

You can do this by using the following command:

sudo systemctl reload bind9

Frequently Asked Questions

What is a DNS server used for?

A DNS server translates domain names into IP addresses, which allows computers to locate and communicate with each other.

How do I access the DNS server?

You can access the DNS server by logging in as a root user.

What is a zone file?

A zone file is where you define the actual host entry. It contains the configuration information for the DNS server, and it is where you will add your host entry.

What is a host entry?

A host entry is an identification that your computer uses to locate and communicate with other devices on a network. When you add a host entry to your DNS server, you are essentially telling it to associate a hostname with an IP address.