ipsec 虚拟网卡模式

113 天前
 huangya

最近在 openwrt 上安装了某 ipsec 插件[1].发现此 ipsec 的实现方式是基于 linux tun 虚拟接口的。

root@OpenWrt:~# ip tuntap

ipsec0: tun

root@OpenWrt:~# ifconfig ipsec0

ipsec0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00

      inet addr:192.168.6.1  P-t-P:192.168.6.1  Mask:255.255.255.0
      inet6 addr: fe80::953b:92c0:5f2c:582/64 Scope:Link
      UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1400  Metric:1
      RX packets:0 errors:0 dropped:0 overruns:0 frame:0
      TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:500
      RX bytes:0 (0.0 B)  TX bytes:304 (304.0 B)
      

这个与我以前认知的不太一样。我以前的认知是 ipsec 基于物理网卡的。这种虚拟接口的 ipsec 实现方式有什么学名吗?是不是主要用于没有公网 ip 的场景?虚拟接口的方式是不是性能会下降很多?我看包是基于 udp 的。假设物理网卡收到了一个加密的包,是不是收到的包先要从物理网卡传到用户进程,然后在用户进程进行解密,然后再往虚拟接口送?如果是这样,有点像 openvpn 了。

[1]https://github.com/Lienol/openwrt-package/tree/main/luci-app-ipsec-server

937 次点击
所在节点    宽带症候群
6 条回复
fortitudeZDY
113 天前
应该是 policy based 和 route based 两种吧,你这种应该后者,可以通过路由指到 ipsec 接口,但是这个 tun 接口感觉性能应该不怎么行
huangya
113 天前
@fortitudeZDY 是由什么配置参数导致的吗
mantouboji
113 天前
玩 wireguard 吧,ipsec 这种东西有点儿过时了。
RecursiveG
113 天前
L2TP/IPsec
HawkinsSherpherd
113 天前
传输模式和隧道模式的区别,但我不建议直接用 IPSec 隧道,它不支持组播,跑不了 OSPF 之类的协议。
IPSec 配置好鬼麻烦,我建议要是设备都支持的话选择 Tinc 或 Wireguard ,配置简单。
huangya
112 天前
@fortitudeZDY 搞清楚了,我现在用的确实是属于 router based 的一种。参考[1]. 并且确实是用户态实现的。

Based on our own userland IPsec implementation and the kernel-libipsec plugin it is possible to create route-based VPNs with TUN devices. Similar to VTI devices or XFRM interfaces the negotiated IPsec policies have to match the traffic routed via TUN device. In particular because packets have to be copied between kernel and userland it is not as efficient as the solutions above (also read the notes on kernel-libipsec).

[1]https://docs.strongswan.org/docs/5.9/features/routeBasedVpn.html

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1009285

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX