起因
因为最近正在建大内网,所以打算用 Wireguard + OSPF 来内部寻路,在去年折腾了好久但是没有折腾出来解决方案。询问了身边的一些大佬得到了解决方案,所以分享出来让大家不要踩坑)
解决办法
1.AllowedIPs
OSPFv3 的邻居通信是通过 IPv6 LLA(fe80::/10
)来建立的,所以我们在 Wireguard 的 AllowedIPs 需要允许 fe80::/10
通过
[Peer]
AllowedIPs = fe80::/10
Bash2.添加 Local Link Address
Wireguard 默认是没有添加 LLA 的,我们需要手动添加 LLA 才能让 OSPFv3 通信
[Interface]
# 两边的 LLA 需要不同
PostUp = ip -6 addr add fe80::4f2a:9c1b:7d8e:2a3f/64 dev %i
PostDown = ip -6 addr del fe80::4f2a:9c1b:7d8e:2a3f/64 dev %i
Bash3.MTU
需要 MTU 相同 OSPFv3 才能工作,如果 ip a 命令显示两端接口 MTU 不一样的话需要手动压制一下
[Interface]
MTU = 1400
Bash4.PTP
我们可以在 OSPF 配置文件中添加 type ptp 这样建立邻居更快些
interface "wg0" {
cost 362;
hello 5; retransmit 2; wait 10; dead 20;
type ptp;
};
Bash
发表回复