set IP for creating domain or subdomain in DNS record

behinam

Well-Known Member
May 9, 2017
77
5
58
Dubay
cPanel Access Level
Root Administrator
Hello
i have Cpanel server with IP : X.X.X.X
when i create a account or subdomain, it was created with Cpanel ip in DNS A records, but i want when i create new domain or account , it create with my arbitrary A record IP like X.X.X.Y in DNS records. ( domain point to my IP)

my webserver Isolated from Cpanel server and website should point to webserver IP.

Can anyone help?
 

behinam

Well-Known Member
May 9, 2017
77
5
58
Dubay
cPanel Access Level
Root Administrator
Hello
Cpanel IP address set in basic configuration WHM but web servers IP is different. I want when create Sub domain, it create with webserver A record in DNS service instead of Cpanel IP address.

thanks
 

behinam

Well-Known Member
May 9, 2017
77
5
58
Dubay
cPanel Access Level
Root Administrator

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,258
463
Hello,

You could develop a custom bash script that manually modifies or adds to the DNS zone through the manipulation of the corresponding zone file in the /var/named/ directory. Then, configure that custom script to automatically run upon the creation of new subdomains via a hook event:

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.