Automatically add a NS record in the parent zone when a virtual server is created under it

Hi,

I’m trying to figure out if it is possible to configure Virtualmin to automatically add a NS record in the parent zone when a virtual server is created under it.

I have a virtual server for the domain mydomain.com which is managed on its own by ns1.mydomain.com and a few external slaves nameservers elsewhere.
Everything is fine, the registrar knows ns1.mydomain.com and I’m able to resolve mydomain.com and some hosts under the domain like www or xmpp or virtualmin.

If I create a new virtual server under mydomain.com, let’s say blog.mydomain.com, a new zone is created and is configured to be under the authority of ns1.mydomain.com and use it as the primary nameserver. That’s ok.

But blog.mydomain.com is unreachable because it is not referenced in the parent zone mydomain.com. There is no NS record for blog.mydomain.com. in mydomain.com zonefile, so I have to add it manually in order to resolve the blog subdomain.

Is there a way to add a reference of the subdomain in the parent domain zone on virtual server creation via configuration ?
I though of making a custom script to run after the virtual server creation but I’d prefer if there was a regular way of doing so.
I hope i’m quite understandable (English is not my native language).

Thanks.

This works for me. Are you first selecting the parent domain, then clicking Create new virtual server, then selecting sub-server? I also deselect Enabled features -> Setup DNS zone. Also, I’m fairly certain sub-servers use the Sub-servers template.

It does not work for me, neither with top-level server nor a sub-server. By the way, if I understand well, a subserver does NOT necessary mean “a server that manages (serves) a subdomain of its parent”. A subserver can manage a totally different domain than its parent. To be clear, subserver is NOT equal subdomain.
How can you not having to configure the DNS entries manually if you uncheck the option Setup DNS zone ?

I know that I can manually add a NS entry in the parent DNS zone to refer to the child zone, like blog IN NS ns1.mydomain.com. in the mydomain.com zonefile to refer to blog.mydomain.com zone and then no problem everything works (blog.mydomain.com is seen from the outside).
I just would like this behavior to be automatic (via configuration) when creating a server / subserver creation whose domain is located under an already existing zone managed by webmin.

‘How can you not having to configure the DNS entries manually if you uncheck the option Setup DNS zone ?’

Yes, my apologies. I was looking at my notes for sites with DNS hosted elsewhere.

‘It does not work for me, neither with top-level server nor a sub-server. By the way, if I understand well, a subserver does NOT necessary mean “a server that manages (serves) a subdomain of its parent”. A subserver can manage a totally different domain than its parent. To be clear, subserver is NOT equal subdomain.’

Yes, that’s right. The ability to do this is controlled in the Account Plan, I believe. However, if your sub-server is a subdomain of a different server, it will create an entirely new DNS zone file for the sub-server, rather than add entries to the parent zone. There might be situations where you might want this.

In any case, that’s not getting your DNS entries working. So, have you checked that Enabled features -> Setup DNS zone IS selected? :slight_smile: If you add a top-level server, is it creating a new zone that gets created on ns1.mydomain.com? Is ns1.mydomain.com the nameserver running on your Virtualmin server, or a slave from it (ie. is Virtualmin a stealth master)?

double post - sorry

Hi, thank you for your reply. I apologize if I sounded a bit harsh in my previous message.

I realized I made mistakes and I forgot some things about how DNS works.

The authoritative nameservers for mydomain.com are slaves of ns1.mydomain.com which is hidden : not mentioned at registrar level. ns1.mydomain.com is also the same machine that runs Virtualmin.
The slaves are hosted at, let’s say externaldns.com .
In this configuration, I must add a slave domain at externaldns.com for each new zone that comes with a new server or subserver in order for it to be accessible.
So I go to externaldns.com’s web interface and add a new slave zone for blog.example.com so that their nameservers know about the new zone.
In virtualmin, the zone is configured to allow-transfer to a few externaldns.com IPs. Everything works, domains that belong to mydomain.com are correctly resolved via externaldns.com.

At first I was confused and did not want to do that so I delegated the subdomain blog to the nameserver ns1.mydomain.com. That’s why I wanted to add automatically a NS record for the subdomain at parent domain level.
My config looked like this :

; mydomain.com.hosts $ttl 38400 @ IN SOA ns1.externaldns.com. contact\.mydomain@email.com. ( 2017092701 3600 3600 604800 38400 )

; nameservers for the zone
@ IN NS ns1.externaldns.com.
@ IN NS ns2.externaldns.com.
blog IN NS ns1 ; blog is delegated to ns1 (bad)

; mydomain.com master nameserver
ns1 IN A 178.x.y.z

; mydomain.com virtual server
@ IN A 178.x.y.z
www IN A 178.x.y.z
admin IN A 178.x.y.z
webmail IN A 178.x.y.z


Zonefile mydomain.com.hosts : not recommended ; blog.mydomain.com.hosts $ttl 38400 @ IN SOA ns1.mydomain.com. contact\.mydomain@email.com. ( 2017092701 3600 3600 604800 38400 )

; nameservers for the zone
@ IN NS ns1.mydomain.com. ; only one nameserver (bad)

; blog.mydomain.com virtual server
@ IN A 178.x.y.z
www IN A 178.x.y.z
admin IN A 178.x.y.z
webmail IN A 178.x.y.z


Zonefile blog.mydomain.com.hosts : not recommended

But I realized it was a bad idea for several reasons. First I only have one nameserver of my own which is ns1.mydomain.com : lack of redundancy. Second, this configuration is not ideal because parent & child listed nameservers do not match. Third : there is one more NS lookup to do in order to resolve hosts in blog.mydomain.com which is pointless.

So in my case it’s better not to use any sort of delegation.
Thank you for your replies though.

Regards

double post, sorry