FRR BGP 基础命令配置

说明

前面了解了BGP基础概念,下面搭建简单的BGP实验场景,基于遇到的测试用例记录BGP不同测试场景下的配置方法。在FRR源码中 tests/topotests 目录下存在很多经典的场景配置,对路由网络有一定了解可以直接参考topotests下配置即可。本文主要记录学习BGP时从刚开始接触到慢慢了解的过程,后续会持续补充遇到的各种场景配置。

BGP相关命令都是基于FRR,基础网络配置使用系统命令,数据面也涉及VPP相关命令。

测试拓扑:

BGP基础

查询命令

#已有配置
do show running-config

#BGP邻居详细信息
do show bgp neighbors

#BGP概要信息
do show bgp summary

#BGP ipv4/6所有地址族
do show bgp ipv4 all
do show bgp ipv6 all

#BGP基于vrf的router信息
do show bgp vrfs

#BGP所有vrf信息
do show bgp vrf all

#内核路由表,包括vrf
do show ip route vrf all

创建IBGP邻居

BGP创建邻居前提要求,配置的neighbor IP L3互通。

R1

router bgp 1000
 neighbor 192.168.55.105 remote-as 1000
或者
 neighbor 192.168.55.105 remote-as internal

R2

router bgp 1000
 neighbor 192.168.55.103 remote-as 1000
或者
 neighbor 192.168.55.103 remote-as internal

创建EBGP邻居

创建EBGP邻居,需要配置ebgp-multihop才能配置成功。

R1

router bgp 56
 neighbor 192.168.55.105 remote-as 65
 neighbor 192.168.55.105 ebgp-multihop 255

R2

router bgp 65
 neighbor 192.168.55.103 remote-as 56
 neighbor 192.168.55.103 ebgp-multihop 255

创建BGP邻居-IPV6

R1和R2分别在2个虚拟机上,虚拟机的enp1s0是虚拟网卡,通过宿主机上br进行了桥接。要创建IPV6 BGP邻居也是要保证IPV6 L3通,所以虚拟机网桥virbr1要先支持IPV6转发。

宿主机

sysctl net.ipv6.conf.virbr1.disable_ipv6=0
ip addr add 2001:db8:55::1/64 dev virbr1

R1

interface enp1s0
 ip address 192.168.55.103/24
 ipv6 address 2001:db8:55::103/64

router bgp 1000
 neighbor 2001:db8:55::105 remote-as 1000

R2

interface enp1s0
 ip address 192.168.55.105/24
 ipv6 address 2001:db8:55::105/64
 
router bgp 1000
 neighbor 2001:db8:55::103 remote-as 1000

引入BGP路由

前提:BGP邻居已建立

想要引入IPV6 路由,邻居双方需要都在address-family ipv6 unicast下激活邻居,IPV4 单播AF下是默认激活的,所以不需要配置。

R1

router bgp 1000
 neighbor 2001:db8:55::105 remote-as 1000
 !
 address-family ipv4 unicast
  network 1.1.1.1/32
 exit-address-family
 !
 address-family ipv6 unicast
  network 1000:5:102::/64
  neighbor 2001:db8:55::105 activate
 exit-address-family
exit

R2

router bgp 1000
 neighbor 2001:db8:55::103 remote-as 1000
 !
 address-family ipv6 unicast
  neighbor 2001:db8:55::103 activate
 exit-address-family
exit

路由映射表 route-map

route-map即路由映射表,是由一组match字句和set字句构成,他实际上是访问控制列表的一个超集。主要功能包括路由控制和策略路由等。详细不展开了,请参考 BGP route-map理解

R1

router bgp 1000
 neighbor 2001:db8:55::105 remote-as 1000
 !
 address-family ipv4 unicast
  network 1.1.1.1/32 route-map rqw-rm
 exit-address-family
exit
!
ip prefix-list rqw-pl seq 100 permit 1.1.1.1/32
!
route-map rqw-rm permit 10
 match ip address prefix-list rqw-pl
exit

R2

router bgp 1000
 neighbor 2001:db8:55::103 remote-as 1000
exit

路由权重 weight

路由权重的设置只影响本端收到BGP邻居同步过来的路由,常用于本端访问目标网络存在多条路由时的路由选路。详细可以参考BGP-路径属性与选路原则

R1

router bgp 1000
 neighbor 192.168.55.105 remote-as 1000
 !
 address-family ipv6 unicast
  network 1001:5::/32
  neighbor 192.168.55.105 activate
 exit-address-family
exit

R2

router bgp 1000
 neighbor 192.168.55.103 remote-as 1000
 !
 address-family ipv6 unicast
  neighbor 192.168.55.103 activate
  neighbor 192.168.55.103 weight 6666
 exit-address-family
exit

VRF 实例

TODO

BGP拓展

L2VPN EVPN

TODO

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
根据提供的引用内容,我们可以了解到BGP是一种路由协议,而静态路由则是手动配置的路由。因此,FRR BGP配置静态路由需要先配置静态路由,然后再将其与BGP协议结合起来。具体步骤如下: 1. 配置静态路由。可以使用以下命令配置静态路由: ```shell ip route add <destination_network>/<netmask> via <next_hop_ip_address> ``` 其中,`<destination_network>/<netmask>`表示目标网络和子网掩码,`<next_hop_ip_address>`表示下一跳IP地址。例如,要将目标网络`192.168.1.0/24`的流量发送到下一跳IP地址`10.0.0.1`,可以使用以下命令: ```shell ip route add 192.168.1.0/24 via 10.0.0.1 ``` 2. 配置BGP协议。可以使用以下命令配置BGP协议: ```shell router bgp <local_as_number> neighbor <neighbor_ip_address> remote-as <remote_as_number> network <local_network> ``` 其中,`<local_as_number>`表示本地AS号,`<neighbor_ip_address>`表示******本地网络设置为`192.168.1.0/24`,可以使用以下命令: ```shell router bgp 65001 neighbor 10.0.0.2 remote-as 65002 network 192.168.1.0/24 ``` 3. 将静态路由与BGP协议结合起来。可以使用以下命令将静态路由与BGP协议结合起来: ```shell router bgp <local_as_number> network <destination_network>/<netmask> route-map <route_map_name> out ``` 其中,`<destination_network>/<netmask>`表示目标网络和子网掩码,`<route_map_name>`表示路由映射名称。例如,要将目标网络`192.168.1.0/24`的流量发送到BGP邻居,可以使用以下命令: ```shell router bgp 65001 network 192.168.1.0/24 route-map static-to-bgp out ``` 在这个例子中,`static-to-bgp`是一个路由映射名称,它将静态路由转换为BGP路由。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值