ds1*_*848 5 permissions network-manager vpn networking
我最近安装了 Ubuntu 18.04。我通过标准设置-> 网络 GUI 设置了 VPN。我可以毫无问题地连接到 VPN,但是当我断开 VPN 连接时,我无法通过 Web 浏览器访问互联网。但是,我可以从 shell 窗口 ping 一个 Internet 地址。
我的 /etc/resolv.conf 文件是 /run/systemd/resolve/stub-resolv.conf 的符号链接。
在我连接到 VPN 之前,权限/所有权如下:
-rw-r--r-- 1 systemd-resolve systemd-resolve 701 Jun 20 20:28 /run/systemd/resolve/stub-resolv.conf
Run Code Online (Sandbox Code Playgroud)
当我连接到 VPN 时,这些权限保持不变,但是当我断开连接时,读取权限将被删除并且所有权更改为root:root,如下所示:
-rw------- 1 root root 701 Jun 20 20:31 /run/systemd/resolve/stub-resolv.conf
Run Code Online (Sandbox Code Playgroud)
似乎因此,我的网络浏览器无法读取 resolv.conf 文件,因此不知道要使用什么名称服务器
如果我chmod a+r这个文件,我可以正常访问互联网,即使所有权仍然是root:root.
有没有人知道这里发生了什么,以及如何在不每次断开 VPN 时手动更改解析文件的权限的情况下修复它?
小智 2
我有同样的问题。也许这是一个错误。但我使用网络管理器。该解决方案不适用于它。该脚本不运行。我为其添加了我的解决方案。
NetworkManager 有类似的解决方案。该脚本必须添加到目录中:
/etc/NetworkManager/dispatcher.d
我添加了这个文件:“02-fix-resolv.conf.sh”:
#!/bin/sh
if [ "$1" = "ppp0" -a "$2" = "vpn-up" ]; then
echo "bleeeeeee je dole" > /tmp/testjenahore.txt
chmod a+r /run/systemd/resolve/stub-resolv.conf.pppd-backup.ppp0
chown systemd-resolve:systemd-resolve /run/systemd/resolve/stub-resolv.conf.pppd-backup.ppp0
fi
Run Code Online (Sandbox Code Playgroud)
这个对我有用。我发现,文件“/run/systemd/resolve/stub-resolv.conf.pppd-backup.ppp0”的权限和所有者很差。当 VPN 启动时,我的脚本会修复权限和遮篷。如果 VPN 出现故障,它也能正常工作。
更新:我在 /etc/network/if-post-down.d 目录中添加了一个脚本,该脚本仅在 VPN 断开连接时更改 Stub-resolv.conf 文件的权限/所有权。
if [ "$IFACE" = ppp0 ]; then
chmod a+r /run/systemd/resolve/stub-resolv.conf
chown systemd-resolve:systemd-resolve /run/systemd/resolve/stub-resolv.conf
fi
Run Code Online (Sandbox Code Playgroud)
目前看来这可行。
| 归档时间: |
|
| 查看次数: |
2762 次 |
| 最近记录: |