Setting up local DNS server between client-server machines

05 Mar, 2021
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 <CRTL> + 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.
Technical Scripter 2020
Computer Networks
Computer Networks
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GSM in Wireless Communication
Secure Socket Layer (SSL)
Wireless Application Protocol
Mobile Internet Protocol (or Mobile IP)
Advanced Encryption Standard (AES)
Introduction of Mobile Ad hoc Network (MANET)
Intrusion Detection System (IDS)
Cryptography and its Types
Difference between URL and URI
Dynamic Host Configuration Protocol (DHCP)