RW - Python 中的主/辅 DNS 地址

发布于 2024-09-02 19:15:34 字数 185 浏览 1 评论 0原文

我想从系统读取主要和辅助 DNS 地址,并将其更改为任何用户给定的地址。

通过某些图书馆可以实现这一点吗?

另一种方法是我阅读 /etc/resolv.conf 并进行更改,这就是我所做的。

顺便说一句,我目前的解决方案是针对 Ubuntu 操作系统的,现在如果我也得到同样操作系统的解决方案,那就没问题了。

I want to read the primary and secondary dns addresses from the system and want to change it to any user given address.

Is this possible through some library.

An alternative approach is that I read the /etc/resolv.conf and do the changes, which is what I've done.

BTW the current solution I have is for Ubuntu OS, and for now if I get if for the same OS also it would be fine.

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

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

发布评论

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

评论(1

枉心 2024-09-09 19:15:34

/etc/resolv.conf DNS 服务器的权威来源,因此您最好在那里进行检查。

有点题外话,但请注意它被 DHCP 覆盖,因此如果您需要添加自己的 DNS 服务器,您必须编辑 /etc/dhcp3/dhclient.conf 并添加类似以下内容:

append domain-name-servers <DNS-ip>;

或者

prepend domain-name-servers <DNS-ip>;

还请注意 Ubuntu(位于我使用的至少是 9.04) 仅支持最多 3 个 DNS 服务器。

/etc/resolv.conf IS the authoritative source of DNS servers, so you better check there.

A bit off-topic, but note that it's being overriden by DHCP, so if you need to add own DNS server, you have to edit /etc/dhcp3/dhclient.conf and add there something like:

append domain-name-servers <DNS-ip>;

or

prepend domain-name-servers <DNS-ip>;

Also note that Ubuntu (at least 9.04 I'm using) supports only up to 3 DNS servers.

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