I am working for a company and we have a domain name hosted on GoDaddy. For the website/application we are creating, we need to be able to programmatically add "A records" to the DNS zone file to point specific subdomains to specific IP addresses/servers. This will be done via PHP or C#, we have two different servers for our application and it doesn't matter, we just need that functionality. I know GoDaddy doesn't give you this functionality nor an API, but I was wondering if anyone could recommend a cheap/affordable service that would let me do this? I don't think we need something like dynamic DNS (or maybe we will), but if anyone knows anything I would much appreciate.
All in all, we are looking for a super cheap and easy way to add custom A records to a zone file programmatically. A free code base would be nice for this as well. The way our application works, we cannot use wildcards or make this too convoluted, it would be most beneficial to have control over the DNS zone file. Thank you!
To add a host record, you will need to use the PowerShell DNS cmdlet Add-DnsServerResourceRecordA . In the example below, you need to add a host record for a new printer that you are adding to the network. It will be added to the corp.ad zone with the name reddeerprint01, and its IP address is 192.168. 2.56.
Record types Each DNS record has a name and a type. Records are organized into various types according to the data they contain. The most common type is an 'A' record, which maps a name to an IPv4 address. Another common type is an 'MX' record, which maps a name to a mail server.
Unfortunately the other responses here did not quite help, but I did find a problem to our solution on my own. I am going to post my solution to help others who may need to programmatically create A records and modify other DNS zone file settings from their website scripting.
I signed up on the website www.cloudflare.com. They are a cloud-based DNS service that manages your DNS for free but also has paid solutions for bigger scale projects. They have a complete, integrated API solution for programmatically modifying DNS zone settings. All I had to do was point my nameservers on GoDaddy to use theirs, and then I was able to use their free cloud-based DNS service.
Now with PHP, I am able to programmatically create DNS records through their service, including A, CNAME, and everything in between. Very simple and intuitive service that solved a big problem we had. Setup was a snap and only took a few minutes to propagate initially. There are other cloud-based DNS services, but CloudFlare lets you sign up for free, no questions asked. I was able to play with their API before committing to it. And their prices are very reasonable with the pro-plan costing only $20/month if you need higher performance.
You could have your own DNS server (e.g.: unbound), then you can just make your program change the zone file and reload the service, if needed.
Here's an example of changing a zone file using the unbound API. Though it's written in Python and modifying resolv.conf
, but with a few changes you can make it work with the actual DNS server zone file.
Maybe it's not the best solution, but it's an easy one.
dns-zonefile
https://github.com/elgs/dns-zonefile is what you are looking for. This is a javascript library/utility that converts dns zone file from/to JSON formats.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With