Installing and Configuring DNS Server on Debian 7.8 Linux Server

in #steemiteducation7 years ago

Hi ...
Before starting to configure Debian Linux, I hope you have the basic knowledge for CLI (Command Line Interfaces) commands. In this post I'm not talking about basic commands, either for Windows or Linux commands. You can find and learn basic commands for Windows or Linux in the Internet, there is too many websites will gives you knowledge to learning Computer basic commands. Commands used by Windows and Linux has a lot of differences as well as similarities.
I will try to explain every commands that I use by linking to other websites.

Please read my previous post about [Installing Linux Debian 7.8 as Server] if you not installed yet.

In my previous post, I am using Virtual Box as Virtual Engine, but now I have to change to Virtual Machine, because VBox on my Computer has some failed registry. Both of it is same as virtual PC. only has a slight difference in settings

SO, WHAT IS DNS SERVER???

Definition of Domain name system:

  1. DNS is a distributed database system that is used to search for computer names on a network that uses TCP / IP. DNS has an unlimited database size overload and also has good performance.
  2. It is a service application on the internet to translate domain name to IP address and IP address to Domain.
  3. It is a connected Computer and has the responsibility of providing your domain name information domain, changing the domain name to IP address and also has responsibility for email distribution on mail server that concerns with domain name.
  4. Applications that mapping host names of a computer to IP addresses in applications connected to the Internet such as web browsers or e-mail.

If you have installed and understood about DNS and Web Server, lets start to configure.
Before configure DNS and Web Server, make sure you have installed Debian Linux Server (I am using Debian 7.8 in this configuration).

Scanning Repository

