前言
比起国内发一份全表,咱其实更愿意伪造一份国内的全表。
使用bgpq4 定期对国内的ASN拉一个IP List,然后再发给路由器。
咱是使用Debian+FRRouting作为网关路由器的,但是因为写太多静态路由太不优雅了。所以就单独起一个GoBGP用BGP协议和Community发过来。
FRRouting配置
下面配置并不算完善,各位有兴趣可以继续完善,但是基本够用,或者需要特别调路由
#Community
!
bgp community-list standard CMCC seq 5 permit 65535:9808
bgp community-list standard CMCC seq 10 permit 65535:9394
bgp community-list standard CT seq 5 permit 65535:4812
bgp community-list standard CU seq 5 permit 65535:4808
bgp community-list standard CU seq 10 permit 65535:4837
!
!
route-map GoBGP:3C:In permit 100
match community CT any
set ip next-hop 192.168.99.101
exit
!
route-map GoBGP:3C:In permit 105
match community CU any
set ip next-hop 192.168.99.102
exit
!
#例如配置走家宽还是商宽 MED设置
route-map GoBGP:3C:In permit 110
match community CMCC any
match metric 500
set ip next-hop 192.168.99.103
exit
!
route-map GoBGP:3C:In permit 115
match community CMCC any
set ip next-hop 192.168.99.104
exit
!
route-map DENY deny 65535
exit
!
router bgp 65534
bgp router-id 10.0.0.34
no bgp default ipv4-unicast
neighbor 192.168.66.253 remote-as 65535
neighbor 192.168.66.253 update-source 192.168.66.254
!
address-family ipv4 unicast
neighbor 192.168.66.253 activate
neighbor 192.168.66.253 route-map GoBGP:3C:In in
neighbor 192.168.66.253 route-map DENY out
exit-address-family
exit
GoBGP
如何刷写路由
# 例如联通
bgpq4 -F "gobgp global rib add %n/%l community 65535:4808 -a ipv4\n" as4808
邻居配置
/etc/gobgpd/gobgpd.conf
[global.config]
as = 65535
router-id = "192.168.66.253"
[[neighbors]]
[neighbors.config]
neighbor-address = "192.168.66.254"
peer-as = 65534
安装
看官方文档
后语
针对某个IP如果需要都走这些当然也可以用FRRouting的pbr调,也非常好用。
这篇文章记录的Community和ASN并不全,但是这样可以结合两个功能,使用FRRouting的route-map调整路由,然后如果你有一定的开发能力,利用GoBGP的接口动态的添加删除指定路由发给FRRouting实现更舒服的调度也是一个好的尝试。
FRRouting说了那么多年的好用的接口至今没实装,唉,-c太痛苦了
YF