• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Add pop.<domain> to dns for all domains?

I

inCharge.co.uk

Guest
Is there a way to add a given subdomain to the DNS configuration of all domains on a server?

e.g. Add...

pop.<domain>. CNAME mail.<domain>.

...to all domains.

It's no good adding it to the zone files manually because Plesk overwrites them when changes are made.

Adding a new subdomain to the default DNS template doesn't affect existing domains.

The reason I need to do this is that I was using another DNS server that had a pop subdomain by default. Now I need to switch to using the Plesk DNS service but adding pop+pop3+smtp etc subdomains manually for every domain will be a nightmare.

Cheers
Julian
 
Looks like there is no global DNS setup (pop.* CNAME mail.*) so a subdomain needs to be added for each domain.

Looks like a subdomain can't be added for all domains using the control panel or command-line utilities.

So the only solution left is to insert data directly to the dns_recs table in the psa database. Then run
dnsmng.exe update domain.com
for each domain to recreate the zone files.
 
OK, here we are. This is tried and tested on Windows Plesk 7.02 but will probably also work on linux.

Please don't attempt this unless you're familiar with MySql or prepared to lean, and you are able to repair it if it all goes wrong. If you are the lucky owner of pop.com then be extra careful!

This adds a 'pop.' subdomain referencing the 'mail.' subdomain for all domains. Change the 'pop', 'CNAME' and 'mail.' clauses in the insert query to add a different type of record.

Start a DOS command/shell prompt

Backup the dns_recs table:
"C:\Program Files\SWsoft\Plesk\MySQL\bin\mysqldump.exe" -uadmin -p -P8306 psa dns_recs > dns_recs.txt

Run the following queries from the MySql command line or mysqladmin:

-- Delete existing pop. records
delete from dns_recs
where host like 'pop.%'

-- Add a pop record for every domain
insert into dns_recs (dom_id, type, host, val)
SELECT d.id as dom_id
,'CNAME' as type
,concat('pop.', name,'.') as host
,concat('mail.', name,'.') as val
FROM `domains` d

-- Check that it worked
SELECT d.name, s.*
FROM domains d
left outer join dns_recs s on d.id=s.dom_id
WHERE s.host like 'pop.%'

-- Get the update script
select concat('dnsmng.exe update ', name) from domains

The last query creates a DOS batch/shell script that makes Plesk rebuild the zone files from the database entries for each domain. Redirect/paste this into a .bat file and run it to finish the job.

Use nslookup to check that the new DNS records are appearing:
C:\>nslookup
Default Server: cache2.ntli.net
Address: 194.168.8.100
> server ns1.server.com
Default Server: ns1.server.com
Address: 69.12.34.567
> set type=all
> pop.domain.com
Server: cache2.ntli.net
Address: 194.168.8.100

Non-authoritative answer:
pop.domain.com canonical name = mail.domain.com
> exit

Cheers
Julian
 
You can achieve it by modifying DNS template. You can do it at Server>DNS.
 
Changing the template doesn't affect existing domains. This is a method of adding a subdomain for all EXISTING domains.
 
After changing DNS template of the server you can go to Domains>DomainName>DNS and press "Default"
 
That sounds much easier and safer that the way I described. Thanks. You'd have to have a lot of domains to make it worth taking the SQL route.
 
Back
Top