基于 ZeroTier 的 P2P L2 互联网络
所有参与者连接到 Route Server 上交换路由信息,您只需要连接 RS,即可和所有参与者建立 Peer,无需额外维护每个参与者。RS 可能不在您路由器所在的区域,但请放心,您到 RS 的延迟不会影响您在 IX 上的实际延迟。
我们施加了额外的措施,尽量阻止超大型 ZeroTier 网络可能出现的广播风暴问题。
推荐启用 ZeroTier 低带宽模式,减少控制平面开销。配合社区标记策略与地理位置过滤,构建高效稳定的路由拓扑。
所有人必须在自己的路由上使用 (4211179999, 64511, *) Route Origin 社区标记。任何不携带该标记的路由将被直接拒绝,无法进入 RS 路由表。标记的值取决于您路由器的物理位置,定义与 dn42 社区相同,详见 dn42 wiki。
特别留意自己的路由策略,不要发全表。
curl -s https://install.zerotier.com | sudo bash
zerotier-cli join 8d0a9150472a22f5
zerotier-cli info 命令获取 ZeroTier ID。fd8d:0a91:5047:2a22:f599:930e:5be1:1576
{
"settings": {
"interfacePrefixBlacklist": ["prefixA", "prefixB"],
"lowBandwidthMode": true
}
}
填写需要屏蔽的接口前缀,避免 ZeroTier 在这些接口上发送P2P流量。
protocol bgp dn42_yuyuko_ix {
local role rs_client;
enable extended messages on;
local as <your asn>;
neighbor fd8d:0a91:5047:2a22:f599:930e:5be1:1576 as 4211179999;
ipv4 {
extended next hop on;
add paths rx;
import filter {
# Accept only routes with the required origin large community
if bgp_large_community ~ [(4211179999, 64511, ????)] then {
<your filter function>
# Strip the community to avoid leaking it to other peers
bgp_large_community.delete([(4211179999, 64511, *)]);
accept;
}
reject;
};
export filter {
if <need export> then {
<your filter function>
# Tag route with the origin community matching your location
bgp_large_community.add((4211179999, 64511, ????));
accept;
}
reject;
};
};
ipv6 {
add paths rx;
import filter {
# Accept only routes with the required origin large community
if bgp_large_community ~ [(4211179999, 64511, ????)] then {
<your filter function>
# Strip the community to avoid leaking it to other peers
bgp_large_community.delete([(4211179999, 64511, *)]);
accept;
}
reject;
};
export filter {
if <need export> then {
<your filter function>
# Tag route with the origin community matching your location
bgp_large_community.add((4211179999, 64511, ????));
accept;
}
reject;
};
};
}
your asn 替换为您的 AS 号码,need export 替换为您需要导出的网络前缀条件,your filter function 替换为您的自定义过滤函数,???? 替换为适当的社区值。