Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Overhead of DNS records on subdomains

Discussion in 'Bind/DNS/Nameserver' started by darkshifty, Nov 14, 2017.

  1. darkshifty

    darkshifty Member

    Joined:
    Oct 14, 2016
    Messages:
    8
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Netherlands
    cPanel Access Level:
    Root Administrator
    I have an automated subdomain creation on my server via the API, however a load (9 of them!) of overhead DNS is created with the creation of a new subdomain. How can i customize the DNS templates for subdomains that only an A record is added?


    The following records are added which aren't needed:
    www
    default._domainkey
    cpcalendars
    webdisk
    cpanel
    webmail
    cpcontacts
    whm
    and a SPF record.

    With thanks
     
  2. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    45,532
    Likes Received:
    1,966
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    Assuming you want to keep those subdomains for the primary domain names associated with the cPanel accounts, you could develop a custom script that manually removes those DNS records through the manipulation of the corresponding zone file in the /var/named/ directory. Then, configure that custom script to run as a post hook every time a new subdomain is added:

    Guide to Standardized Hooks - Software Development Kit - cPanel Documentation

    You can find the corresponding API function for a hook by enabling "Debug mode is on. The system displays information about every stage for every hookable event, even if no hooks exist for that stage." under the "Development" tab in "WHM >> Tweak Settings". Then, perform the specific action you want to hook into via cPanel or WHM, and watch the output in /usr/local/cpanel/logs/error_log.

    For example, the following cPanel API 1 function is utilized when adding an Alias in cPanel:

    Cpanel::Api1::Park::park

    You can find documentation on hooks with cPanel functions at:

    Guide to Standardized Hooks - Cpanel Functions - Software Development Kit - cPanel Documentation

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    darkshifty likes this.
  3. darkshifty

    darkshifty Member

    Joined:
    Oct 14, 2016
    Messages:
    8
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Netherlands
    cPanel Access Level:
    Root Administrator
    Sounds good, i will have a look at that. Thanks!
     
    cPanelMichael likes this.
  4. darkshifty

    darkshifty Member

    Joined:
    Oct 14, 2016
    Messages:
    8
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Netherlands
    cPanel Access Level:
    Root Administrator
    I've looked into it but i cant come to a viable solution, the only way with these hooks is removing records per line which isn't very attractive to program as i have to identify all the 9 records, remove them per line and add an A record.

    Isn't there a way to adjust the template for subdomains or create a pre hook that uses such a template?

    The documentation is very general and limited.
     
  5. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    45,532
    Likes Received:
    1,966
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    Most of the subdomains you referenced are part of the proxy subdomains feature. They are automatically created as part of the following option under the "Domains" tab in "WHM >> Tweak Settings":

    Proxy subdomain creation

    Per it's description:

    Automatically create cpanel, webmail, webdisk, cpcalendars, cpcontacts, and whm proxy subdomain DNS entries for new accounts. When this is initially enabled it will add appropriate proxy subdomain DNS entries to all existing accounts. (Use /scripts/proxydomains to reconfigure the DNS entries manually)

    One potential alternative is to run a command like this in a custom script that runs as a post action hook during the addition of a new subdomain:

    Code:
    /scripts/proxydomains --domain=sub.domain.tld remove
    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice