我刚刚从 ubuntu 19.10 更新到 ubuntu 20.04。现在,当我使用网络管理器中的 openconnect 连接到 vpn 时,我的 resolve.conf 不再更新。
这可以正常工作:
sudo openconnect-u 用户https://服务器
我看到 resolv.conf 被更改了。所以这是客户端的问题。
在 /etc/NetworkManager/NetworkManager.conf 中我有 dns=none 来使用 resolv.conf
/etc/resolv.conf 是一个文件,没有符号链接到 /run/systemd/resolve/resolv.conf。我确实检查了 /run/systemd/resolve/resolv.conf 是否有被任何东西更新,但它也没有被更新。
这是来自系统日志的:
NetworkManager[62862]: <info> [1590658767.3686] vpn-connection[,"vpn",0]: VPN connection: (ConnectInteractive) reply received
NetworkManager[62862]: <info> [1590658767.3714] vpn-connection[,"vpn",0]: VPN plugin: state changed: starting (3)
openconnect[63139]: Connected to somehostip:443
openconnect[63139]: SSL negotiation with somehostip
openconnect[63139]: Server certificate verify failed: signer not found
openconnect[63139]: Connected to HTTPS on somehostip
openconnect[63139]: Got CONNECT response: HTTP/1.1 200 OK
openconnect[63139]: CSTP connected. DPD 30, Keepalive 20
openconnect[63139]: Connected as 10.0.0.2 + ipv6addresswashere, using SSL, with DTLS in progress
openconnect[63139]: Established DTLS connection (using GnuTLS). Ciphersuite (DTLS0.9)-(DHE-CUSTOM)-(AES-256-CBC)-(SHA1).
openconnect[63139]: SIOCSIFMTU: Operation not permitted
NetworkManager[62862]: <info> [1590658768.5289] vpn-connection[,"vpn",0]: VPN connection: (IP Config Get) reply received.
NetworkManager[62862]: <info> [1590658768.5320] vpn-connection[,"vpn",14:(vpn0)]: VPN connection: (IP4 Config Get) reply received
NetworkManager[62862]: <info> [1590658768.5362] vpn-connection[,"vpn",14:(vpn0)]: VPN connection: (IP6 Config Get) reply received
NetworkManager[62862]: <info> [1590658768.5373] vpn-connection[,"vpn",14:(vpn0)]: Data: VPN Gateway: somehostip
NetworkManager[62862]: <info> [1590658768.5374] vpn-connection[,"vpn",14:(vpn0)]: Data: Tunnel Device: "vpn0"
NetworkManager[62862]: <info> [1590658768.5374] vpn-connection[,"vpn",14:(vpn0)]: Data: IPv4 configuration:
NetworkManager[62862]: <info> [1590658768.5375] vpn-connection[,"vpn",14:(vpn0)]: Data: Internal Address: 10.0.0.2
NetworkManager[62862]: <info> [1590658768.5375] vpn-connection[,"vpn",14:(vpn0)]: Data: Internal Prefix: 19
NetworkManager[62862]: <info> [1590658768.5375] vpn-connection[,"vpn",14:(vpn0)]: Data: Internal Point-to-Point Address: 10.0.0.55
NetworkManager[62862]: <info> [1590658768.5375] vpn-connection[,"vpn",14:(vpn0)]: Data: Static Route: 0.0.0.0/0 Next Hop: 0.0.0.0
NetworkManager[62862]: <info> [1590658768.5376] vpn-connection[,"vpn",14:(vpn0)]: Data: Static Route: 10.0.0.0/19 Next Hop: 0.0.0.0
NetworkManager[62862]: <info> [1590658768.5376] vpn-connection[,"vpn",14:(vpn0)]: Data: DNS Domain: 'xxx.com'
NetworkManager[62862]: <info> [1590658768.5376] vpn-connection[,"vpn",14:(vpn0)]: Data: IPv6 configuration:
NetworkManager[62862]: <info> [1590658768.5377] vpn-connection[,"vpn",14:(vpn0)]: Data: Internal Address: ipv6addresswashere
NetworkManager[62862]: <info> [1590658768.5377] vpn-connection[,"vpn",14:(vpn0)]: Data: Internal Prefix: 64
NetworkManager[62862]: <info> [1590658768.5378] vpn-connection[,"vpn",14:(vpn0)]: Data: Internal Point-to-Point Address: ipv6addresswashere
NetworkManager[62862]: <info> [1590658768.5378] vpn-connection[,"vpn",14:(vpn0)]: Data: Static Route: ::/0 Next Hop: ::
NetworkManager[62862]: <info> [1590658768.5378] vpn-connection[,"vpn",14:(vpn0)]: Data: Static Route: ipv6addresswashere Next Hop: ::
NetworkManager[62862]: <info> [1590658768.5378] vpn-connection[,"vpn",14:(vpn0)]: Data: DNS Domain: 'xxx.com'
NetworkManager[62862]: <info> [1590658768.5380] vpn-connection[,"vpn",14:(vpn0)]: VPN plugin: state changed: started (4)
NetworkManager[62862]: <info> [1590658768.5534] vpn-connection[,"vpn",14:(vpn0)]: VPN connection: (IP Config Get) complete
NetworkManager[62862]: <info> [1590658768.5548] device (vpn0): state change: unmanaged -> unavailable (reason 'connection-assumed', sys-iface-state: 'external')
NetworkManager[62862]: <info> [1590658768.5600] device (vpn0): state change: unavailable -> disconnected (reason 'connection-assumed', sys-iface-state: 'external')
NetworkManager[62862]: <info> [1590658768.5615] device (vpn0): Activation: starting connection 'vpn0' (xxx)
NetworkManager[62862]: <info> [1590658768.5616] manager: NetworkManager state is now CONNECTED_SITE
NetworkManager[62862]: <info> [1590658768.5629] manager: NetworkManager state is now CONNECTED_LOCAL
NetworkManager[62862]: <info> [1590658768.5632] manager: NetworkManager state is now CONNECTED_SITE
NetworkManager[62862]: <info> [1590658768.5633] policy: set 'vpn' (vpn0) as default for IPv4 routing and DNS
我查看了升级之前的旧系统日志,其中有如下几行:
NetworkManager[1245]: <info> [1590386910.5867] vpn-connection[,"vpn",14:(vpn0)]: Data: Internal DNS: 10.0.0.1
NetworkManager[1245]: <info> [1590386910.5867] vpn-connection[,"vpn",14:(vpn0)]: Data: Internal DNS: 10.0.0.2
所以现在那些都不见了。有人知道如何解决这个问题吗?
我确实尝试使用 dns=auto 来使用 systemd-resolve,但存在同样的问题。systemd-resolve --status 报告 vpn 连接没有 dns 服务器,/run/systemd/resolve/resolve.conf 也是如此。
注意:我将所有 IP 地址和主机名等匿名化。
答案1
我找到了解决方案。基本上,如果 DNS 服务器发送 ipv6 dns 服务器来查找 ipv4 地址,事情就会出错。Openconnect 会将 ipv6 地址放入 INTERNAL_IP4_DNS 中,而“network-manager-openconnect”并不期望这一点,会将整个变量(基本上是所有 dns 服务器)视为垃圾并继续。我从 master 编译了自己的 network-manager-openconnect,它对此进行了修复,并且运行良好。
我不知道为什么升级后会出现这个问题。也许是 openconnect 发生了一些变化?或者也许在我升级的那天,我公司的网络管理员添加了一个 ipv6 dns 服务器?(我认为这不太可能......)
如果您正在使用 network-manager-openconnect 1.2.6 或 1.2.7-dev(或者甚至是较低版本,不包含修复),您可以从 master 编译您自己的版本,如下所示:
sudo apt-get build-dep network-manager-openconnect
mkdir ~/network-manager-openconnect_build
cd ~/network-manager-openconnect_build
git clone https://gitlab.gnome.org/GNOME/NetworkManager-openconnect.git
cd NetworkManager-openconnect
./autogen.sh
make
sudo mv /usr/lib/NetworkManager/nm-openconnect-service-openconnect-helper /usr/lib/NetworkManager/nm-openconnect-service-openconnect-helper_bak
sudo cp src/nm-openconnect-service-openconnect-helper /usr/lib/NetworkManager/nm-openconnect-service-openconnect-helper
注意:我只复制了辅助 bin。理论上,这可能会导致不兼容问题。我没有遇到任何问题。但如果有,您可以尝试从 src 复制主 bin。
如果需要,您可以使用以下命令为 vpn 模块添加额外的日志记录,以便在 syslog 中查看 openconnect 是否收到任何 dns 数据:
sudo nmcli general logging level KEEP domains VPN_PLUGIN:TRACE
如果您看到 INTERNAL_IP4_DNS 同时设置了 ipv4 和 ipv6 地址,并且您使用上面提到的 openconnect 网络管理器版本,则您会受到此错误的影响。