Open In App

Setting up local DNS server between client-server machines

Improve
Improve
Like Article
Like
Save
Share
Report

In this, article you will see the overview of DNS server and how to set up the local DNS server between the client and server machines. And here we will use Wireshark. Let’s discuss it one by one. 

Introduction :
A DNS server is computer server that contains a database of public IP addresses and their associated hostname, and in most cases serves to resolve, or translate, those names to IP addresses as requested. DNS servers run special software and communicate with each other using special protocols.

To set up the DNS server we need two virtual machines, here, we will implement with the help of 2 Ubuntu virtual machines running on my laptop and I named the server virtual machine as Ubuntu and the client virtual machine as Ubuntu client. To understand how DNS server works we use Wireshark packet capture to see how the request is handled by the DNS server.

Step-1 :Installing Wireshark on Server virtual machine :

  • In this, you can use given below command to Install Wireshark with this command. After installing Wireshark we will start setting up the DNS server.
sudo apt-get install wireshark

Step-2 :Configuring client virtual machine :

  • We need to add the IP Address of the custom DNS server to the client machine. This is done by adding the IP address of the server to the file /etc/resolv.conf which stores the order of DNS server resolution. This ensures that the custom DNS server will be used to resolve names. To find the IP Address of the server virtual machine first go to server virtual machine and this command in the terminal
ifconfig
  • The value after the inet is IP Address in my case my IP address of the server machine is 10.0.2.15.

  • Now, go the client virtual machine and in the terminal run this command and enter user password to open that file.
sudo gedit /etc/resolv.conf
  • You will find the screen similar to this, Now add this line in the first line of the file and save it.
nameserver 10.0.2.15

Note – 
Change 10.0.2.15 to your server machine IP Address in my case my server IP Address is 10.0.2.15.

Step-3 :Configuring Server virtual machine :

  • To set up the DNS server we need a software called bind9, bind9 server is used as the DNS server on the server virtual machine. It can be installed using the below command.
sudo apt-get install bind9
  • After installing bind9 Let’s check the status of the bind9 server whether it’s running or not with this command.
sudo service bind9 status

  • If you see active (running) then we are good to go, If you see something else like failure or stopped or inactive type this command and restart your server virtual machine this will fix the issue.
sudo service bind9 restart
  • Now, we just finished setting up the local DNS server now we are going to see how it works.

Step-4 :Performing the packet capture with Wireshark :

  • Go to the server virtual machine and open terminal and type this command to open the Wireshark.

Note – 
Open Wireshark with admin privilege using sudo command as shown below this command.

sudo wireshark
  • After Wireshark gets opened double click on any or click on any and right click and click on start capture.

  • Now quickly go to Client virtual machine and open terminal and ping any website for example, ping www.flipkart.com 
ping www.flipkart.com
  • After 15 or 20 seconds press <CTRL> + C to stop the pinging the www.flipkart.com.

  • Now go to the server virtual machine and stop the capturing of the Wireshark by pressing the red button on top left side of the panel this will stop the capturing of the Wireshark.

  • Now, type DNS on apply display filter and press enter.

  • Now, Observe the first frame of the packet capture in Fig 7, source is IP address of the client virtual machine and the destination is the IP address of the server which implies that the client is sending request to the server virtual machine to get the results for the webpage www.flipkart.com
  • Now, observe the frame number 191, source is IP address of the server virtual machine and the destination is the IP address of the client virtual machine which implies that the server virtual machine sending the response to the client virtual machine.

Setting up a local DNS server between client-server machines involves the following steps:

  1. Choose a DNS server software: There are several DNS server software options available, including BIND, PowerDNS, and dnsmasq. Choose the one that best fits your needs and familiarity.
  2. Install the DNS server software: Install the DNS server software on a dedicated machine that will act as the DNS server.
  3. Configure the DNS server: Configure the DNS server by setting up zones, which are containers that hold information about domain names and their corresponding IP addresses.
  4. Assign IP addresses to the client and server machines: Assign static IP addresses to the client and server machines that will be using the DNS server.
  5. Set the DNS server as the primary DNS server for the client machines: On the client machines, set the IP address of the DNS server as the primary DNS server.
  6. Test the DNS server: Test the DNS server by trying to access the client and server machines using their hostnames instead of their IP addresses.

By following these steps, you can set up a local DNS server between client-server machines, allowing you to easily access resources by hostname instead of IP address.


Last Updated : 07 May, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads