Using sub-subdomains with bind

4

1

Can you put multiple levels of sub-domains in the main zone with bind?

I have one zone called example.com and I want to create a sub-domain like host01.nyc.us.example.com. Can I make an entry like this in the example.com zone?

; A Records
host01.nyc.us.example.com.   IN   A   1.1.1.1

Or do I need to/or is it better to create another zone called nyc.us.example.com?

; NS Records
     IN   NS   ns1.example.com.
     IN   NS   ns2.example.com.

; A Records
host01   IN   A   1.1.1.1

user72718271

Posted 2016-01-05T01:20:55.250

Reputation: 141

Answers

2

You should get hold of a copy of "DNS and BIND in a Nutshell" and work with it as a way to understand how DNS works (as this is the second question you have asked - which is OK, you are learning we hope !)

You can put multiple subdomains in the main zone. There are, in fact at least 2 ways to accomplish this.

The simpler way would be this
; NS Records
     IN   NS   ns1.example.com.
     IN   NS   ns2.example.com.

; A Records
host01   IN   A   1.1.1.1
host01.nyc.us IN A  2.2.2.2

The more complex way would be to create a subdomain, with its own Zone records. You would probably not want to do this in the case you mentioned above, however it is useful if you want to send requests to different nameservers or put them under someone else's control - in fact, this is pretty much how things are done by the root nameservers to delegate your domain name !

To do this you need to create a zone with an NS record for the subdomain like

; NS Records
     IN   NS   ns1.example.com.
     IN   NS   ns2.example.com.

; A Records
host01   IN   A   1.1.1.1
us       IN  NS   ns.nameserver.com
us       IN  NS   ns2.nameserver.com

Then create a zone file for "us.example.com" where you could have nyc.us.example.com (and again delegate that to new nameservers) or have a record host01.nyc" (because it will be relative to us.example.com)

The key is that domain names are resolved from right to left, seperated by "." characters, so you can subdelegate quite a long way down.

davidgo

Posted 2016-01-05T01:20:55.250

Reputation: 49 152

Thanks for the recommendation. I will pick up the book! So if the same dns servers will be used, its best to keep it under one zone? If a different DNS server will handle a subdelegate zone, then obviously separate it? – user72718271 – 2016-01-05T06:30:02.163

Yup. A single zone file is probably easiest (and fastest) if you dont have special requirements. – davidgo – 2016-01-05T06:43:05.490