Example for Configuring BFD for BGP
Networking Requirements
As shown in Figure 9-33, SwitchA belongs to AS 100, and SwitchB and SwitchC belong to AS 200. EBGP connections are established between SwitchA and SwitchB, and between SwitchA and SwitchC.
Service traffic is transmitted along the primary link SwitchA→SwitchB. The link SwitchA→SwitchC→SwitchB functions as the backup link.
Use BFD to monitor the BGP peer relationship between SwitchA and SwitchB. When a fault occurs on the link between SwitchA and SwitchB, BFD can rapidly detect the fault and notify BGP. Then traffic is transmitted on the backup link.
Configuration Roadmap
The configuration roadmap is as follows:
Configure basic BGP functions on each switch.
Configure the MED attribute to control route selection.
Enable BFD on SwitchA and SwitchB.
Procedure
- Configure the VLAN to which each interface belongs.
<HUAWEI> system-view [~HUAWEI] sysname SwitchA [*HUAWEI] commit [~SwitchA] vlan batch 10 20 [*SwitchA] interface 10ge 1/0/1 [*SwitchA-10GE1/0/1] port link-type trunk [*SwitchA-10GE1/0/1] port trunk allow-pass vlan 10 [*SwitchA-10GE1/0/1] quit [*SwitchA] interface 10ge 1/0/2 [*SwitchA-10GE1/0/2] port link-type trunk [*SwitchA-10GE1/0/2] port trunk allow-pass vlan 20 [*SwitchA-10GE1/0/2] quit [*SwitchA] commit
The configurations of SwitchB and SwitchC are similar to the configuration of SwitchA, and are not provided here.
- Configure VLANIF interfaces and assign IP addresses to the VLANIF interfaces.
[~SwitchA] interface vlanif 10 [*SwitchA-Vlanif10] ip address 192.168.2.1 24 [*SwitchA-Vlanif10] quit [*SwitchA] interface vlanif 20 [*SwitchA-Vlanif20] ip address 192.168.1.1 24 [*SwitchA-Vlanif20] quit [*SwitchA] commit
The configurations of SwitchB and SwitchC are similar to the configuration of SwitchA, and are not provided here.
- Configure basic BGP functions, establish EBGP connections between SwitchA and SwitchB and between SwitchA and SwitchC, and establish an IBGP connection between SwitchB and SwitchC.
# Configure SwitchA.
[~SwitchA] bgp 100
[*SwitchA-bgp] router-id 172.17.1.1
[*SwitchA-bgp] peer 192.168.1.2 as-number 200
[*SwitchA-bgp] peer 192.168.2.2 as-number 200
[*SwitchA-bgp] commit
[~SwitchA-bgp] quit
# Configure SwitchB.
[~SwitchB] bgp 200
[*SwitchB-bgp] router-id 172.17.2.2
[*SwitchB-bgp] peer 192.168.1.1 as-number 100
[*SwitchB-bgp] peer 10.1.1.2 as-number 200
[*SwitchB-bgp] import-route direct
[*SwitchB-bgp] commit
[~SwitchB-bgp] quit
# Configure SwitchC.
[~SwitchC] bgp 200
[*SwitchC-bgp] router-id 172.17.3.3
[*SwitchC-bgp] peer 192.168.2.1 as-number 100
[*SwitchC-bgp] peer 10.1.1.1 as-number 200
[*SwitchC-bgp] commit
[~SwitchC-bgp] quit
# View the BGP peer status on SwitchA, finding that BGP peers have been established.
<SwitchA> display bgp peer
BGP local router ID : 172.17.1.1
Local AS number : 100
Total number of peers : 2
Peers in established state : 2
Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv
192.168.1.2 4 200 2 5 0 00:01:25 Established 0
192.168.2.2 4 200 2 4 0 00:00:55 Established 0
- Configure the MED attribute.
# Set the MED values for the routes sent from SwitchB and SwitchC to SwitchA using a route-policy.
# Configure SwitchB.
[~SwitchB] route-policy 10 permit node 10
[*SwitchB-route-policy] apply cost 100
[*SwitchB-route-policy] commit
[~SwitchB-route-policy] quit
[~SwitchB] bgp 200
[~SwitchB-bgp] peer 192.168.1.1 route-policy 10 export
[*SwitchB-bgp] commit
# Configure SwitchC.
[~SwitchC] route-policy 10 permit node 10
[*SwitchC-route-policy] apply cost 150
[*SwitchC-route-policy] commit
[~SwitchC-route-policy] quit
[~SwitchC] bgp 200
[~SwitchC-bgp] peer 192.168.2.1 route-policy 10 export
[*SwitchC-bgp] commit
# View all BGP routing information on SwitchA.
<SwitchA> display bgp routing-table
BGP Local router ID is 172.17.1.1
Status codes: * - valid, > - best, d - damped, h - history,
i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 5
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 10.1.1.0/24 192.168.2.2 150 0 200?
*> 172.16.1.0/24 192.168.1.2 100 0 200i
* 192.168.2.2 150 0 200i
*> 192.168.2.0 192.168.1.2 100 0 200?
192.168.2.2 150 0 200?
In the BGP routing table, you can view that the next-hop address of the route to 172.16.1.0/24 is 192.168.1.2, and traffic is transmitted on the primary link SwitchA→SwitchB.
- Configure BFD, and set the interval for sending BFD packets, the interval for receiving BFD packets, and the local detection multiplier.
# Enable BFD on SwitchA, and set the minimum intervals for sending and receiving BFD packets to 300 ms and the local detection multiplier to 5.
[~SwitchA] bfd
[*SwitchA-bfd] quit
[*SwitchA] bgp 100
[*SwitchA-bgp] peer 192.168.1.2 bfd enable
[*SwitchA-bgp] peer 192.168.1.2 bfd min-tx-interval 300 min-rx-interval 300 detect-multiplier 5
[*SwitchA-bgp] commit
# Enable BFD on SwitchB, and set the minimum intervals for sending and receiving BFD packets to 300 ms and the local detection multiplier to 5.
[~SwitchB] bfd
[*SwitchB-bfd] quit
[*SwitchB] bgp 200
[*SwitchB-bgp] peer 192.168.1.1 bfd enable
[*SwitchB-bgp] peer 192.168.1.1 bfd min-tx-interval 300 min-rx-interval 300 detect-multiplier 5
[*SwitchB-bgp] commit
# View all the BFD sessions set up by BGP on SwitchA.
<SwitchA> display bgp bfd session all
--------------------------------------------------------------------------------
Local_Address Peer_Address Interface
192.168.1.1 192.168.1.2 Vlanif20
Tx-interval(ms) Rx-interval(ms) Multiplier Session-State
300 300 5 Up
--------------------------------------------------------------------------------
- Verify the configuration.
# Run the shutdown command on 10GE1/0/2 of SwitchB to simulate a primary link fault.
[~SwitchB] interface 10ge 1/0/2
[~SwitchB-10GE1/0/2] shutdown
[*SwitchB-10GE1/0/2] commit
# View the BGP routing table of SwitchA.
<SwitchA> display bgp routing-table
BGP Local router ID is 172.17.1.1
Status codes: * - valid, > - best, d - damped, h - history,
i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 3
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 10.1.1.0/24 192.168.2.2 150 0 200?
*> 172.16.1.0/24 192.168.2.2 150 0 200i
192.168.2.0 192.168.2.2 150 0 200?
In the BGP routing table, you can view that the backup link SwitchA→SwitchC→SwitchB takes effect after the primary link fails, and the next-hop address of the route to 172.16.1.0/24 becomes 192.168.2.2.
Configuration Files
Configuration file of SwitchA
# sysname SwitchA # router id 172.17.1.1 # vlan batch 10 20 # bfd # interface Vlanif10 ip address 192.168.2.1 255.255.255.0 # interface Vlanif20 ip address 192.168.1.1 255.255.255.0 # interface 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 10 # interface 10GE1/0/2 port link-type trunk port trunk allow-pass vlan 20 # bgp 100 router-id 172.17.1.1 peer 192.168.1.2 as-number 200 peer 192.168.1.2 bfd min-tx-interval 300 min-rx-interval 300 detect-multiplier 5 peer 192.168.1.2 bfd enable peer 192.168.2.2 as-number 200 # ipv4-family unicast peer 192.168.1.2 enable peer 192.168.2.2 enable # return
Configuration file of SwitchB
# sysname SwitchB # router id 172.17.2.2 # vlan batch 20 30 40 # bfd # interface Vlanif20 ip address 192.168.1.2 255.255.255.0 # interface Vlanif30 ip address 10.1.1.1 255.255.255.0 # interface Vlanif40 ip address 172.16.1.1 255.255.255.0 # interface 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 30 # interface 10GE1/0/2 port link-type trunk port trunk allow-pass vlan 20 # interface 10GE1/0/3 port link-type trunk port trunk allow-pass vlan 40 # bgp 200 router-id 172.17.2.2 peer 10.1.1.2 as-number 200 peer 192.168.1.1 as-number 100 peer 192.168.1.1 bfd min-tx-interval 300 min-rx-interval 300 detect-multiplier 5 peer 192.168.1.1 bfd enable # ipv4-family unicast import-route direct peer 10.1.1.2 enable peer 192.168.1.1 enable peer 192.168.1.1 route-policy 10 export # route-policy 10 permit node 10 apply cost 100 # return
Configuration file of SwitchC
# sysname SwitchC # router id 172.17.3.3 # vlan batch 10 30 # bfd # interface Vlanif10 ip address 192.168.2.2 255.255.255.0 # interface Vlanif30 ip address 10.1.1.2 255.255.255.0 # interface 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 10 # interface 10GE1/0/2 port link-type trunk port trunk allow-pass vlan 30 # bgp 200 router-id 172.17.3.3 peer 10.1.1.1 as-number 200 peer 192.168.2.1 as-number 100 # ipv4-family unicast network 10.1.1.0 255.255.255.0 peer 10.1.1.1 enable peer 192.168.2.1 enable peer 192.168.2.1 route-policy 10 export # route-policy 10 permit node 10 apply cost 150 # return