mirkrotik

看好多文章都是用的vultr服务器拉取bgp路由,这就是需要有vultr服务器,那是否有直接本地拉取bgp然后推送到ros呢。找了一下发现有gobgp或者bgpd-rs,以下实例用gobgp实现,过墙用的dae

# debian12安装 
apt install -y gobgpd bgpq4
# ros ip 为192.168.1.1 debian12 ip我为192.168.11.1
# ros添加bgp互联
/routing bgp connection
add address-families=ip as=65501 disabled=no local.address=192.168.1.1 .role=ebgp multihop=yes name=gobgp \
    remote.address=192.168.11.1/32 .as=65111 router-id=192.168.1.1 routing-table=main
# bgpd添加配置
vi /etc/gobgp.toml
[global.config]
  as = 65111  # 本地AS号
  router-id = "192.168.11.1"
  local-address-list = ["192.168.11.1"]

[[neighbors]]
  [neighbors.config]
    neighbor-address = "192.168.1.1"  # 对端BGP邻居IP
    peer-as = 65501  # 对端AS号
  [neighbors.transport.config]
        local-address = "192.168.11.1"
  [neighbors.timers.config]
    connect-retry = 5  # 单位是秒
    hold-time = 180      # 单位是秒
    keepalive-interval = 60  # 单位是秒
  [neighbors.ebgp-multihop.config]
    enabled = true
    multihop-ttl = 5  # 设置 TTL 为 5,适用于较短距离的多跳连接

# 启动    
sudo systemctl start gobgpd.service

# 如果调试
sudo -E gobgpd -f /etc/gobgpd.conf -l debug 
# 查看全局路由表
gobgp global rib
# 手动添加一条路由看是否能宣告成功 nexthop 192.168.1.251 指定网关比如可以指定代理的机器网关
gobgp global rib add -a ipv4 10.11.0.0/24 nexthop 192.168.1.251 community 65001:60134
# 如果上面测试成功,接下来就是拉取asn推送到ros 收集中国的路由刷入到gobgp中写一个脚本每天获取即可
bgpq4 -F "gobgp global rib add %n/%l community 65001:4808 -a ipv4\n" as4808
# 然后ros可以设置过滤规则设置网关 示例如下
/routing filter rule
add chain=myChain disabled=no rule=\
    "if ( protocol  bgp ) {set gw 192.168.11.1; accept} else {set distance -1; accept}"