Reputation: 153
Just updated my post to clarify that i use Bind9/named DNS. I found libraries but most implement their own DNS so i can't use them. I want to do a c++ program (running on linux/debian) to update a local DNS using bind9 with new records and then propagate informations so other nodes can update their local DNS. Actually I got a solution but i would like to know if there was a more proper way to do it (with some libs for example), and after that create new types of records and not only NAPTR.
I have messages with various informations (service/domain) and I am already using theses informations to create NAPTR records, but the method is very ugly. I write into a txt file all the nsupdate command i need for example :
std::ofstream nsupdateCommand("/tmp/nsupdate.txt", std::ofstream::out | std::ofstream::trunc);
nsupdateCommand << "update add" << enumName << "." << zone << ". "<< ttl << " NAPTR ";
[...]
nsupdateCommand << "send";
nsupdateCommand.close();
system("nsupdate -l -v /tmp/nsupdate.txt")
I would like to know if there is a better way to update the DNS in c++, maybe using sockets or a library?
Any help would be appreciated.
Upvotes: 0
Views: 403
Reputation: 13189
ldd `which nsupdate` |grep dns
libdns.so.81 => /usr/lib64/libdns.so.81 (0x000000348b000000)
rpm -qf /usr/lib64/libdns.so.81
bind-libs-9.8.2-0.62.rc1.el6_9.5.x86_64
On CentOS you need to install bind-devel
to get the header files for bind-libs
. Other distros may package them under slightly different names.
Upvotes: 1