Score:1

set domain to a ubuntu 20.04 vps with bind

us flag

so I have a ubuntu 20.04 vps and a website running on it, I wanted to point my domain to it. but nslookup railnet.ir gives ** server can't find railnet.ir: SERVFAIL
the vps ip is 87.236.210.159 and the domain is railnet.ir the thing I did:
apt install bind9 and then the configs: /etc/bind/named.conf.options:

options {
    directory "/var/cache/bind";
    allow-query { any; };
    forwarders {
        8.8.8.8;
        8.8.4.4;
    };
    dnssec-validation auto;
    listen-on{
        87.236.210.159;
    };
    listen-on-v6 { none;};
};

and /etc/bind/named.conf.local:

zone "railnet.ir" {
        type master;
        file "/etc/bind/db.railnet.ir";
        allow-transfer { 87.236.210.159; };
        also-notify { 87.236.210.159; };
};

and eventually /etc/bind/db.railnet.ir:

$TTL    604800
@       IN      SOA     ns1.railnet.ir. myemail.gmail.com. (
                              2         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      ns1.railnet.ir.
@       IN      A       87.236.210.159

and also in my domain provider website I did set server name to ns1.railnet.ir and ip address to 87.236.210.159

this is my first time doing such thing, so obviously I'm doing something wrong, but can't figure it out

vidarlo avatar
ar flag
As a sidenote: do use short TTL for all fields before you *know* your setup is working. I'd suggest 60 seconds for now, and extend it to an hour or a day once you know it works. 7 days is excessive in most cases; what if you're forced to change IP? That's up to seven days before everyone's onboard with your new IPs.
Parsa avatar
us flag
@vidarlo thanks! a question, you said it's better to host dns externally like cloudflare instead of hosting them yourself, does it really matter if i plan that like only 4~10 people are going to use my site? I mean in this case, does it have any real downside to host it myself?
vidarlo avatar
ar flag
The risk is basically downtime. I believe DNS is free with CF.
Score:1
ar flag

First of all, you have to define ns1.railnet.ir. in your zone. Add a line

ns1 IN A 87.236.210.159

Second, your DNS server does not reply. dig railnet.ir @87.236.210.159 does not return any answers. To figure out why, have a look at the logs provided by bind. Likely it can't open the zone file for some reason, or finds it invalid.

Third, your also-notify and allow-transfer points back to yourself based on what you write. Commonly these should point at your secondary DNS servers for that domain.

Start by making bind reply authoratively for all valid names, e.g.

  • dig railnet.ir SOA @87.236.210.159 should return ns1.railnet.ir
  • dig ns1.railnet.ir A @87.236.210.159 should return 87.236.210.159

When that's done, update whois, and hopefully glue records will be configured correctly.

In addition, you probably want to define some ACL's. As it is now, bind answers everything anyone bothers to ask. You probably want it to answer to zones it controls, and deny other queries.

In addition, DNS is one of those things that's a bit finicky to host yourself. Not impossible, but with only one domain you have to rely on glue records. Together with caching, this can lead to short downtime being cached. It's often a better approach to host DNS externally, with e.g. Cloudflare.

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.