-
Notifications
You must be signed in to change notification settings - Fork 1
/
bird_single.conf
104 lines (90 loc) · 2.52 KB
/
bird_single.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
log syslog all;
debug protocols all;
# 可以采用隧道地址,也可以采用路由所在的IP,在自己的网段内且不重复即可
router id 172.16.4.254;
# 分表,给后期的其他配置留一点回旋的余地
ipv4 table BGP_table;
protocol device{
}
# 从 master4 导出所有路由表到 kernel
protocol kernel{
ipv4 {
export all;
import none;
};
}
# 宣告 172.16.4.0/24 段
protocol static {
ipv4 {
table BGP_table;
import all;
export none;
};
# 只是为了让BGP的路由表里出现这条路由,不要担心 reject
# 这个动作其实无所谓,reject 这个动作并不会被发到其他 AS
# 后续将在导出到 master4 的时候删除这条路由,本地也不会有这一条
# 请修改为你自己要宣告的段
route 172.16.4.0/24 reject;
}
roa4 table dn11_roa4;
protocol static DN11_ROA4 {
roa4 { table dn11_roa4; };
include "/etc/bird/dn11/dn11_roa_bird2.conf";
}
# 定义BGP模板
template bgp BGP_peers {
# 修改为隧道地址和你的ASN
local 172.16.4.254 as 4220084444;
hold time 60;
keepalive time 20;
ipv4 {
table BGP_table;
import filter{
if roa_check(dn11_roa4, net, bgp_path.last) !~ [ROA_VALID, ROA_UNKNOWN] then {
print "[DN11] ROA check failed for ", net, " ASN ", bgp_path.last;
reject;
}
accept;
};
export filter {
if source ~ [RTS_STATIC, RTS_BGP] then accept;
reject;
};
};
}
# 从 BGP_table 导入路由到 master4
protocol pipe {
table master4;
peer table BGP_table;
import filter {
# 过滤 protocol static 添加的 reject
if source = RTS_STATIC then reject;
krt_prefsrc=172.16.4.6;
accept;
};
export none;
}
protocol bgp collect_self {
# 修改为你的ASN
local as 4220084444;
neighbor 172.16.255.1 as 4211110101;
multihop;
ipv4 {
add paths tx;
# 修改为你的 BGP Table
table BGP_table;
import none;
# 如果你使用 protocol static 宣告网段无需修改
# 如果你使用重分发,自行修改过滤规则
export filter {
if source ~ [RTS_BGP,RTS_STATIC] then accept;
reject;
};
};
}
# 从模板定义一个BGP邻居
# protocol bgp protocol名称 from 模板名称
protocol bgp hakuya from BGP_peers {
# 对端隧道地址%接口 as ASN
neighbor 172.16.0.254%hakuya as 4220081919;
}