php*_*_qq 7 vpn internet 18.04
默认情况下(我猜)每当我断开 VPN 连接时,Ubuntu 都会切断我的互联网连接,这很好,除非您不想要它,并且每次都必须重新连接(停止和启动)您的连接。如何配置它以使其在断开特定 VPN 连接后不会阻止我的流量?
此问题的解决方法是为网络管理器创建一个调度脚本,它将自动为您执行此操作。
/etc/NetworkManager/dispatcher.d/80-ppp-vpn-down
使用以下内容创建:
#!/usr/bin/env bash
##
# The environment contains more information about the interface and the connection:
# DEVICE_IFACE - The interface name of the control interface of the device
main() {
local interface="$1"
local event="$2"
if [[ "${interface}" =~ "ppp"* && "${event}" == "vpn-down" ]]; then
local connection
connection="$(nmcli -t -f NAME,DEVICE connection show --active | awk -F: '/'"${DEVICE_IFACE}"'/ {print $1}')" || return 1
nmcli connection down id "${connection}"
nmcli connection up id "${connection}"
fi
}
main "$@"
exit $?
Run Code Online (Sandbox Code Playgroud)
确保它也可执行:
chmod +x /etc/NetworkManager/dispatcher.d/80-ppp-vpn-down
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
355 次 |
最近记录: |