最近在 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