For the first steps, let scan all discs of Debian 7.8 to list all of available repositories. The 1st disk didn't need to scan anymore, it has been listed when installing Debian Operating System.

  • Write : eject
  • Mount disc 2
  • Write : apt-cdrom add (read about command)
    Server-2017-09-30-11-27-59.png
  • Repeat the commands for disk 3
    Server-2017-09-30-11-29-46.png

    DNS Server Installation and Configuration

    1. Install bind9 application for DNS server,
      the command is apt-get install bind9
      Server-2017-09-30-11-30-47.png

      2. Confirm your answer : "y" then press enter
      Server-2017-09-30-11-30-54.png

      3. It will request for disk 1, because bind9 is placed in disk 1 of Debian 7.8.
      Mount disk 1 (iso file) and then press enter
      Server-2017-09-30-11-31-06.png

      4. Installation progress may take a few seconds. The completed installation will display a green [ OK ] Starting domain name service... : bind9
      Server-2017-09-30-11-31-19.png

      5. If we have completed the DNS installation without any trouble, now we can configure it.
      -- cd /etc/bind -> change directory to /etc/bind
      -- ls -> show files or folders in current directory
      -- There is 2 files we need to copy before configure, db.local and db.127.
      -- cp db.local db.web -> copy file db.local and paste in same directory with name db.web
      -- cp db.127 db.ip -> copy file db.127 and paste in same directory with name db.ip
      Server-2017-09-30-11-33-12.png

      6. #nano named.conf.local -> nano is text editor to open file named.conf.local [read more about nano functions]
      Read about named.conf function and how it works.
      Server-2017-09-30-11-36-30.png
      Save your work on nano editor by pressing [CTRl + O] then enter
      Exit nano editor by pressing [CTRL + X]

      7. Now edit the copied file, db.web
      nano db.web
      Replace all localhost texts to our domain name server-01.com, its depend to you, what name you will create.
      Server-2017-09-30-11-38-01.png!

      8. For fast and save writing use nano search and replace functions.
      [CTRL + W] to search and combine it with [CTRL + R] to replace, then type "localhost" (search text) - press enter
      Server-2017-09-30-11-39-31.png
      Type "server-01.com" (replace text) - press enter
      Server-2017-09-30-11-39-41.png
      Then press "A" (it will replace all matched text)
      Server-2017-09-30-11-39-50.png
      After complete replace localhost -> server-01.com, we can add more sub-domain. Just what ever sub-domain you need.
      Save and Exit (see instruction step number 7)
      Server-2017-09-30-11-58-44.png

      9. Edit db.ip file
      nano db.ip
      Then repeat search and replace like step before (step number 8).
      Server-2017-09-30-11-59-15.png
      Add sub-domain like what you added in db.web, please see the writing mode.
      Save and Exit
      Server-2017-09-30-12-00-40.png

      10. Add DNS server to resolv.conf file. -> Read more about resolv.conf .
      Note : If your created server will connected to the internet you have to addpublic DNS here, it can be much IP, just add like Google DNS (8.8.8.8), Open DNS (208.67.222.222 and 208.67.220.220), or other DNS.
      Server-2017-09-30-12-01-23.png

      11. Finally, restart service of bind9.
      service bind9 restart.
      Restart result should not error or failed.
      If you got Error or Failed, you need to check for configuration step number 1 ~ 10.
      Server-2017-09-30-12-01-46.png

      12. Now, let's do a test of the DNS that we have configured.
      First test -->> nslookup server-01.com
      Second test-->> nslookup 220.20.10.1
      The DNS test results are as in the following picture.
      Server-2017-10-05-06-23-35.png

      Configuring and connecting client to Server.

      I am using Windows 10 as my Computer operating system, and VMWare as virtual PC application. My computer will connected as client.

      1. Setting Virtual server for LAN Connection, right click on LAN icon VMware,
        2017-10-06_082753.png
        Select device Network and change connection to Host only, its mean the virtual PC will communicating with Windows System.
        2017-10-06_082849.png

        2. On Windows Computer, Open Network and Sharing Center
        2017-10-05_062917.jpg
        On the left sides, click Change adapter settings
        2017-10-05_062955.jpg

        3. Select and right-click on VMWare Network adapter NMNet1 not VMWare Network adapter NMNet8
        VMWare Network adapter NMNet1 is adapter connected to the hosts,
        VMWare Network adapter NMNet8is adapter connected the NAT (Network Address Translation).
        2017-10-05_063343.jpg

        4. Double cliks on selected IPV4 or click Properties.
        2017-10-05_063419.jpg

        5. Set IP address for client,
        Client IP address must be in same subnet with Server IP address and including Netmask.
        Gateway is Server IP address.
        DNS is Server IP address -->>This is important, wrong DNS will cause client error to communicating with Domain
        2017-10-05_063518.jpg
        If anything fill in good, click OK to save your change.

        6. Open Command promt by press [WINDOWS + R] then type "cmd" then hit enter.
        2017-10-05_063550.jpg

        7. Ping testing.
        First ping to IP 220.20.100.1 -> ping 220.20.10.1
        2017-10-05_063752.jpg
        Reply successful
        Second ping to domain name -> ping server-01.com
        2017-10-05_063815.jpg
        Reply successful
        Its mean your host has been connected to server.

        8. DNS lookup
        First test lookup for domain name --> nslookup server-01.com
        2017-10-05_063833.jpg
        Second test lookup for DNS of IP --> nslookup 220.20.10.1
        2017-10-05_063843.jpg
        Its mean translation of IP and domain name is running good.

        Troubleshoot

        1. If restart of bind9 (for DNS service) is failed, you need to check all configuration of IP address on server and DNS Server. Check it out in writing!
        2. If restart going success but nslookup test is failed, there is two possible;
          First, if nslookup to IP is failed, check db.ip and named.conf.local files, pay your attention to check out writing.
          Second, if nslookup to domain is failed, check db.web and named.conf.local files, pay your attention to check out writing.
        3. On client, make sure you have to disconnect all other network adapter, like Wi-fi adapter, LAN adapter or anything connected adapter.

        This tutorial is used to teach my students Networking support to install Linux Debian as server.

        Wait for next post there is too many science of network and computer I want to share.

        Best regards @azizali