I have a file called named.conf, which is the configuration file for BIND. It has entries enclosed in curly braces. I want to edit and enter a new zone entry into both the internal and external views using PHP. How can I do this. Is there any library
available for editing this type of config files?
view "internal"
{
match-clients { localnets; };
match-destinations { localnets; };
recursion yes;
include "/etc/named.root.hints";
zone "my.internal.zone" {
type master;
file "my.internal.zone.db";
};
};
view "external"
{
match-clients { !localnets; !localhost; };
match-destinations { !localnets; !localhost; };
recursion no;
include "/etc/named.root.hints";
zone "my.external.zone" {
type master;
file "my.external.zone.db";
};
};
I was able to do it using the below code. The code accepts arguments using PHP CLI and creates a new file with the values.
To execute the code call
php script.php --zone=my.new.external.zone --type=master --file=my.new.external.zone.db