Add a name server for your lab

To add a caching DNS nameserver to your lab environment, you can follow the following procedure.
This will create: - A nameserver lxc container - A forwarding rule on the proxmox server to the nameserver - 3 dns zones - all zone files (forward and reverse)

Create the container

To host the nameserver we will need a lxc container with the following specs:

  • a container based on the CentOs stream lxc template
  • 128 MB memory
  • 128 MB swap
  • 4 GB disk space
  • 1 CPU core

Once the container is created, log in with the root account.

Install bind

dnf install -y bind
systemctl enable named

edit the file named.conf

Adjust the top section according to the following: Only the changes are listed below, lines that aren't changed are left out.
The forwarders and cache control lines are added. This keeps named from eating all memory and getting killed by the oom-killer..

options {
        listen-on port 53 { any; };
        forwarders      { 192.168.2.254; };
        max-cache-size  50m;
        cleaning-interval 2;
        max-cache-ttl 120;
        max-ncache-ttl 120;
        allow-query     { any; };

        dnssec-validation no;

At the bottom of the file, add the zones:
In the default file, you wil see a "hint" zone, replace that zone with the lines below, changing the domain names to your names.

zone "local" IN {
        type master;
        file "local.forward";
};

zone "10.1.1.in-addre.arpa" IN {
        type master;
        file "local.rev";
};

zone "localdomain" IN {
        type master;
        file "localdomain.forward";
};

zone "10.10.10.in-addre.arpa" IN {
        type master;
        file "localdomain.rev";
};


zone "homelab" IN {
        type master;
        file "homelab.forward";
};


zone "2.168.192.in-addr.arpa" IN {
        type master;
        file "homelab.rev";
};

Save the file..

Preparing the zone files

Change to the /var/named directory:

Touch the following files: - local.forward - local.rev

Add the following lines to the local.forward file:

$TTL 3600
@ SOA nameserver.local. root.local. (2025032402 15m 5m 30d 1h)
    NS nameserver.local.
    A 10.1.1.222

nameserver              IN      A       10.1.1.222

Add the following lines to the local.rev file

$TTL 86400
@ IN SOA nameserver.local. root.local. (
                                                2025032402 ;Serial
                                                3600 ;Refresh
                                                1800 ;Retry
                                                604800 ;Expire
                                                86400 ;Minimum TTL
)
; Nameserver information
@ IN NS nameserver.local.
nameserver      IN      A       10.1.1.222
;Reverse lookup for this nameserver
222     IN      PTR     nameserver.local.

Now initialize the other zone files, by copying the forward file to the new names.

cp local.forward localdomain.forward
cp local.forward homelab.forward
cp local.rev localdomain.rev
cp local.rev homelab.rev

Start your engines..

Mow start the nameserver

systemctl start named

It should start without any errors.

Add machines to the dns

By adding records to the zone files, you can add machine names that can be resolved by this nameserver. This nameserver will only work on the inside of your proxmox networks.

How to use the nameserver from the outside will be explained later.

Back

Backto Site