-1

I am having problem with DNS configuration in Linux. I am using isc-dhcp-server as DHCP server and bind9 as DNS server, but I it returning me errors.

This is my Setup

Internet <--enp0s3 interface-->router<--enp0s8 interface-->Ubuntu server

The router serves both as DHCP and DNS server and the Ubuntu server is for internal uses. The enp0s3 interface has access to the internet and the enp0s8 is for internal network.

The enp0s8 interface on the router has the address of 192.168.1.1 and the Ubuntu Server has an address of 192.168.1.2. The DHCP server works, the machines can ping each other.

The problem comes from the DNS server, I gave the Ubuntu server the name server and when I run this command ping server it returns me this error:

   $ ping server
   ping: server: Temporary failure in name resolution

When I check the bind9.service status it gives me this:

$ sudo systemctl status bind9.service
● named.service - BIND Domain Name Server
     Loaded: loaded (/lib/systemd/system/named.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2024-02-20 11:10:08 UTC; 6min ago
       Docs: man:named(8)
    Process: 2759 ExecStart=/usr/sbin/named $OPTIONS (code=exited, status=0/SUCCESS)
   Main PID: 2760 (named)
      Tasks: 5 (limit: 2221)
     Memory: 5.6M
        CPU: 141ms
     CGroup: /system.slice/named.service
             └─2760 /usr/sbin/named -u bind

Feb 20 11:10:08 fox-router named[2760]: network unreachable resolving './NS/IN': 2001:500:a8::e#53
Feb 20 11:10:08 fox-router named[2760]: network unreachable resolving './NS/IN': 2001:500:12::d0d#53
Feb 20 11:10:08 fox-router named[2760]: network unreachable resolving './NS/IN': 2001:500:9f::42#53
Feb 20 11:10:08 fox-router named[2760]: network unreachable resolving './NS/IN': 2801:1b8:10::b#53
Feb 20 11:10:08 fox-router named[2760]: network unreachable resolving './NS/IN': 2001:500:2f::f#53
Feb 20 11:10:08 fox-router named[2760]: network unreachable resolving './NS/IN': 2001:500:2::c#53
Feb 20 11:10:08 fox-router named[2760]: network unreachable resolving './NS/IN': 2001:7fe::53#53
Feb 20 11:10:08 fox-router named[2760]: network unreachable resolving './NS/IN': 2001:503:ba3e::2:30#53
Feb 20 11:10:08 fox-router named[2760]: managed-keys-zone: Key 20326 for zone . is now trusted (acceptance timer complete)
Feb 20 11:10:08 fox-router named[2760]: resolver priming query complete: success
These are the commands that I had run when configuring the DHCP server:

Router

Ubuntu Server as Router

Assign IP address to interface

sudo vim /etc/netplan/00-installey-config.yaml
__________________________________

network:
    ethernets:
        enp0s3:
            dhcp4: true
        enp0s8:
            dhcpd4: true
            addresses: [192.168.1.1/24]
    version: 2
__________________________________

sudo netplan apply

DHCP server

sudo apt install isc-dhcp-server
sudo vim /etc/dhcp/dhcpd.conf
__________________________________

default-lease-time 600;
max-lease-time 7200;
ddns-update-style none;

subnet 192.168.1.0 netmask 255.255.255.0{
    range 192.168.1.2 192.168.1.10;
    option routers 192.168.1.1;
    option domain-name-servers 8.8.8.8, 8.8.4.4;
}

host Server{
    hardware ethernet: <MAC address>
    fixed-address: <IP Address>
}

Assign interface for DHCP service

sudo vim /etc/default/isc-dhcp-server
__________________________________

INTERFACESv4="enp0s8"

Restart/start DHCP server

sudo systemctl start isc-dhcp-server //START SERVICE 
sudo systemctl status isc-dhcp-server //CHECK STATUS
sudo systemctl restart isc-dhcp-server //RESTART SERVICE

And these are the commands I had run for the DNS server:

$ sudo apt-get install bind9

Edited the /etc/bind/named.conf.options file.

forwarders {
    8.8.8.8;
    8.8.4.4;
};

Configure the zones in the /etc/bind/named.conf.local

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

zone "0.168.192.in-addr.arpa" {
        type master;
        file "/etc/bind/db.168";
};

And created the zones: /etc/bind/db.foxnetwork.net

;
; BIND data file for local loopback interface
;
$TTL    604800
@       IN      SOA     ns.foxnetwork.net. root.localhost. (
                              2         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      ns.foxnetwork.net.
foxnetwork.net. IN      MX      10      mail.foxnetwork.net.
ns      IN      A       192.168.1.1
web     IN      A       192.168.1.2

; The reverse zone


;
; BIND reverse data file for local loopback interface
;
$TTL    604800
@       IN      SOA     ns.foxnetwork.net root.localhost. (
                              1         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      ns.
1       IN      PTR     ns.foxnetwork.net.
2       IN      PTR     web.foxnetwork.net.

I had then restarted the bind9 and DHCP servers. But I still can't ping the router with ping ns and the server with ping server

3
  • 4
    You tell your LAN clients to use 8.8.8.8 and 8.8.4.4 as DNS servers via DHCP.
    – AlexD
    Commented Feb 20 at 15:57
  • to be exact, your problem starts option domain-name-servers 8.8.8.8, 8.8.4.4 Here already and second, why use forward in bind9 instead using the bind instance to resolve it? that's a home and end-user setup that you show us
    – djdomi
    Commented Feb 20 at 18:41
  • To do a preliminary check whether or not your name server actually works, try a nslookup server 192.168.1.1. This bypasses /etc/resolv.conf and takes the address that you have provided as the address of the DNS server to be queried.
    – Robidu
    Commented Feb 21 at 0:54

1 Answer 1

2

What your DHCP server is handing out is the addresses of two publicly available DNS servers (possibly from Google?) and not your own DNS server. Since that one cannot be reached by ordinary means (check etc/resolv.conf on your Ubuntu server to see what's in there), you cannot reach anything that is registered in your private DNS server.

Given what you are intending to do /etc/resolv.conf on your Ubuntu server has to contain a line like this:
nameserver 192.168.1.1, however, it will contain something entirely different, namely nameserver 8.8.8.8 8.8.4.4 (that is, the servers that your DHCP server is handing out).

Your DHCP server configuration has to look like this for your DNS server to be able to be reached:

default-lease-time 600;
max-lease-time 7200;
ddns-update-style none;

subnet 192.168.1.0 netmask 255.255.255.0{
    range 192.168.1.2 192.168.1.10;
    option routers 192.168.1.1;
    option domain-name-servers 192.168.1.1;
}

host Server{
    hardware ethernet: <MAC address>
    fixed-address: <IP Address>
}

Then restart the DHCP server and do an ifdown <interface> ; ifup <interface> on your server (or whatever is relevant for your machine) and check /etc/resolv.conf on your Ubuntu server again.
The relevant line should now read nameserver 192.168.1.1, and a nslookup server should now resolve the name.

As a side note: DHCP should be used only for clients without a fixed address connecting to your network. If there are machines that get a fixed address, your are best advised to assign those addresses on the machines themselves (select addresses that aren't residing inside the pool of DHCP-assignable addresses) and then update the configuration of your DNS server where necessary.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .