1.组网需求

  Switch A、Switch B、Switch C和Switch D通过BGP协议实现网络互连。要求链路B正常时,Switch A和Switch D之间的流量通过链路B转发;链路B出现故障时,流量可以快速切换到链路A上。

  

 2.配置步骤

  1)在AS 200内配置OSPF,发布接口地址所在网段的路由(包括Loopback接口),确保Switch B、Switch C和Switch D之间路由可达(略)

  2) 配置BGP连接

# 配置Switch A分别与Switch B和Switch C建立EBGP会话,并配置通过BGP发布路由1.1.1.1/32。
[SwitchA] bgp 100
[SwitchA-bgp-default] router-id 1.1.1.1
[SwitchA-bgp-default] peer 10.1.1.2 as-number 200
[SwitchA-bgp-default] peer 30.1.1.3 as-number 200
[SwitchA-bgp-default] address-family ipv4 unicast
[SwitchA-bgp-default-ipv4] peer 10.1.1.2 enable
[SwitchA-bgp-default-ipv4] peer 30.1.1.3 enable
[SwitchA-bgp-default-ipv4] network 1.1.1.1 32
# 配置Switch B与Switch A建立EBGP会话,与Switch D建立IBGP会话。
[SwitchB] bgp 200
[SwitchB-bgp-default] router-id 2.2.2.2
[SwitchB-bgp-default] peer 10.1.1.1 as-number 100
[SwitchB-bgp-default] peer 4.4.4.4 as-number 200
[SwitchB-bgp-default] peer 4.4.4.4 connect-interface loopback 0
[SwitchB-bgp-default] address-family ipv4 unicast
[SwitchB-bgp-default-ipv4] peer 10.1.1.1 enable
[SwitchB-bgp-default-ipv4] peer 4.4.4.4 enable
[SwitchB-bgp-default-ipv4] peer 4.4.4.4 next-hop-local
# 配置Switch C与Switch A建立EBGP会话,与Switch D建立IBGP会话。
[SwitchC] bgp 200
[SwitchC-bgp-default] router-id 3.3.3.3
[SwitchC-bgp-default] peer 30.1.1.1 as-number 100
[SwitchC-bgp-default] peer 4.4.4.4 as-number 200
[SwitchC-bgp-default] peer 4.4.4.4 connect-interface loopback 0
[SwitchC-bgp-default] address-family ipv4 unicast
[SwitchC-bgp-default-ipv4] peer 30.1.1.1 enable
[SwitchC-bgp-default-ipv4] peer 4.4.4.4 enable
[SwitchC-bgp-default-ipv4] peer 4.4.4.4 next-hop-local
# 配置Switch D分别与Switch B和Switch C建立IBGP会话,并配置BGP发布路由4.4.4.4/32。
[SwitchD] bgp 200
[SwitchD-bgp-default] router-id 4.4.4.4
[SwitchD-bgp-default] peer 2.2.2.2 as-number 200
[SwitchD-bgp-default] peer 2.2.2.2 connect-interface loopback 0
[SwitchD-bgp-default] peer 3.3.3.3 as-number 200
[SwitchD-bgp-default] peer 3.3.3.3 connect-interface loopback 0
[SwitchD-bgp-default] address-family ipv4 unicast
[SwitchD-bgp-default-ipv4] peer 2.2.2.2 enable
[SwitchD-bgp-default-ipv4] peer 3.3.3.3 enable
[SwitchD-bgp-default-ipv4] network 4.4.4.4 32

  3)修改路由的首选值,使得Switch A和Switch D之间的流量优先通过链路B转发

# 在Switch A上配置从Switch B接收到的路由的首选值为100。
[SwitchA-bgp-default-ipv4] peer 10.1.1.2 preferred-value 100

# 在Switch D上配置从Switch B接收到的路由的首选值为100。
[SwitchD-bgp-default-ipv4] peer 2.2.2.2 preferred-value 100

  4) 配置BGP快速重路由

# 配置Switch A:配置通过Echo方式的BFD会话检测主路由的下一跳是否可达,并配置BFD echo报文的源IP地址为11.1.1.1;创建路由策略frr,为路由4.4.4.4/32指定备份下一跳的地址为30.1.1.3(对等体Switch C的地址);在BGP IPv4单播地址族下应用该路由策略。
[SwitchA] bfd echo-source-ip 11.1.1.1
[SwitchA] ip prefix-list abc index 10 permit 4.4.4.4 32
[SwitchA] route-policy frr permit node 10
[SwitchA-route-policy] if-match ip address prefix-list abc
[SwitchA-route-policy] apply fast-reroute backup-nexthop 30.1.1.3
[SwitchA-route-policy] quit
[SwitchA] bgp 100
[SwitchA-bgp-default] primary-path-detect bfd echo
[SwitchA-bgp-default] address-family ipv4 unicast
[SwitchA-bgp-default-ipv4] fast-reroute route-policy frr
# 配置Switch D:配置通过Echo方式的BFD会话检测主路由的下一跳是否可达,并配置BFD echo报文的源IP地址为44.1.1.1;创建路由策略frr,为路由1.1.1.1/32指定备份下一跳的地址为3.3.3.3(对等体Switch C的地址);在BGP IPv4单播地址族下应用该路由策略。
[SwitchD] bfd echo-source-ip 44.1.1.1
[SwitchD] ip prefix-list abc index 10 permit 1.1.1.1 32
[SwitchD] route-policy frr permit node 10
[SwitchD-route-policy] if-match ip address prefix-list abc
[SwitchD-route-policy] apply fast-reroute backup-nexthop 3.3.3.3
[SwitchD-route-policy] quit
[SwitchD] bgp 200
[SwitchD-bgp-default] primary-path-detect bfd echo
[SwitchD-bgp-default] address-family ipv4 unicast
[SwitchD-bgp-default-ipv4] fast-reroute route-policy frr

3.验证配置

# 在Switch A上查看4.4.4.4/32路由,可以看到备份下一跳信息。
[SwitchA] display ip routing-table 4.4.4.4 32 verbose
Summary count : 1
Destination: 4.4.4.4/32
   Protocol: BGP             Process ID: 0
  SubProtID: 0x2                    Age: 00h01m52s
       Cost: 0               Preference: 255
      IpPre: N/A             QosLocalID: N/A
        Tag: 0                    State: Active Adv
  OrigTblID: 0x0                OrigVrf: default-vrf
    TableID: 0x2                 OrigAs: 200
      NibID: 0x15000003          LastAs: 200
     AttrID: 0x5               Neighbor: 10.1.1.2
      Flags: 0x10060        OrigNextHop: 10.1.1.2
      Label: NULL           RealNextHop: 10.1.1.2
    BkLabel: NULL             BkNextHop: 30.1.1.3
    SRLabel: NULL             BkSRLabel: NULL
   SIDIndex: NULL               InLabel: NULL
  Tunnel ID: Invalid          Interface: Vlan-interface 100
BkTunnel ID: Invalid        BkInterface: Vlan-interface 200
   FtnIndex: 0x0           TrafficIndex: N/A
  Connector: N/A                 PathID: 0x0
   LinkCost: 0               MicroSegID: 0
# 在Switch D上查看1.1.1.1/32路由,可以看到备份下一跳信息。
[SwitchD] display ip routing-table 1.1.1.1 32 verbose
Summary count : 1
Destination: 1.1.1.1/32
   Protocol: BGP             Process ID: 0
  SubProtID: 0x1                    Age: 00h00m36s
       Cost: 0               Preference: 255
      IpPre: N/A             QosLocalID: N/A
        Tag: 0                    State: Active Adv
  OrigTblID: 0x0                OrigVrf: default-vrf
    TableID: 0x2                 OrigAs: 100
      NibID: 0x15000003          LastAs: 100
     AttrID: 0x1               Neighbor: 2.2.2.2
      Flags: 0x10060        OrigNextHop: 2.2.2.2
      Label: NULL           RealNextHop: 20.1.1.2
    BkLabel: NULL             BkNextHop: 40.1.1.3
    SRLabel: NULL             BkSRLabel: NULL
   SIDIndex: NULL               InLabel: NULL
  Tunnel ID: Invalid          Interface: Vlan-interface 101
BkTunnel ID: Invalid        BkInterface: Vlan-interface 201
   FtnIndex: 0x0           TrafficIndex: N/A
  Connector: N/A                 PathID: 0x0
   LinkCost: 0               MicroSegID: 0

 

posted on 2022-01-14 12:11  星痕1216  阅读(470)  评论(0编辑  收藏  举报