Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

系统DNS配置问题 #184

Open
reserveword opened this issue Mar 31, 2021 · 3 comments
Open

系统DNS配置问题 #184

reserveword opened this issue Mar 31, 2021 · 3 comments

Comments

@reserveword
Copy link

reserveword commented Mar 31, 2021

我把DNS服务器配置成优先使用系统DNS

priority = system|overhttps|remote

同时系统DNS只有一个本机127.0.0.1,但是运行程序的时候就显示有三个系统DNS
图片
图片

图片
这是为什么呢?

@reserveword reserveword changed the title DNS 系统DNS配置问题 Mar 31, 2021
@SeaHOH
Copy link
Owner

SeaHOH commented Mar 31, 2021

ipconfig /all 运行下这个命令,估计能看到是哪个网络连接有设置,然后取消其 DNS 设置或禁用连接。

@reserveword
Copy link
Author

ipconfig /all 运行下这个命令,估计能看到是哪个网络连接有设置,然后取消其 DNS 设置或禁用连接。

没有这样的网络连接,只有我自己配置的127.0.0.1和::1,还有一些连接的DNS是

fec0:0:0:ffff::1%1
fec0:0:0:ffff::2%1
fec0:0:0:ffff::3%1

,其他都没有DNS服务器这一项。

@SeaHOH
Copy link
Owner

SeaHOH commented Apr 3, 2021

如果方便,请提供以下信息:

  • 运行 regedit 打开注册表,导出 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\Interfaces 分支,得到 reg 文件。

  • 运行 python3 进入交互模式,复制以下代码粘贴到其中,得到运行结果。

def get_dns_servers():
    import ctypes, ctypes.wintypes, struct, socket
    DNS_CONFIG_DNS_SERVER_LIST = 6
    buf = ctypes.create_string_buffer(2048)
    ctypes.windll.dnsapi.DnsQueryConfig(DNS_CONFIG_DNS_SERVER_LIST, 0, None, None, ctypes.byref(buf),
                                        ctypes.byref(ctypes.wintypes.DWORD(len(buf))))
    ipcount = struct.unpack('I', buf[0:4])[0]
    return [socket.inet_ntoa(buf[i:i + 4]) for i in range(4, ipcount * 4 + 4, 4)]

print(get_dns_servers())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants