RR 反射路由无法修改属性
2025/12/11BGP 常见问题7.X.X大约 3 分钟
RR 反射路由无法修改属性
网络环境
Hub 与 Spoke 在同一个 AS 65000 内:
- Hub:作为 BGP Route Reflector,IP 为
169.254.10.254。 - Spoke1:Hub 的 iBGP 邻居,IP 为
169.254.10.1。 - Spoke2:Hub 的 iBGP 邻居,IP 为
169.254.10.2。 - Hub 通过 BGP 通告
10.10.254.0/24网段。 - Spoke1 向 Hub 通告前缀
10.10.1.0/24,Hub 通过 RR 将10.10.1.0/24反射给 Spoke2。 - Hub 上对发往 Spoke2 的方向配置了
route-map-out,意图修改自身发布和反射给 Spoke2 的路由的 Local Preference。
问题现象
Spoke1 向 Hub 通告网段:
10.10.1.0/24。Hub 作为 Route Reflector 的 BGP 配置如下。Hub 对 Spoke2 的出站 route-map 用于试图修改通告/反射到 Spoke2 的路由的 Local Preference 为 500。
config router route-map edit "Hub-RM_Spoke2-OUTBOUND" config rule edit 1 set set-local-preference 500 next end next end config router bgp set as 65000 config neighbor edit "169.254.10.1" <----Spoke1 IP set remote-as 65000 set route-reflector-client enable next edit "169.254.10.2" <----Spoke2 IP set remote-as 65000 set route-map-out "Hub-RM_Spoke2-OUTBOUND" set route-reflector-client enable next end config network edit 1 set prefix 10.10.254.0 255.255.255.0 <----Hub 发布到 BGP 的网段 next end endHub 从 Spoke1 学到的 BGP 路由
10.10.1.0/24,LocPrf为 100。Hub # get router info bgp neighbors 169.254.10.1 routes VRF 0 BGP table version is 44, local router ID is 10.255.255.1 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric `LocPrf` Weight RouteTag Path * >i10.10.1.0/24 169.254.10.1 0 100 0 0 i <----由Spoke1发布并安装在Hub的路由由于 Hub 被配置为 Route Reflector,它会将从 Spoke1 学到的路由
10.10.1.0/24反射给 Spoke2,同时也会把自己发布的路由10.10.254.0/24一并通告。这里可以看到发送给 Spoke2 的 2 条路由中,只有 Hub 自身发布的路由LocPrf被改为 500,反射的路由仍然为 100。Hub # get router info bgp neighbors 169.254.10.2 advertised-routes VRF 0 BGP table version is 44, local router ID is 10.255.255.1 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric `LocPrf` Weight RouteTag Path * >i10.10.1.0/24 169.254.10.1 100 0 0 i <----Spoke1发布被Hub反射路由 * >i10.10.254.0/24 169.254.10.254 500 32768 0 i <----Hub自身发布的路由 Total number of prefixes 2在 Spoke2 上查看来自 Hub(
169.254.10.254)的路由,可以看到 2 条前缀,Hub 发布的路由的LocPrf被修改为 500,但反射的 Spoke1 的路由LocPrf没有被改变,仍然为 100。Spoke2 # get router info bgp neighbors 169.254.10.254 received-routes VRF 0 BGP table version is 16, local router ID is 10.255.255.30 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric `LocPrf` Weight RouteTag Path * >i10.10.1.0/24 169.254.10.1 0 100 0 0 i <----Spoke1发布的反射路由 * >i10.10.254.0/24 169.254.10.254 0 500 0 0 i <----Hub自身发布的路由 Total number of prefixes 2
问题原因
- BGP Route Reflection 由 RFC 4456 定义,Route Reflector 会将从 IBGP peer 学到的前缀通告给所有 route-reflector clients。
- 按 RFC 4456 第 10 节的建议,Route Reflector 不应修改反射路由的,也就是说,对反射路由不会应用
route-map-out中的属性修改:- NEXT_HOP
- AS_PATH
- LOCAL_PREF
- MED(metric)
- community
总结
- 当 FortiGate 作为 Route Reflector 时,
route-map-out不会修改反射路由的属性。 - 在以上示例中,只有 Hub 自己通过
network注入的10.10.254.0/24被成功改写 Local Preference。 - 来自 Spoke1 的
10.10.1.0/24作为反射路由,其 Local Preference 保持不变。
解决方法
若希望在 Spoke1 → Spoke2 经过 Hub 反射的路径上对 BGP 属性进行调整,可以在以下任一位置进行修改:
- Spoke1 的 route-map-out to Hub。
- Hub 的 route-map-in from Spoke1。
- Spoke2 的 route-map-in from Hub。
- 在 Hub 上开启
next-hop-self-rr,可以将反射路由的 NEXT_HOP 修改为 Hub 自身地址(详情参考:路由 → 动态路由 → BGP → 路由反射器章节)。