我已经安装了Wireguard并成功地连接到了我的VPN网络,但是我无法使用VPN网络的DNS解析域名。我可以通过nslookup获得绑定到域的IP地址,但是ping、curl等不能做到这一点。
我也使用openvpn,所以使用openvpn连接解析域名可以工作得很好。
如何解决使用wireguard解析域名的问题?
操作系统: Ubuntu 18.10
发布于 2021-11-22 11:45:27
从CONFIGURATION的wg-quick手册页面中,用一种不太明显的方式来表达:
• DNS — a comma-separated list of IP (v4 or v6) addresses to be set as the interface's DNS servers, or non-IP hostnames to be set as the in‐
terface's DNS search domains. May be specified multiple times. Upon bringing the interface up, this runs `resolvconf -a tun.INTERFACE -m 0
-x` and upon bringing it down, this runs `resolvconf -d tun.INTERFACE`. If these particular invocations of resolvconf(8) are undesirable,
the PostUp and PostDown keys below may be used instead.其中声明可以在您的search文件的[Interface]部分中包括一个/etc/wireguard/wg.conf域,以及您的DNS服务器条目:
[Interface]
DNS = 10.10.10.1, localdomain将IP 10.10.10.1更改为远程wg网络中的DNS服务器IP,更新localdomain以反映远程wg网络中使用的域名。
例如:如果您有一个包含例如RFC1918地址的RFC1918部分:
[Peer]
AllowedIPs = 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16然后,myserver的查询将作为myserver.localdomain发送到10.10.10.1 (您的远程DNS服务器显然需要能够解析该主机)。
如果您有多个可以由远程DNS服务器解析的域,那么它们也可以附加到上面的DNS =条目中,每个条目由一个逗号分隔。
所有这些都是在常规主机/etc/resolv.conf之外处理的,并使用resolvconf在幕后添加额外的DNS详细信息,这些细节将在wg接口上动态添加/删除。
警告:我不知道(尚未测试)在发送查询时使用的是什么优先级,因此,如果您有多个活动的wg远程DNS服务器,则可能会向多个远程DNS服务器发送查询,因此可能会将主机详细信息泄漏到该远程DNS服务器,这可能是不可取的。
HTH
https://askubuntu.com/questions/1132981
复制相似问题