Use same DNS name both as host name and subdomain

Can I configure a DNS zone such that both a.b.c and b.c can serve as host names? In other words, can b.c be both a subdomain and a hostname at the same time?

Is this perhaps just a matter of serving both A and NS (for delegation) records for b in c's zone?


Solution 1:

Yes you can! You also do somethhing similar when making example.com and www.example.com point to an A record. You will have to create the A record on the delegated zone though.

You can combine A and NS records but you can’t combine them with a CNAME record.

Note that the terms “hostname” and “subdomain” are kinda synonymous as you can createA records for www.test(.example.com.) and both wwe and test are considered a subdomain. You’re talking about a delegation of a zone here. And you can both delegate a zone and assign an A record to it (from the delegated zone, as its apex).

Solution 2:

If you only want to have records for b.c and a.b.c subdomains are not necessary. It's completely valid to have more sub-levels in one file, for example in zonefile for c you can have

b    IN     A    127.0.0.1
a.b  IN     A    127.0.0.2

If you really want a subdomain b.c first define delegation i c zonefile.

b    IN     NS   ns.with.b.c.zone

the ns.with.b.c.zone can point on the same server, or to hosting provider for example. Is good practice to have at least two DNS server for domain. RFC1912

next define A record for b.c in zonefile for b.c

@    IN     A    127.0.0.2

or

b.c. IN     A    127.0.0.2