I've developed an application with Laravel (it's same as a site builder), clients can add their information to their profile, and finally, they can park a domain to the profile (by setting my DNS for the domains)

In the application controller, I will get the domain name (with request()->getHost()) and I will load the correct profile.

Everything is ok when I've tested my application on the local by adding a sample domain to /etc/hosts.

My problem is on the server because I need to add a DNS Zone for each domain (as far as I know), I'm wondered is there any solution to read the DNS records from a MySQL database, instead of the file? because BIND will load the DNS Zones from a text file and I don't want to generate that files.

The server is CentOS 8.


Solution 1:

Is it possible for you to switch to PowerDNS instead of BIND? PowerDNS supports reading DNS records from a MySQL database, and has a JSON API to add/remove records which you can use from your app (which will handle things like properly incrementing the serial number) instead of manually manipulating its database.

Solution 2:

BIND has database support called Dynamically Loadable Zones (DLZ).

DLZ (Dynamically Loadable Zones) is an extension to BIND 9 that allows zone data to be retrieved directly from an external database. There is no required format or schema. DLZ drivers exist for several different database backends including PostgreSQL, MySQL, and LDAP and can be written for any other.

There's also an article on Using DLZ in BIND.