0

I have set up a DNS service on a Debian 11 server (BIND 9.16.33-Debian) for my company's LAN with the following (forward) zone file (mycomp.com isn't the real name, of course):

# cat forward.mycomp.com.db
;
; BIND data file for local loopback interface
;
$TTL    604800
@       IN      SOA     ns1.mycomp.com. root.ns1.mycomp.com. (
                              2         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
;@      IN      NS      localhost.
;@      IN      A       127.0.0.1
;@      IN      AAAA    ::1

@ IN  NS  ns1.mycomp.com.
ns1 IN  A 192.168.50.9
www IN  A 77.66.11.123

bonsai  IN  A 192.168.50.149
...

All PCs point to the internal DNS:

# cat /etc/resolv.conf
# Generated by NetworkManager
search mycom.com
nameserver 192.168.50.9

The problem now is, that the company website is also called mycomp.com - I tried to include www in forward.mycomp.com.db, and it works, in the sense that it resolves to the right address, but www.mycomp.com is only an alias for mycomp.com, so I still can't reach the website from inside the LAN. I can see from my searches that I am sort of on the right track, but I think I need to point my browser to mycomp.com. However, including mycomp.com in the file above doesn't work, obviously; how do I fix this?

2
  • Is there a specific reason for using the same DNS name already used elsewhere? Commented Feb 1, 2023 at 10:08
  • @Peregrino69 Yes, lack of forward thinking, I assume. Regrettably, I now have to deal with it, and changing the names is not a popular option.
    – j4nd3r53n
    Commented Feb 1, 2023 at 10:34

2 Answers 2

2

Including "mycomp.com" in the file does work, but the syntax rules of zone files must be followed. The entry needs to be named either mycomp.com. (the trailing dot is important) or @ (like your SOA/NS records).

Just like your "www" entry automatically gets the zone name appended, the same happens to an entry named "mycomp.com" which is expanded to "mycomp.com.mycomp.com." in DNS:

www           A    77.66.11.123      ; becomes "www.mycomp.com."
sub.www       A    77.66.11.123      ; becomes "sub.www.mycomp.com."
mycomp.com    A    77.66.11.123      ; becomes "mycomp.com.mycomp.com."

To avoid this, the entry name must already have a trailing dot:

mycomp.com.   A    77.66.11.123      ; remains "mycomp.com."

You can also use the @ shortcut to specify the zone root – which your SOA and NS records already have (and in fact you even have a commented-out example of it being used for A/AAAA records):

@         NS   ns1.mycomp.com.
@         A    77.66.11.123

The same automatic suffix is also applied to values, so it would be enough to write NS ns1 – the server would automatically expand that to "ns1.mycomp.com." as well.

@         NS   ns1
ns1       A    192.168.50.9
2

After the SOA record, you should write something like this:

@      IN      NS      ns1.mycomp.com.       # the final dot is NOT optional here.
@      IN      A       77.66.11.123
@      IN      AAAA    <mycomp.com web server IPv6 address>
@      IN      MX      1 smtp.mycomp.com.    # incoming mail server. Final dot needed.
ns1    IN      A       192.168.50.9
ns1    IN      AAAA    <DNS server IPv6 address>

bonsai IN      A       192.168.50.149
www    IN      CNAME   mycomp.com.

@ at the left-most column refers to the "top of zone", i.e. mycomp.com.

Note the different record types: although a NS record of the mycomp.com top level needs to point to the DNS server, the A record for the same can point to the WWW server, and the MX record to the SMTP server. And since the NS record points to a name instead of an IP address, the nameserver doesn't have to have its own A record at the zone root.

The CNAME record defines www.mycomp.com as an alias of mycomp.com.

You must log in to answer this question.

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