---
# System prepended metadata

title: 'SAE R3.06 Report : network architecture : DNS'

---

# SAE R3.06 Report : network architecture : DNS
#### Group : Maël Jansen / Yahn Bervas

1. [IP configiration for the machines](#IP-configuration-for-the-machines)
2. [Local naming configuration](#Local-naming-configuration)
3. [DNS configuration for the client machines](#DNS-configuration-for-the-client-machines)
4. [DNS servers configuration](#DNS-servers-configuration)
    4.1. [Primary server configuration](#Primary-server-configuration)
    4.2. [Secondary server configuration](#Secondary-server-configuration)
    4.3. [Etude of the LAN server](#Etude-of-the-LAN-server)
    4.4. [Principal domain configuration](#Principal-domain-configuration)
    4.5. [Reversed zone configuration](#Reversed-zone-configuration)
    4.6. [Sub domain configuration](#Sub-domain-configuration)
    
### IP configuration for the machines


To give an IP address with DHCP we need to edit the file : /etc/network/interfaces (on all machines) to add : 

    iface eth0 inet dhcp
        
After doing a ifup to start the interfaces your machine will have their address : 

dns2 => IP:192.168.0.2  
client1 => IP:192.168.0.10  
client2 => IP:192.168.0.20  
dns1 => IP:192.168.0.1 

You can test the communication between the machines  with the command : 
    
    ping <IP>

    
And check the routes with the command : 

    route

![](https://i.imgur.com/DLCR3n3.png)


### Local naming configuration

To localy associate a name with the IP you can write in the file : /etc/hosts (on dns1)

    <IP> <name>
You can find a screenshot of the file below : 
![](https://i.imgur.com/XsVwyO8.png)

Now you can communicate between dns1 and the others machine with their name : 
    
    ping <name>
    
### DNS configuration for the client machines

To configure the client machines you need to add a rule in the file : /etc/dhcp/dhclient.conf

For dns1 and dns2 you need to add : 
    
    supersede domain-name-servers 127.0.0.1
For client1 : 

    supersede domain-name-servers <IP dns1>
    
For client1 : 
    
    supersede domain-name-servers <IP dns2>
You can find an example screenshot for dns1 below : 
![](https://i.imgur.com/fS15SSu.png)

To relay the DNS request we need to edit the file : /etc/bind/named.conf.options (on dns1 and dns2)

    forwarders {
        172.16.0.3;
    }:
    
    alow-query {
        any;
    };
### DNS servers configuration

#### Primary server configuration

To configure a new primary DNS zone we need to define it in the file : /etc/bind/named.conf.local

    zone "netas" {
        type master;
        file "/etc/bind/db.netas";
    };

To fill our DNS zone we need to copy the file : /etc/bind/dd.empty in the file that will just define : 

    cp /etc/bind/db.empty /etc/bind/db.netas
    
Now we can update the zone file : (/etc/bind/db.netas)

    @ IN SOA dns1.netas. contact.netas. (
    1    ;
    604800
    86400
    2419200
    86400 )

You need to add a new NS input that will be indicate the name of the principal DNS server (in the zone file too) : 

    @ IN NS dns1
    
You need to add an input A to specify the IP for dns1 : 

    dns1 IN A <IP dns1>
    
You can find an screeshot of the result below : 
![](https://i.imgur.com/KQ88xkA.png)

Now you can restart dns1 with the command : 

    systemctl restart named
    
__You need to increment the serial number after each modification of the db.netas file__

You can also do : 

    systemctl reload named
to reaload the configurations files without restart your dns1

If you want to check the status of your server you can do : 

    systemctl status named

The logs are stored in the file : /var/log/syslog
You can also see the complete log with : 

    journalctl --unit named

To test your configuration you can do a ping between client1 and dns1.netas

    ping dns1.netas
    
Now you need to add an input A for dns2 just like hte one for dns1 (in the file : /etc/bind/db.netas on dns1)

Add to CNAME input to name the "dns-primaire" and "dns-secondaire" alias to the dns1 and dns2 servers (in the file : /etc/bind/db.netas on dns1)
    
    dns-primaire  IN  CNAME  dns1
    dns-secondaire  IN  CNAME  dns2
    
You can use the ping command between the client1 machine and "dns1.netas", "dns2.netas", "dns-primaire.netas" and "dns-secondaire.netas" as you can see below

Ping between client1 and dns1.netas
![](https://i.imgur.com/oc1laxy.png)

Ping between client1 and dns-primaire.netas
![](https://i.imgur.com/Mrk3JPQ.png)

#### Secondary server configuration

In the configuration zone of dns1 you have to put a new input to identify dns2 as a server : (in the file : /etc/bind/db.netas on dns1) 

    @  IN  NS  dns2
    
On dns2 you need to declare the netas zone as secondary of the dns1 server (on the file : /etc/bind/named.conf.local)

    zone "netas" {
        type slave;
        file "/var/lib/bind/db.netas";
        masters { <IP du serveur dns1>; };
    };
    
After restarting the dns1 and dns2 servers you can make a ping between client2 and the machines in the netas zone to verify if they can communicate : 

    example : ping dns1.netas
    
On the client machines you have to use the host command to check if the two server are in the nets zone : 

    host dns-primaire <IP de dns1>
    host dns-primaire <IP de dns2>
    host dns-secondaire <IP de dns1>
    host dns-secondaire <IP de dns2>
    
You can find screenshots of the command performed on client1 below : 
![](https://i.imgur.com/3I7imFd.png)

![](https://i.imgur.com/Yq4jvJ9.png)

#### Etude of the LAN server

There is 22 fix bytes on the IP address because we have /22 on the mask.

You can scan the LAN server to collect IP address which composed the sub-net with the commmand : 

    map -T5 -sP 10.0.0.0/22
    
![](https://i.imgur.com/KTi6lBw.png)

Now you have to connect in ssh with each collected IP to set up the connection between all of the machine which composed the LAN server

    ssh <username>@<IP machine>
    
    username : tc
    password : plop
    
#### Principal domain configuration

You have to add a new input A for each web server (s1, s2, s3) in the file : /etc/bind/db.netas
    
    @  IN  NS  s1
    @  IN  NS  s2
    @  IN  NS  s3
    
    s1  IN  A  10.0.2.1
    s2  IN  A  10.0.2.2
    s3  IN  A  10.0.2.3
    
You can add an CNAME input for each web server : 

    creative  IN  CNAME  s1
    grayscale  IN  CNAME  s2
    wonder  IN  CNAME  s3
    
You can use ping or host commands if you want to test your alias a on the client1 and client2 machines.

Now you have to switch on graphic mod on the client1 machine.
Open your browser and test the enregistred site : 
    
    creative.netas
    grayscale.netas
    wonder.netas
    
You can find a screeshot of one of the sites below : 

![](https://i.imgur.com/TvtkHzK.png)

You can try it on client2 too.

#### Reversed zone configuration

You need to declare the reversed in the file : /etc/bind/named.conf.local (on dns1) : 

    zone "2.0.10.in-addr.arpa" {
      type master;
      file "/etc/bind/db.netas-rev";
    };
    
And in the file : /etc/bind/db.netas-rev : 

    @  IN  SOA  dns1.netas.  contact.netas (
    1
    604800
    86400
    2419200
    86400 )
    
    @  IN  NS  dns1.netas.
    @  IN  NS  dns2.netas.
    1  IN  PTR  s1.netas.
    2  IN  PTR  s2.netas.
    3  IN  PTR  s3.netas.
    
You can use ping and host commands to check your new configuration.

You have to declare dns2 to make it a second server for the reversed netas zone. You can check it with a ping and host too (on client2 this time).

#### Sub-domain configuration

You need to add a new NS input in the main netas zone : (in the file : /etc/bind/db.netas)

    perf  IN  NS  dns1
    
You have to declare this new sub-domain in the file : /etc/bind/named.conf.local : 

    zone "perf.netas" {
      type master;
      file "/etc/bind/db.perf.netas";
    };
    
Create the associate file : 

    @  IN  SOA  dns1.perf.netas; contact.netas. (
    1
    604800
    86400
    2419200
    86400 )
    @  IN  NS  dns1
    dns1  IN  A  <IP de dns1>
    
Complete the file to include the A inputs which pointing on p1 and p2.

Verify your configuration by using ping and host on client1.


