1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice

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

Discussion in 'Plesk for Windows - 8.x and Older' started by inCharge.co.uk, Nov 9, 2005.

  1. inCharge.co.uk

    inCharge.co.uk Guest

    0
     
    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
     
  2. inCharge.co.uk

    inCharge.co.uk Guest

    0
     
    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.
     
  3. inCharge.co.uk

    inCharge.co.uk Guest

    0
     
    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
     
  4. Gris@

    Gris@ Guest

    0
     
    You can achieve it by modifying DNS template. You can do it at Server>DNS.
     
  5. inCharge.co.uk

    inCharge.co.uk Guest

    0
     
    Changing the template doesn't affect existing domains. This is a method of adding a subdomain for all EXISTING domains.
     
  6. Gris@

    Gris@ Guest

    0
     
    After changing DNS template of the server you can go to Domains>DomainName>DNS and press "Default"
     
  7. inCharge.co.uk

    inCharge.co.uk Guest

    0
     
    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.
     
Loading...