如何使用 DNS 自动创建子域?

发布于 2024-07-13 17:46:09 字数 265 浏览 2 评论 0原文

我想以编程方式自动更新我的 DNS 更多域。 我在 GoDaddy 上运行 BIND 服务器(在 FreeBSD 上)以及主机域和 DNS。 我找不到 GoDaddy 的 Web 服务 API 来访问和更新他们托管的 DNS,因此我可能必须使用我的 BIND 服务器来提供动态解决方案。

基本上我只想查询哪些子域已经存在并添加新的子域。

BIND 是最好的解决方案吗? 是否有其他方法可以自动添加新域名,而无需登录 GoDaddy 或手动更新我的 BIND 配置?

I would like to automatically update my DNS more multiple domains programmatically. I run a BIND server (on FreeBSD) as well as host domains and DNS at GoDaddy. I could not find a web service API for GoDaddy to access and update my DNS that they are hosting so I may have to use my BIND server to provide a dynamic solution.

Basically I just want to query which sub-domains already exist and add new ones.

Is BIND the best solution? Is there another way to automatically add new domains without me having to log into GoDaddy or update my BIND configuration manually?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

赠意 2024-07-20 17:46:09

您需要添加新子域的功能是动态更新,如 RFC 2136,并得到 BIND 的良好支持。

使用 DNS“UPDATE”消息在区域文件中添加和删除记录相当容易(例如使用 Perl 的 Net::DNS 模块)。

要实际检索其中的内容,您有两种方法:

  1. 将其他一些数据库视为确定的,并将该数据库中的更改转换为 ddns 更新,或者。

  2. 允许 DNS“AXFR”消息以允许您下载整个区域内容(尽管仅下载到您的区域管理系统,而不是整个世界!)

The feature you need to add new sub-domains is Dynamic Updates, as specified in RFC 2136, and well supported by BIND.

It's reasonably easy (for example with Perl's Net::DNS module) to add and remove records from a zone file with the DNS "UPDATE" message.

To actually retrieve what's there, you've got two approaches:

  1. Treat some other database as definitive, and convert changes in that database into ddns updates, or.

  2. Permit DNS "AXFR" messages to allow you to download the entire zone content (albeit only to your zone management system, not to the whole world!)

猫七 2024-07-20 17:46:09

一种方法是编写一个程序来读取和/或更新 BIND 配置文件(它只是一个具有特定格式的文本文件),并在发生任何更改时重新加载 BIND 守护程序。 因此,就像您手动更新了 BIND 配置一样,除非您已经编写了一个程序来为您执行此操作。

One approach would be to write a program that reads and/or updates the BIND configuration file (it's just a text file, with a specific format) and reloads the BIND daemon if any changes have been made. So, it would be as if you updated your BIND configuration manually, except you'd have written a program to do it for you.

£噩梦荏苒 2024-07-20 17:46:09

仅供参考:这是系统/网络管理问题,而不是编程问题。 您可能可以在其他地方更快地得到更好的答案。

也就是说......这相当简单:您只需要一个支持其数据的数据库后端的 DNS 服务器。 然后,您只需将条目写入数据库,或查询数据库中的内容,DNS 记录就会自动提供。 理想情况下,使用支持触发器的数据库,以便您可以在发生更改时自动更新 DNS 记录的序列号。 否则,您需要在代码的每次更改中读取/写入序列,在事务中完成整个更新。

编辑:刚刚看到上面的其他评论。 不允许 AXFR。 如今这被认为是一种安全风险。

不过,请将域 TTL 设置得较低,以便更新能够快速传播到其他服务器。

Just FYI: this is a systems/network administration question, not a programming question. You probably could have got better answers more quickly elsewhere.

That said... it's fairly simple: you just need a DNS server that supports a database backend for its data. Then you just write entries to the database, or query the database for what's in there, and the DNS records will be served out automatically. Ideally, use a database that supports triggers so you can have the DNS records' serial numbers update automatically on changes. Otherwise, you'll need to read/write the serial in every change from your code, doing the whole update within a transaction.

Edit: just saw the other comment above. Don't allow AXFR. That's considered a security risk these days.

Do have the domain TTLs set lowish so updates propagate to other servers quickly, though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文