How to add domain account when sub domain already exists?

jasgot

Well-Known Member
Mar 2, 2004
70
3
158
We have a customer whos DNS and website are hosted elsewhere. As part of a database project, I created a new account on my WHM/cPanel server called database.customerdomain.com

Fast forward three years.

They now want us to host the records for their DNS zone.

Can I just add customerdomain.com as a new account on my WHM/cPanel server? or will it get confused? I only need it to be able to host their zone records, not web hosting or e-mail.

Or, can the database.customerdomain.com account handle the customerdomain.com dns records (up one level)?

If I need to explain better, please ask.
 

andrew.n

Well-Known Member
Jun 9, 2020
328
71
28
EU
cPanel Access Level
Root Administrator
You can create a new account with the domain name however adding it as add-on domain under their current account will cause conflict and cPanel won't allow this. The new account with the domain will work just fine.
 

jasgot

Well-Known Member
Mar 2, 2004
70
3
158
You can create a new account with the domain name however adding it as add-on domain under their current account will cause conflict and cPanel won't allow this. The new account with the domain will work just fine.
You're certain adding a new account with the same domain as an existing subdomain account will not present a problem?
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,252
313
Houston
Yep you should be able to add the root domain as its own account without the conflict as long as the root domain isn't listed in any of the existing account's information (just as domain.tld not sub.domain.tld)
 

Michael-Inet

Well-Known Member
Feb 20, 2014
117
15
68
Nashville, TN, USA
cPanel Access Level
Root Administrator
They now want us to host the records for their DNS zone.
Edit: If you’re using BIND.

Alternately, since domain and subdomain zone files are separate files, you can just grab a copy and add the domain file to:

Code:
/var/named
And then restart your DNS Server:

Code:
WHM »Restart Services »DNS Server
Best,
Michael

PS: This is also how you make a DNSONLY a master DNS controller.
 

jasgot

Well-Known Member
Mar 2, 2004
70
3
158
Edit: If you’re using BIND.

Alternately, since domain and subdomain zone files are separate files, you can just grab a copy and add the domain file to:

Code:
/var/named
And then restart your DNS Server:

Code:
WHM »Restart Services »DNS Server
Best,
Michael

PS: This is also how you make a DNSONLY a master DNS controller.

That's more like what I was hoping for! So you can drop any 'ol BIND zone file in /var/named and it will use it?

I've already created the new user account and entered all the zone records.

If I have a copy of the zone db file, can I delete the account I just created and then drop the saved zone .db file back into the /var/named folder?
 

Michael-Inet

Well-Known Member
Feb 20, 2014
117
15
68
Nashville, TN, USA
cPanel Access Level
Root Administrator
That's more like what I was hoping for! So you can drop any 'ol BIND zone file in /var/named and it will use it?

I've already created the new user account and entered all the zone records.

If I have a copy of the zone db file, can I delete the account I just created and then drop the saved zone .db file back into the /var/named folder?
I've never done it that way (e.g. created an account to create the zone record), I've always copied the .db from another machine (or created it from scratch if I had to < which is a pita btw...).

Given that, I do not see why it would not work. Here's a dig command to use to verify it worked okay:

Code:
dig @ns1.your-nameserver.com your-users-domain.com
Just to be really sure, I'd do a dig against the current NS first (so I had a reference). I'm pretty sure dig has a 'everything' flag, google that if you're really paranoid ;)

Best,
Michael
 

jasgot

Well-Known Member
Mar 2, 2004
70
3
158
I've never done it that way (e.g. created an account to create the zone record), I've always copied the .db from another machine (or created it from scratch if I had to < which is a pita btw...).

Given that, I do not see why it would not work. Here's a dig command to use to verify it worked okay:

Code:
dig @ns1.your-nameserver.com your-users-domain.com
Just to be really sure, I'd do a dig against the current NS first (so I had a reference). I'm pretty sure dig has a 'everything' flag, google that if you're really paranoid ;)

Best,
Michael
I had already made the new account before I saw your post. I didn't make it to get the zone record, although it was an easy way to do it! :)

I suppose I'll also have to ad the zone back into /etc/named.conf?

Then restart Bind?
 

jasgot

Well-Known Member
Mar 2, 2004
70
3
158
Would running this ever cause a problem if there is not an account?

Home »DNS Functions »Perform a DNS Cleanup
 

Michael-Inet

Well-Known Member
Feb 20, 2014
117
15
68
Nashville, TN, USA
cPanel Access Level
Root Administrator
jasgot said:
I suppose I'll also have to ad the zone back into /etc/named.conf?
S'Okay, that's what I get from replying by memory :(

Here's my instructions to myself (I don't do this often):

Code:
DNS Zone file locations
/var/named # Directory containing zone files
/etc/named.conf # Configuration file of Nameservice

DNSONLY
Edit the zone from command line and use /scripts/dnscluster to sync it
I need to leave myself better notes, but, I believe the answer is 'yes.'

Would running this ever cause a problem if there is not an account?

Home »DNS Functions »Perform a DNS Cleanup
LOL, I've never been brave enough to try that!

Do me a favor?

When you get it setup and working (save .db, delete account, copy .db back to /var/named), would you run that to see if it wipes the copied .db?

Thanks,
Michael
 

jasgot

Well-Known Member
Mar 2, 2004
70
3
158
Do me a favor?

When you get it setup and working (save .db, delete account, copy .db back to /var/named), would you run that to see if it wipes the copied .db?

Thanks,
Michael
Terminated account in cPanel
copied customerdomain.db back to /var/named
added customerdomain info back to /etc/named.conf
restarted bind
Ran dig to confirm all was ok. It was.
Ran Home »DNS Functions »Perform a DNS Cleanup from WHM.
Restarted Bind
Ran dig to confirm all was ok. It was.

So, it did not remove the zone that did not have an account.
 
  • Like
Reactions: Michael-Inet

ffeingol

Well-Known Member
PartnerNOC
Nov 9, 2001
436
104
343
cPanel Access Level
DataCenter Provider
Out of curiosity, why are you mucking with the bind zone files? We have a number of customers with two accounts:

example.tld
stage.example.tld

Two zone files are created. The 'stage' site is not listed in the 'main' zone file. Bind seems to accept this just fine. We have not tested with PDNS as we have not converted yet.
 

Michael-Inet

Well-Known Member
Feb 20, 2014
117
15
68
Nashville, TN, USA
cPanel Access Level
Root Administrator
Out of curiosity, why are you mucking with the bind zone files?
I run a DNS cluster for my clients. The easiest way is to have your DNSONLY servers completely separate from your webhosting servers. That way development activities and site moves don’t whack your DNS settings. DNSONLY servers don’t have a UI for editing DNS, so in my setup you need to do them from the command line. We probably won’t switch to PDNS.

We have a number of customers with two accounts:

example.tld
stage.example.tld

Two zone files are created. The 'stage' site is not listed in the 'main' zone file. Bind seems to accept this just fine. We have not tested with PDNS as we have not converted yet.
That's basically how I’ve always seen them, e.g. having both zones identified like that. (Somebody with more experience with DNS might correct this, but I think the only way you have stage. in example.com is if stage. is only a single IP reference. Anything else and then stage. needs it’s own zone descriptor.)
 

jasgot

Well-Known Member
Mar 2, 2004
70
3
158
Out of curiosity, why are you mucking with the bind zone files? We have a number of customers with two accounts:

example.tld
stage.example.tld

Two zone files are created. The 'stage' site is not listed in the 'main' zone file. Bind seems to accept this just fine. We have not tested with PDNS as we have not converted yet.
I went down that road because I had the stage.example.tld (to use your example) created long before we needed example.tld. I did not know how WHM/cPanel/Bind would react if I added a new account with example.tld, AFTER I had stage.example.tld

I felt certain cPanel would be unhappy if the domain and the sub-domain were separate accounts. I new Bind would be fine, but sometimes WHM/cPanel think they are smarter than the admin and they do things different than we would expect. The test I ran as requested by @Michael-Inet demonstrated that WHM/cPanel would not destroy any settings that were known only to BIND.
 

Michael-Inet

Well-Known Member
Feb 20, 2014
117
15
68
Nashville, TN, USA
cPanel Access Level
Root Administrator
we just use the DNS edit functions in WHM to do any editing as all our servers are jointed to the cluster.
I have no full install WHM servers jointed to my DNS cluster. Intentionally.

At least half my clients purchase FailOver backup capabilities (think server hot swap?). This scatters the same zone files across multiple full install WHM servers. Those servers can’t provide DNS, as at least half of them have the wrong DNS info at any given time.

I could purchase a single, not used for anything else, full install WHM to use it’s GUI, but a) why would I want to pay $180+taxes per year just for a GUI when, b) the command line is actually significantly faster.

Just a different architectural setup…

Best,
Michael