Install DNS in raspberry pi

From UNamur InfoSec
Jump to navigation Jump to search

Local DNS Installation Procedure Using Raspberry Pi

Requirement and Devices

  1. Devices check-list
    • Two Raspberry Pi (server, client) + 16GB SD Card
    • Networking devices: switch, network Cable, Router , Keyboard and Mouse.
  2. Technology
  3. System Physical Architecture

Architecture

Installation Process

We assume that:

  • Both Raspberry Pi have been installed ubuntu server operating system
  • Our local network has been connected to internet and local network with LAN: 192.168.0.1/24 (gateway: 192.168.0.1)
DNS Server:
  • Hostname: server.inforsec.com
  • IP address: 192.168.0.2
DNS Client:
  • Hostname: client.infosec.com
  • IP address: 192.168.0.3
DNS Package Installation

we use bind9 package for our DNS server and dnsutils for troubleshooting tool

  • sudo apt install bind9 dnsutils
DNS File Configuration

After we installed the packaged in our DNS server, we will get the configuration folder in /etc/bind/

  • /etc/bind/named.conf.options: global DNS options
  • /etc/bind/named.conf.local: for your zones
  • /etc/bind/named.conf.default-zones: default zones such as localhost, its reverse, and the root hints

First of all we have to configure our zones so we have domain zone and IP zone (forward zone and reverse zone)

  • Sudo nano /etc/bind/named.conf.local

then we add the configuration of both zones into file

Note:for indenting we can’t use tab button, we have to use space button

Forward zone and Reverse zone:

zone "infosec.com" IN {

     type master;
     file "/etc/bind/db.infosec.com";

}; //db.infosec.com it is just the name so we can put anything we want

zone "0.168.192.in-addr.arpa" IN {

     type master;
     file "/etc/bind/db.192";

}; //the same case that db.192 it is just the name so we can but anything we want

Secondly, we have to configure file of each zones (forward and reverse zone) Forward zone: db.infosec.com

    The configuration template have been made similar to the db.local so we can copy that file to be our file (db.infosec.com) and db.192 is the same structure too.
  • Sudo cp /etc/bind/db.local /etc/bind/db.infosec.com
  • Sudo nano /etc/bind/db.infosec.com
BIND data file for local loopback interface
$TTL 604800
@ IN SOA server.infosec.com. root.server.infosec.com. (
                             2         ; Serial
                        604800         ; Refresh
                         86400         ; Retry
                       2419200         ; Expire
                        604800 )       ; Negative Cache TTL
@ IN NS server.infosec.com.
@ IN A 192.168.0.2
server IN A 192.168.0.2
host IN A 192.168.0.2
client IN A 192.168.0.3
client1 IN A 192.168.0.3
server and host is the name that we set for machine 192.168.0.2 (DNS Server)
client and client1 are the name that we set for machine 192.168.0.3
  • Sudo cp /etc/bind/db.infosec.com /etc/bind/db.192
  • Sudo nano /etc/bind/db.192
BIND data file for local loopback interface
$TTL 604800
@ IN SOA server.infosec.com. root.server.infosec.com. (
                             2               ; Serial
                        604800               ; Refresh
                         86400               ; Retry
                       2419200               ; Expire
                        604800 )             ; Negative Cache TTL
@ IN NS server.infosec.com.
@ IN PTR infosec.com
server IN A 192.168.0.2
host IN A 192.168.0.2
client IN A 192.168.0.3
client1 IN A 192.168.0.3
2 IN PTR server.infosec.com
3 IN PTR client.infosec.com