All*_*ial 6 network-manager systemd systemd-resolved 18.04
有没有办法仅在通过网络管理器或其配置文件之一连接到 VPN (OpenVPN) 时优先考虑特定 DNS 服务器?
我有一个经常连接的 VPN ( 192.168.1.*
),它192.168.1.53
配置了 DNS ( ) 以解析其网络上的主机名*.internal.example.com
。我的本地路由器 ( 192.168.0.1
) 上有 DD-WRT 和 Google 的 DNS 设置(这些并不是严格需要的)。
/etc/resolv.conf
我已用符号链接替换了 systemd存根/run/systemd/resolve/resolv.conf
,以便主机名实际上可以使用 VPN 的 DNS 服务器进行解析。昨天它运行良好,因为 VPN 的 DNS 服务器位于列表的顶部。
# /etc/resolv.conf -> /run/systemd/resolve/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
# ...
nameserver 192.168.1.53
nameserver 192.168.0.1
nameserver 8.8.8.8
# Too many DNS servers configured, the following entries may be ignored.
nameserver 8.8.4.4
search Home internal.example.com
Run Code Online (Sandbox Code Playgroud)
然而,当我今天连接时,DNS 条目被重新排序。
# /etc/resolv.conf -> /run/systemd/resolve/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
# ...
nameserver 192.168.0.1
nameserver 8.8.8.8
nameserver 8.8.4.4
# Too many DNS servers configured, the following entries may be ignored.
nameserver 192.168.1.53
search Home internal.example.com
Run Code Online (Sandbox Code Playgroud)
重新启动后顺序经常发生变化。有时,重新连接到 VPN 后,我会注意到顺序发生变化(在遇到解决问题后)。
systemd-resolve
工作正常,可以使用正确的 DNS 服务器解析主机。
$ systemd-resolve --status --no-pager
Global
DNSSEC NTA: ...
Link 10 (tun0)
Current Scopes: DNS
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Servers: 192.168.1.53
DNS Domain: internal.example.com
Link 2 (eno1)
Current Scopes: DNS
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Servers: 192.168.0.1
8.8.8.8
8.8.4.4
192.168.1.53
DNS Domain: Home
Run Code Online (Sandbox Code Playgroud)
$ systemd-resolve srv1.internal.example.com
srv1.internal.example.com: 192.168.1.113
-- Information acquired via protocol DNS in 2.1ms.
-- Data is authenticated: no
Run Code Online (Sandbox Code Playgroud)
ping
、nslookup
、 但ssh
都失败了。
$ ping srv1.internal.example.com
ping: srv1.internal.example.com: Name or service not known
Run Code Online (Sandbox Code Playgroud)
$ nslookup srv1.internal.example.com
Server: 192.168.0.1
Address: 192.168.0.1#53
** server can't find srv1.internal.example.com: NXDOMAIN
Run Code Online (Sandbox Code Playgroud)
$ ssh srv1.internal.example.com
ssh: Could not resolve hostname srv1.internal.example.com: Name or service not known
Run Code Online (Sandbox Code Playgroud)
一些笔记。
我通过网络管理器连接到 VPN。我在 VPN 上手动指定了 VPN 的 DNS:IPv4 > DNS 服务器。
我尝试使用单独的有线以太网连接,并在以下位置配置了 VPN 的 DNS:IPv4 > 其他 DNS 服务器。
当您接受使用 dnsmasq 时,这样怎么样:
server=/internal.example.com/192.168.1.53
server=8.8.8.8
Run Code Online (Sandbox Code Playgroud)
这将使用 192.168.1.53 作为域“internal.example.com”,使用 8.8.8.8 作为其他域。
查看 dnsmasq 手册页上的“-S、--local、--server=”选项。
更新:您可能还想禁用 DHCP,以避免与本地路由器发生冲突。也许只在 lo (127.0.0.1) 接口上监听。
归档时间: |
|
查看次数: |
10380 次 |
最近记录: |