这是与此处相同的问题:让openconnect vpn通过gui工作,但是我对它的添加被删除了,并要求我创建一个新问题。
实际上,这里有很多人在问类似的问题,但都回答为0。
软体版本: ubuntu 14.04,openconnect 5.02
主要问题:我正在尝试使用openconnect将vpn连接添加到网络管理器中。当我提供我的VPN用户名和密码时,它可以成功连接,但是我无法解析DNS。
如果我通过sudo在终端中运行openconnect,则dns有效。
sudo openconnect -u <username> https://<vpn concentrator name>
更多细节:
1a。当通过openconnect和network-manager连接时,即使我在ipv4选项卡下明确添加了dns和搜索域,也只有搜索域以/etc/resolv.conf结尾。即使我不提供dns和搜索域,我也可以在日志中看到它正在从vpn集中器获取信息。再次,搜索域已正确更新。[下面的日志]
1b。当在终端上通过sudo连接时,即使我没有在命令行中添加该信息或未提供vpnc脚本的路径,resolv.conf仍正确填充了dns和搜索域。它一定是从vpn集中器获得的。[下面也有日志]
2a。通过openconnect和network-manager连接时,将创建一个新接口'vpn0'。
2b。通过sudo和命令行连接时,将创建一个新接口'tun0'。
通过网络管理器连接时记录日志:
NetworkManager[784]: <info> Starting VPN service 'openconnect'...
NetworkManager[784]: <info> VPN service 'openconnect' started (org.freedesktop.NetworkManager.openconnect), PID 4513
NetworkManager[784]: <info> VPN service 'openconnect' appeared; activating connections
NetworkManager[784]: <info> VPN plugin state changed: init (1)
这是要求我输入密码的地方
NetworkManager[784]: <info> VPN plugin state changed: starting (3)
NetworkManager[784]: SCPlugin-Ifupdown: devices added (path: /sys/devices/virtual/net/vpn0, iface: vpn0)
NetworkManager[784]: SCPlugin-Ifupdown: device added (path: /sys/devices/virtual/net/vpn0, iface: vpn0): no ifupdown configuration found.
NetworkManager[784]: <warn> /sys/devices/virtual/net/vpn0: couldn't determine device driver; ignoring...
NetworkManager[784]: <info> VPN connection '<connection name>' (Connect) reply received.
openconnect[4544]: Attempting to connect to server <ip address>:443
openconnect[4544]: SSL negotiation with <correctly identified vpn server>
openconnect[4544]: Connected to HTTPS on <correctly identified vpn server>
openconnect[4544]: Got CONNECT response: HTTP/1.1 200 OK
openconnect[4544]: CSTP connected. DPD 30, Keepalive 20
NetworkManager[784]: <info> VPN connection '<connection name>' (IP Config Get) reply received.
NetworkManager[784]: <info> VPN connection '<connection name>' (IP4 Config Get) reply received.
NetworkManager[784]: <info> VPN connection '<connection name>' (IP6 Config Get) reply received.
NetworkManager[784]: <info> VPN Gateway: <ip address>
NetworkManager[784]: <info> Tunnel Device: vpn0
NetworkManager[784]: <info> IPv4 configuration:
NetworkManager[784]: <info> Internal Address: 10.xxx.xxx.xxx
NetworkManager[784]: <info> Internal Prefix: 19
NetworkManager[784]: <info> Internal Point-to-Point Address: 10.xxx.xxx.xxx
NetworkManager[784]: <info> Maximum Segment Size (MSS): 0
NetworkManager[784]: <info> Forbid Default Route: no
NetworkManager[784]: <info> Internal DNS: <ip address>
NetworkManager[784]: <info> Internal DNS: <ip address>
NetworkManager[784]: <info> DNS Domain: '(none)'
NetworkManager[784]: <info> IPv6 configuration:
NetworkManager[784]: <info> Internal Address: <ipv6 ip>
NetworkManager[784]: <info> Internal Prefix: 64
NetworkManager[784]: <info> Internal Point-to-Point Address: <ipv6 ip>
NetworkManager[784]: <info> Maximum Segment Size (MSS): 0
NetworkManager[784]: <info> Forbid Default Route: no
NetworkManager[784]: <info> DNS Domain: '(none)'
openconnect[4544]: Connected vpn0 as <ip address> + <ipv6 ip>, using SSL
openconnect[4544]: Established DTLS connection (using OpenSSL)
NetworkManager[784]: <info> VPN connection '<connection name>' (IP Config Get) complete.
NetworkManager[784]: <info> Policy set '<connection name>' (vpn0) as default for IPv4 routing and DNS.
NetworkManager[784]: <info> Policy set '<connection name>' (vpn0) as default for IPv6 routing and DNS.
NetworkManager[784]: <info> Writing DNS information to /sbin/resolvconf
dnsmasq[1027]: setting upstream servers from DBus
dnsmasq[1027]: using nameserver 127.0.0.1#53 for domain 10.in-addr.arpa
dnsmasq[1027]: using nameserver 127.0.0.1#53 for domain <home search domain>
dnsmasq[1027]: using nameserver 127.0.0.1#53 for domain <vpn search domain>
dnsmasq[1027]: using nameserver <ip address>#53 for domain 10.in-addr.arpa
dnsmasq[1027]: using nameserver <ip address>#53 for domain <home search domain>
dnsmasq[1027]: using nameserver <ip address>#53 for domain <vpn search domain>
dnsmasq[1027]: using nameserver <ip address>#53 for domain 10.in-addr.arpa
dnsmasq[1027]: using nameserver <ip address>#53 for domain <home search domain>
dnsmasq[1027]: using nameserver <ip address>#53 for domain <vpn search domain>
dbus[471]: [system] Activating service name='org.freedesktop.nm_dispatcher' (using servicehelper)
NetworkManager[784]: <info> VPN plugin state changed: started (4)
NetworkManager[784]: keyfile: updating /etc/NetworkManager/system-connections/<connection name>-6a503043-13b0-4ce7-9749-29cd3054cae3
dbus[471]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
尽管日志中有很多关于更新resolv.conf的杂音,但它会删除名称服务器,但不会将其替换为日志中的IP地址。它确实会正确更新搜索域,因此可能不是权限问题。
在终端中使用sudo openconnect连接时的日志:
NetworkManager[784]: SCPlugin-Ifupdown: devices added (path: /sys/devices/virtual/net/tun0, iface: tun0)
NetworkManager[784]: SCPlugin-Ifupdown: device added (path: /sys/devices/virtual/net/tun0, iface: tun0): no ifupdown configuration found.
NetworkManager[784]: <warn> /sys/devices/virtual/net/tun0: couldn't determine device driver; ignoring...
dbus[471]: [system] Activating service name='org.freedesktop.hostname1' (using servicehelper)
kernel: [ 3258.725774] systemd-hostnamed[4927]: Warning: nss-myhostname is not installed. Changing the local hostname might make it unresolveable. Please install nss-myhostname!
dbus[471]: [system] Successfully activated service 'org.freedesktop.hostname1'
无需更新resolv.conf,但可以正确更新名称服务器和搜索域。
更新 ,如果我忽略resolv.conf中所有的警告,并添加VPN集中域名服务器吧,我是即刻就能浏览。当然,一旦我断开连接,这些更改就会被覆盖。
早在2012年就存在一个错误,但此错误已过期。问题似乎是vpnc脚本。
我尝试手动将vpnc脚本更新为最新版本,但无济于事。
一些进一步的研究表明,从12.04版本开始,在使用network-manager时,resolv.conf不再是名称服务器用于dns解析的地方。这就是为什么当我使用命令行而不是使用network-manager时它可以工作的原因。而是添加了名称服务器127.0.1.1 [dnsmasq],并告知该名称服务器实际的名称服务器的IP地址。
最大的优点是,如果您连接到VPN,而不是像过去那样通过DNS路由所有DNS流量,您将只发送与该VPN宣布的子网和域相关的DNS查询
如上面的链接所述,通过禁用dnsmasq来进行更新可解决此问题,因为已填充了/etc/resolv.conf。
尽管这是一个回退,但这不是一个真正的解决方案。
nameserver
,无论使用了多少个转发名称服务器,都仅在/etc/resolv.conf中的一行上列出其侦听地址。