为什么deepin直接不支持tun连接呢?
Tofloor
poster avatar
melonboy312
deepin
2017-08-31 02:49
Author
事情是这样的,我所在公司用了array_vpnc连接内网。我使用公司提供的脚本连接之后,显示连接成功,但是实际上无法ping通内网。搜了一下,发现deepin下tun连接的问题有别的朋友也反馈了,但是没有什么结果,于是我跟了一下。

首先开始连接,然后
"journalctl -n100" 看日志,发现了这么个东西:
&network.activeConnection{path:"/org/freedesktop/NetworkManager/ActiveConnection/26", typ:"", Devices:[]dbus.ObjectP
Aug 30 18:22:05 zhangzi-PC daemon/network[1239]: manager_device.go:96: ignore invalid device type 16



注意第二行,报了一个非法设备的log。
于是我去github上跟了一下这个 manager_device.go 的代码。
https://github.com/linuxdeepin/dde-daemon/blob/master/network/manager_device.go

if !isDeviceTypeValid(devType)
err = fmt.Errorf("ignore invalid device type %d", devType)
看来就是这个判断的原因了,根据上下文,发现devType这个参数是nm的一个枚举,找到nm的枚举说明:
https://people.freedesktop.org/~lkundrak/nm-docs/nm-dbus-types.html
enum NMDeviceType

NMDeviceType values indicate the type of hardware represented by a device object.

Values

NM_DEVICE_TYPE_UNKNOWN
= 0
unknown device

NM_DEVICE_TYPE_GENERIC
= 14
generic support for unrecognized device types

NM_DEVICE_TYPE_ETHERNET
= 1
a wired ethernet device

NM_DEVICE_TYPE_WIFI
= 2
an 802.11 WiFi device

NM_DEVICE_TYPE_UNUSED1
= 3
not used

NM_DEVICE_TYPE_UNUSED2
= 4
not used

NM_DEVICE_TYPE_BT
= 5
a Bluetooth device supporting PAN or DUN access protocols

NM_DEVICE_TYPE_OLPC_MESH
= 6
an OLPC XO mesh networking device

NM_DEVICE_TYPE_WIMAX
= 7
an 802.16e Mobile WiMAX broadband device

NM_DEVICE_TYPE_MODEM
= 8
a modem supporting analog telephone, CDMA/EVDO, GSM/UMTS, or LTE network access protocols

NM_DEVICE_TYPE_INFINIBAND
= 9
an IP-over-InfiniBand device

NM_DEVICE_TYPE_BOND
= 10
a bond master interface

NM_DEVICE_TYPE_VLAN
= 11
an 802.1Q VLAN interface

NM_DEVICE_TYPE_ADSL
= 12
ADSL modem

NM_DEVICE_TYPE_BRIDGE
= 13
a bridge master interface

NM_DEVICE_TYPE_TEAM
= 15
a team master interface

NM_DEVICE_TYPE_TUN
= 16
a TUN or TAP interface

NM_DEVICE_TYPE_IP_TUNNEL
= 17
a IP tunnel interface

NM_DEVICE_TYPE_MACVLAN
= 18
a MACVLAN interface

NM_DEVICE_TYPE_VXLAN
= 19
a VXLAN interface

NM_DEVICE_TYPE_VETH
= 20
a VETH interface


发现16这个枚举,正好是TUN/TAP类型····
再反过来查刚才的合法性验证方法isDeviceTypeValid,找到对应的代码:
https://github.com/linuxdeepin/dde-daemon/blob/master/network/utils_dbus_nm.go


func isDeviceTypeValid(devType uint32) bool {
        switch devType {
        case nm.NM_DEVICE_TYPE_GENERIC, nm.NM_DEVICE_TYPE_UNKNOWN, nm.NM_DEVICE_TYPE_BT, nm.NM_DEVICE_TYPE_TEAM, nm.NM_DEVICE_TYPE_TUN, nm.NM_DEVICE_TYPE_IP_TUNNEL, nm.NM_DEVICE_TYPE_MACVLAN, nm.NM_DEVICE_TYPE_VXLAN, nm.NM_DEVICE_TYPE_VETH:
                return false
        }
        return true
}
发现直接把TUN类型的连接返回false了。

这么看来,应该是deepin直接不支持tun了···
这是为啥呢···有这个必要吗···现在蛮多公司都是通过vpn来支持员工在家访问公司内网的,毕竟线上出问题的时候,随时随地都得上线修bug···,deepin的同学能帮忙支持下这个吗···
Reply Favorite View the author
All Replies
avatar
jingle
deepin
2017-08-31 04:10
#1
Reply View the author
avatar
iminto
deepin
2017-08-31 05:47
#2
本帖最后由 iminto 于 2017-8-30 21:53 编辑

楼主研究精神可嘉
  1. #确认内核是否有tun模块
  2. modinfo tun
  3. #开启模块
  4. modprobe tun
  5. lsmod | grep tun
Copy the Code
我在网上找到的文档,其中第一步看到deepin是有TUN模块的
Reply View the author
avatar
134******40
deepin
2017-08-31 05:48
#3
本帖最后由 jdocker 于 2017-8-31 12:18 编辑

我也遇到过,只是没有跟踪。
Reply View the author
avatar
wangyong
deepin
2017-08-31 18:17
#4

如果确实是代码写的有问题,转给对应的研发吧,下个版本修正
Reply View the author
avatar
yanbowen
deepin
Community Developer
2017-08-31 18:43
#5
IsDeviceTypeValid 这个函数只是过滤掉控制中心里不希望显示网络设备类型, 与 tun 类型的 vpn 能否可用没有任何关系.

另外我们公司内部也使用的是 tun 设备类型的 vpn, 连接没有问题. 所以你的 vpn 问题不是在这里.

请检查下 /etc/resolv.conf 里的配置是否正确, 使用 sudo route 看下路由表是否是期望的, 谢谢!
Reply View the author