Score:0

Simple DNS server in a docker container returns server unknown

mv flag

its my first time posting here. I am trying to configure a DNS server with nginx so two docker containers. for some reason, when I do nslookup ns.main.com, it is returning server: unknown.

Here is my DNS file

$TTL 86400
@       IN      SOA ns.main.com. hostmaster.main.com. (
                    202      ; Serial
                    600      ; Refresh
                    3600     ; Retry
                    1209600  ; Expire
                    3600)    ; Negative Cache TTL

@       IN      NS      ns.main.com.
ns      IN      A       127.0.0.1

I am doing this locally so I am using the loopback address. when I do nslookup ns.main.com, i get this message:

Server:  UnKnown
Address:  fd28:8d22:2169:0:9221:6ff:feb3:1438

named.config file look like this:

options {
  directory "var/bind";
  allow-transfer { "none"; };
  allow-query { any; };
  listen-on { any; };
};

zone "main.com" IN {
    type master;
    file "/etc/bind/zone/main.com";
};

zone "secondary.com" IN {
    type master;
    file "/etc/bind/zone/secondary.com";
};

What could be wrong here?

This is the tutorial I am following.

https://www.youtube.com/watch?v=GlCloo47p_E&list=PLOLrQ9Pn6cawvMA5JjhzoQrnKbYGYQqx1&index=3&ab_channel=VeryAcademy
Score:0
pt flag

I am doing this locally so I am using the loopback address. when I do nslookup ns.main.com, i get this message...

What command are you running specifically? If you simply run nslookup ns.main.com, nslookup will look in /etc/resolv.conf to find a nameserver, which probably isn't what you want.

You can provide nslookup with an explicit server by passing it a second command line argument:

nslookup <name_to_lookup> <server_to_query>

There is one typo in your named.conf; you have:

  directory "var/bind";

When you probably mean:

  directory "/var/bind";

You will also need to ensure that directory exists.

If I deploy your named.conf with the above change and place your zone records in /etc/bind/zone/main.com, then nslookup seems to work correctly:

# nslookup ns.main.com localhost
Server:         localhost
Address:        ::1#53

Name:   ns.main.com
Address: 127.0.0.1

I've made a complete Dockerfile and associated files available here as a demonstration; if you build an image:

$ docker build -t named .

And then run it:

$ docker run --name named --rm -d named

You can verify that it works:

$ docker exec named nslookup ns.main.com localhost
Server:         localhost
Address:        ::1#53

Name:   ns.main.com
Address: 127.0.0.1
masafood avatar
mv flag
I will try this and get back to you, and thank you for having a look, i really wanted to get this working
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.