You are aspiring on a career as a System administrator or a network administrator, and you don’t know the function of a DNS server? You don’t have to worry anymore because this is the right article for you to have a better understanding of a DNS server and how it works.
Domain Name System or Service is also known as DNS is responsible for translating your domain name into IP addresses on the Internet. The server responsible for providing such service is called the DNS server.
Every website you visit has an IP address and having to face through troubles of typing in or memorizing all website IP addresses, DNS server says NO! Let me save you the stress of memorizing IP addresses, just type in the website name or the domain name, and I will get it resolved for you. The DNS server came to solve problems in humans as regards to remembering numbers.
This article focuses on how to set up DNS in the /etc/hosts file in Linux systems for local domain name resolution.
HOW TO SET UP A HOSTNAME IN LINUX
Every system has a hostname which is used to identify the machine within a network in a human-readable format. Unlike other operating systems, the hostname in a Linux machine can easily be changed by using the hostname command.
However, there is a limitation in using this command to change the hostname of your system. it is not persistent across system boot.
To change the hostname of your machine to be persistent across system boot, you make use of the hostnamectl command. The hostnamectl command is the newer version of the which is present in most Linux distribution such as Ubuntu, RedHat, and Debian machines, etc. these machines run on a systemd daemon which provides the hostnamectl command to manage hostnames in Linux.
You can enter the hostname or hostnamectl status to view your current hostname
For older Linux distros which use the SysVinit can have their hostname changed by editing the /etc/hostname file.
Ok, let's kick off on learning how that is done for those still making use of old RedHat and Centos Linux distro. Unfortunately, this is not applicable in my system so I won’t be giving a practical screenshot on that.
Follow these simple steps to see through this. First, use any text editor of your choice to make entry to the file /etc/sysconfig/network
Find the part that says HOSTNAME= “.“ If located, replace the hostname there with the hostname of your choice and save by entering “:x” in the normal mode. When you are done, you need to add another record to the /etc/hosts file
You will see something that looks like this in the file
Just replace with the hostname of your choice as seen below
When you are done, you have to restart the networking service by entering the command below on the command line
HOW TO CONFIGURE NAME RESOLUTION
The stub resolver is responsible for converting hostnames to IP addresses and vice versa. The content of the /etc/hosts is checked first.
We will be making use of the static IPv4 address as 184.108.40.206 and domain name as redhat.learn.com. You can set a domain name of your choice.
Now let’s enter into our /etc/hosts file as seen below
Add the above IP address and the domain name and save as seen below
After adding, ping to see if everything is working fine
Everything looks good. Now the hostname has been resolved
I hope you learn something new on setting up a hostname and resolving the hostname to IP address and vice versa.
Please if you have any information to add or remove from the article feel free to leave a note on the comment section