我真的希望nordvpn能够在睡眠/恢复事件中存活下来,但是当然,如果远程端没有从我的笔记本上听到,那么它就会断开连接。公平地说,我很乐意在睡觉前断开连接,只要我能自动完成简历就可以重新连接--我通常在/usr/lib/systemd/system中-睡眠/睡眠-之类的(下面)。
但这不太管用。在简历中,运行“nordvpn连接”,如果立即观察到路由表(即从睡眠/恢复脚本中观察到),则路由表看起来很好:
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 10.8.1.1 128.0.0.0 UG 0 0 0 tun0
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 wlp3s0
10.8.1.0 0.0.0.0 255.255.255.0 U 0 0 0 tun0
103.137.12.219 192.168.0.1 255.255.255.255 UGH 0 0 0 wlp3s0
128.0.0.0 10.8.1.1 128.0.0.0 UG 0 0 0 tun0
172.16.2.0 0.0.0.0 255.255.255.0 U 0 0 0 vmnet8
172.16.71.0 0.0.0.0 255.255.255.0 U 0 0 0 vmnet1
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 wlp3s0不幸的是,当我登录时,路由表已经被“某某物”恢复到非vpn模式,我不知道是什么,也许是NetworkManager:
$ netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 wlp3s0
172.16.2.0 0.0.0.0 255.255.255.0 U 0 0 0 vmnet8
172.16.71.0 0.0.0.0 255.255.255.0 U 0 0 0 vmnet1
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 wlp3s0nordvpn状态报告说,它的工作:
$ nordvpn status
Status: Connected
Current server: au492.nordvpn.com
Country: Australia
City: Brisbane
Your new IP: 144.48.39.91
Current technology: OpenVPN
Current protocol: UDP
Transfer: 7.89 MiB received, 6.00 MiB sent
Uptime: 24 minutes 52 seconds..。但是,当然,我必须做一个额外的断开/连接,这是很俗气的。
有什么想法吗?
下面是脚本(放入/usr/lib/systemd/system-睡眠/睡眠-内容和chmod +x):
#!/bin/sh
if [ "${1}" == "pre" ]; then
# before suspend
pgrep nordvpnd &> /dev/null && nordvpn status |grep -q 'Status: Connected' && {
# This will run as root, so root needs to have been initialised by
# nordvpn login at some time in the past.
/bin/nordvpn disconnect
}
elif [ "${1}" == "post" ]; then
# after resume
pgrep nordvpnd &> /dev/null && {
# This will run as root, so root needs to have been initialised by
# nordvpn login at some time in the past.
(
sleep 5 # I've tried sleep from 0 to 5
/bin/nordvpn connect
netstat -rn # routing table looks OK now but it gets zapped by something else later!!
) &
}
fi这是在费多拉-31号。
发布于 2020-07-14 00:49:48
经过大量的讨论后,我得出的结论是,不可能使用/usr/lib/systemd/systemd/中的脚本重新启动nordvpn。
我已经满足于使用这个脚本来停止nordvpn的睡眠,我必须记住在简历中手动重新启动它。由于我使用的是摆(1),热键可以节省一些输入。
下面是修改后的脚本:
#!/bin/sh
if [ "${1}" == "pre" ]; then
# before suspend
pgrep nordvpnd &> /dev/null && nordvpn status |grep -q 'Status: Connected' && {
# This will run as root, so root needs to have been initialised by
# 'nordvpn login' at some time in the past.
nordvpn disconnect
}
elif [ "${1}" == "post" ]; then
# after resume
:
fihttps://unix.stackexchange.com/questions/597537
复制相似问题