在Python中获取DNS搜索域

2024-05-15 07:41:51 发布

您现在位置:Python中文网/ 问答频道 /正文

我想获得为localhost配置的搜索域,这意味着在查找DNS时附加到主机名的域名,例如example.comsome.other.example.com。你知道吗

在Linux中,它们保存在/etc/resolv.conf中,如下所示:

search example.com some.other.example.com

This answer有一个针对Windows的特定于操作系统的解决方案。你知道吗

有没有一种平台无关的方法可以用Python获取主机的DNS搜索域?你知道吗


Tags: answercomlocalhostsearchdnsexamplelinuxconf