当openvpn
启动时tun0
界面被创建并且立即wlan0
被删除。
如何防止这种情况发生?
编辑:我注意到其他类型的 VPN 也会出现同样的问题,所以这不是 OpenVPN 特有的。我使用了 VmWare 的 SSL VPN,也出现了同样的问题。
我查看了类似的案例,发现漫游方面存在类似的问题:OpenVPN 导致 Linux 中的 WLAN/WiFi 断开连接?
但是,同样的修复方法对我来说不起作用。看起来 on 的Ubuntu 16
wpa_supplicant
配置不同(对我来说很神秘)
可能根本原因是一样的(漫游),但我不知道如何配置接口启动脚本,以便 tun0 创建不会触发 wlan0 删除
使用时eth0
,没有问题。关闭时vpn tunnel
也没有问题。wlan
openvpn
欣赏有关如何调试的提示wlan_supplicant
。
系统信息:
- Linux ul001541 4.4.0-62-通用
- Ubuntu 16.04.1 LTS
- OpenVPN 2.4.0 x86_64-未知-linux-gnu
我可以通过运行 openvpn 来重现该问题:
>openvpn slviovyos.ovpn
这是配置文件 slviovyos.ovpn:
client
proto tcp
remote-cert-tls server
verb 2
dev tun0
cert tecodevteam.crt
key tecodevteam.key
ca ca.crt
remote 169.50.156.11 3389
当 wlan0 启动并运行且 openvpn 启动时出现的日志:
>journalctl -xe
feb 13 13:58:40 ul001541 NetworkManager[1410]: <info> [1486987120.8119] manager: (tun0): new Tun device (/org/freedesktop/NetworkManager/Devices/5)
feb 13 13:58:40 ul001541 kernel: audit: type=1400 audit(1486987120.812:38): apparmor="ALLOWED" operation="open" profile="/usr/sbin/sssd" name="/sys/devices/virtual/net/tun0/type" pid=1570 co
mm="sssd" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
feb 13 13:58:40 ul001541 audit[1570]: AVC apparmor="ALLOWED" operation="open" profile="/usr/sbin/sssd" name="/sys/devices/virtual/net/tun0/type" pid=1570 comm="sssd" requested_mask="r" denie
d_mask="r" fsuid=0 ouid=0
feb 13 13:58:40 ul001541 NetworkManager[1410]: <info> [1486987120.8191] devices added (path: /sys/devices/virtual/net/tun0, iface: tun0)
feb 13 13:58:40 ul001541 NetworkManager[1410]: <info> [1486987120.8191] device added (path: /sys/devices/virtual/net/tun0, iface: tun0): no ifupdown configuration found.
feb 13 13:58:40 ul001541 acvpnagent[2236]: A new network interface has been detected.
feb 13 13:58:40 ul001541 NetworkManager[1410]: <info> [1486987120.8194] device (tun0): state change: unmanaged -> unavailable (reason 'connection-assumed') [10 20 41]
feb 13 13:58:40 ul001541 acvpnagent[2236]: Function: logInterfaces File: ../../vpn/AgentUtilities/Routing/InterfaceRouteMonitorCommon.cpp Line: 477 IP Address Interface List: 10.33.79.122 10
.34.96.46 10.255.254.4 FE80:0:0:0:B9D9:E3E:F65B:4C83 FE80:0:0:0:4EEB:42FF:FEEF:FD0D
feb 13 13:58:40 ul001541 acvpnagent[2236]: Function: netInterfaceNoticeCategoryHandler File: ../../vpn/Agent/MainThread.cpp Line: 7695 Network Interface change detected, refreshing physical
MAC addresses
feb 13 13:58:40 ul001541 NetworkManager[1410]: <info> [1486987120.8204] keyfile: add connection in-memory (a745dd9a-c4f0-4337-9267-8e8c5f6cd9e9,"tun0")
feb 13 13:58:40 ul001541 NetworkManager[1410]: <info> [1486987120.8209] device (tun0): state change: unavailable -> disconnected (reason 'connection-assumed') [20 30 41]
feb 13 13:58:40 ul001541 NetworkManager[1410]: <info> [1486987120.8218] device (tun0): Activation: starting connection 'tun0' (a745dd9a-c4f0-4337-9267-8e8c5f6cd9e9)
feb 13 13:58:40 ul001541 NetworkManager[1410]: <info> [1486987120.8298] device (tun0): state change: disconnected -> prepare (reason 'none') [30 40 0]
feb 13 13:58:40 ul001541 NetworkManager[1410]: <info> [1486987120.8305] device (tun0): state change: prepare -> config (reason 'none') [40 50 0]
feb 13 13:58:40 ul001541 NetworkManager[1410]: <info> [1486987120.8311] device (tun0): state change: config -> ip-config (reason 'none') [50 70 0]
feb 13 13:58:40 ul001541 kernel: audit: type=1400 audit(1486987120.828:39): apparmor="ALLOWED" operation="open" profile="/usr/sbin/sssd" name="/sys/devices/virtual/net/tun0/type" pid=1570 co
mm="sssd" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
feb 13 13:58:40 ul001541 audit[1570]: AVC apparmor="ALLOWED" operation="open" profile="/usr/sbin/sssd" name="/sys/devices/virtual/net/tun0/type" pid=1570 comm="sssd" requested_mask="r" denie
d_mask="r" fsuid=0 ouid=0
feb 13 13:58:40 ul001541 NetworkManager[1410]: <info> [1486987120.8327] device (tun0): state change: ip-config -> ip-check (reason 'none') [70 80 0]
feb 13 13:58:40 ul001541 NetworkManager[1410]: <info> [1486987120.8336] device (tun0): state change: ip-check -> secondaries (reason 'none') [80 90 0]
feb 13 13:58:40 ul001541 NetworkManager[1410]: <info> [1486987120.8339] device (tun0): state change: secondaries -> activated (reason 'none') [90 100 0]
feb 13 13:58:40 ul001541 NetworkManager[1410]: <info> [1486987120.8413] device (tun0): Activation: successful, device activated.
feb 13 13:58:40 ul001541 dbus[1331]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service'
feb 13 13:58:40 ul001541 systemd[1]: Starting Network Manager Script Dispatcher Service...
-- Subject: Unit NetworkManager-dispatcher.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit NetworkManager-dispatcher.service has begun starting up.
feb 13 13:58:40 ul001541 dbus[1331]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
feb 13 13:58:40 ul001541 systemd[1]: Started Network Manager Script Dispatcher Service.
-- Subject: Unit NetworkManager-dispatcher.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit NetworkManager-dispatcher.service has finished starting up.
--
-- The start-up result is done.
feb 13 13:58:40 ul001541 nm-dispatcher[6799]: req:1 'up' [tun0]: new request (2 scripts)
feb 13 13:58:40 ul001541 nm-dispatcher[6799]: req:1 'up' [tun0]: start running ordered scripts...
feb 13 13:58:42 ul001541 systemd[1]: Reloading OpenBSD Secure Shell server.
-- Subject: Unit ssh.service has begun reloading its configuration
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit ssh.service has begun reloading its configuration
feb 13 13:58:42 ul001541 sshd[2089]: Received SIGHUP; restarting.
feb 13 13:58:42 ul001541 systemd[1]: Reloaded OpenBSD Secure Shell server.
-- Subject: Unit ssh.service has finished reloading its configuration
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit ssh.service has finished reloading its configuration
here
-- [20/1774]
-- The result is done.
feb 13 13:58:42 ul001541 sshd[2089]: Server listening on 0.0.0.0 port 22.
feb 13 13:58:42 ul001541 sshd[2089]: Server listening on :: port 22.
feb 13 13:58:42 ul001541 ntpd[2172]: Listen normally on 10 tun0 10.255.254.4:123
feb 13 13:58:42 ul001541 ntpd[2172]: new interface(s) found: waking up resolver
feb 13 13:58:42 ul001541 kernel: wlan0: deauthenticating from a0:d3:c1:a8:e0:60 by local choice (Reason: 3=DEAUTH_LEAVING)
feb 13 13:58:42 ul001541 wpa_supplicant[1627]: wlan0: CTRL-EVENT-DISCONNECTED bssid=a0:d3:c1:a8:e0:60 reason=3 locally_generated=1
feb 13 13:58:42 ul001541 avahi-daemon[1805]: Interface wlan0.IPv6 no longer relevant for mDNS.
feb 13 13:58:42 ul001541 avahi-daemon[1805]: Leaving mDNS multicast group on interface wlan0.IPv6 with address fe80::4eeb:42ff:feef:fd0d.
feb 13 13:58:42 ul001541 dhclient[4249]: receive_packet failed on wlan0: Network is down
feb 13 13:58:42 ul001541 avahi-daemon[1805]: Interface wlan0.IPv4 no longer relevant for mDNS.
feb 13 13:58:42 ul001541 NetworkManager[1410]: <info> [1486987122.5755] WiFi hardware radio set disabled
feb 13 13:58:42 ul001541 avahi-daemon[1805]: Leaving mDNS multicast group on interface wlan0.IPv4 with address 10.34.96.46.
feb 13 13:58:42 ul001541 NetworkManager[1410]: <info> [1486987122.5755] device (wlan0): state change: activated -> unavailable (reason 'none') [100 20 0]
feb 13 13:58:42 ul001541 avahi-daemon[1805]: Withdrawing address record for fe80::4eeb:42ff:feef:fd0d on wlan0.
feb 13 13:58:42 ul001541 avahi-daemon[1805]: Withdrawing address record for 10.34.96.46 on wlan0.
feb 13 13:58:42 ul001541 wpa_supplicant[1627]: rfkill: WLAN soft blocked
feb 13 13:58:42 ul001541 kernel: cfg80211: World regulatory domain updated:
feb 13 13:58:42 ul001541 kernel: cfg80211: DFS Master region: unset
feb 13 13:58:42 ul001541 kernel: cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)
feb 13 13:58:42 ul001541 kernel: cfg80211: (2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A)
feb 13 13:58:42 ul001541 kernel: cfg80211: (2457000 KHz - 2482000 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A)
feb 13 13:58:42 ul001541 kernel: cfg80211: (2474000 KHz - 2494000 KHz @ 20000 KHz), (N/A, 2000 mBm), (N/A)
feb 13 13:58:42 ul001541 kernel: cfg80211: (5170000 KHz - 5250000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (N/A)
feb 13 13:58:42 ul001541 kernel: cfg80211: (5250000 KHz - 5330000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (0 s)
feb 13 13:58:42 ul001541 kernel: cfg80211: (5490000 KHz - 5730000 KHz @ 160000 KHz), (N/A, 2000 mBm), (0 s)
feb 13 13:58:42 ul001541 kernel: cfg80211: (5735000 KHz - 5835000 KHz @ 80000 KHz), (N/A, 2000 mBm), (N/A)
feb 13 13:58:42 ul001541 kernel: cfg80211: (57240000 KHz - 63720000 KHz @ 2160000 KHz), (N/A, 0 mBm), (N/A)
feb 13 13:58:42 ul001541 wpa_supplicant[1627]: rfkill: WLAN soft blocked
feb 13 13:58:42 ul001541 systemd[1]: Starting Load/Save RF Kill Switch Status...
-- Subject: Unit systemd-rfkill.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-rfkill.service has begun starting up.
feb 13 13:58:42 ul001541 acvpnagent[2236]: A network interface has gone down.
feb 13 13:58:42 ul001541 acvpnagent[2236]: Function: logInterfaces File: ../../vpn/AgentUtilities/Routing/InterfaceRouteMonitorCommon.cpp Line: 477 IP Address Interface List: 10.33.79.122 10
.255.254.4 FE80:0:0:0:B9D9:E3E:F65B:4C83
feb 13 13:58:42 ul001541 acvpnagent[2236]: Function: netInterfaceNoticeCategoryHandler File: ../../vpn/Agent/MainThread.cpp Line: 7695 Network Interface change detected, refreshing physical
MAC addresses
feb 13 13:58:42 ul001541 wpa_supplicant[1627]: p2p-dev-wlan0: CTRL-EVENT-REGDOM-CHANGE init=CORE type=WORLD
feb 13 13:58:42 ul001541 systemd[1]: Started Load/Save RF Kill Switch Status.
-- Subject: Unit systemd-rfkill.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-rfkill.service has finished starting up.
--
-- The start-up result is done.
feb 13 13:58:42 ul001541 NetworkManager[1410]: <info> [1486987122.6082] dhcp4 (wlan0): canceled DHCP transaction, DHCP client pid 4249
feb 13 13:58:42 ul001541 NetworkManager[1410]: <info> [1486987122.6082] dhcp4 (wlan0): state changed bound -> done
feb 13 13:58:42 ul001541 NetworkManager[1410]: <info> [1486987122.6107] dns-mgr: Writing DNS information to /sbin/resolvconf
feb 13 13:58:42 ul001541 dnsmasq[1705]: setting upstream servers from DBus
feb 13 13:58:42 ul001541 dnsmasq[1705]: using nameserver 10.34.8.112#53
feb 13 13:58:42 ul001541 dnsmasq[1705]: using nameserver 131.207.136.44#53
feb 13 13:58:42 ul001541 dnsmasq[1705]: using nameserver 10.42.81.48#53
feb 13 13:58:42 ul001541 wpa_supplicant[1627]: nl80211: deinit ifname=p2p-dev-wlan0 disabled_11b_rates=0
feb 13 13:58:42 ul001541 NetworkManager[1410]: <info> [1486987122.6272] audit: op="radio-control" arg="wireless-enabled:0" pid=6930 uid=0 result="success"
feb 13 13:58:42 ul001541 NetworkManager[1410]: <info> [1486987122.6274] manager: WiFi now disabled by radio killswitch
feb 13 13:58:42 ul001541 nm-dispatcher[6799]: req:2 'down' [wlan0]: new request (2 scripts)
feb 13 13:58:42 ul001541 nm-dispatcher[6799]: req:2 'down' [wlan0]: start running ordered scripts...
feb 13 13:58:42 ul001541 wpa_supplicant[1627]: nl80211: deinit ifname=wlan0 disabled_11b_rates=0
feb 13 13:58:44 ul001541 ntpd[2172]: Deleting interface #8 wlan0, 10.34.96.46#123, interface stats: received=0, sent=0, dropped=0, active_time=66 secs
feb 13 13:58:44 ul001541 ntpd[2172]: Deleting interface #9 wlan0, fe80::4eeb:42ff:feef:fd0d%3#123, interface stats: received=0, sent=0, dropped=0, active_time=66 secs