Hi,
This is an Example of Associating BGP with BFD.
Description
SwitchA belongs to AS 100, 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 with the primary link SwitchA→SwitchB. The link SwitchA→SwitchC→SwitchB functions as the backup link. Fast fault detection is required to allow traffic to be fast switched from the primary link to the backup link.

Procedure
Configure VLANs that interfaces belong to.
<HUAWEI> system-view
[HUAWEI] sysname SwitchA
[SwitchA] vlan batch 10 20
[SwitchA] interface gigabitethernet 1/0/0
[SwitchA-GigabitEthernet1/0/0] port link-type trunk
[SwitchA-GigabitEthernet1/0/0] port trunk allow-pass vlan 10
[SwitchA-GigabitEthernet1/0/0] quit
[SwitchA] interface gigabitethernet 2/0/0
[SwitchA-GigabitEthernet2/0/0] port link-type trunk
[SwitchA-GigabitEthernet2/0/0] port trunk allow-pass vlan 20
[SwitchA-GigabitEthernet2/0/0] quitThe configurations of SwitchB and SwitchC are similar to the configuration of SwitchA, and are not mentioned here.
Assign an IP address to each VLANIF interface.
[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] quitThe configurations of SwitchB and SwitchC are similar to the configuration of SwitchA, and are not mentioned here.
Configure basic BGP functions. Establish EBGP peer relationships between Switch A and Switch B, and between Switch A and Switch C and an IBGP peer relationship between Switch B and Switch C.
# Configure Switch A.
[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.1.2 ebgp-max-hop
[SwitchA-bgp] peer 192.168.2.2 as-number 200
[SwitchA-bgp] peer 192.168.2.2 ebgp-max-hop
[SwitchA-bgp] quit# Configure Switch B.
[SwitchB] bgp 200
[SwitchB-bgp] router-id 172.17.2.2
[SwitchB-bgp] peer 192.168.1.1 as-number 100
[SwitchB-bgp] peer 192.168.1.1 ebgp-max-hop
[SwitchB-bgp] peer 10.1.1.2 as-number 200
[SwitchB-bgp] network 172.16.1.0 255.255.255.0
[SwitchB-bgp] quit# Configure Switch C.
[SwitchC] bgp 200
[SwitchC-bgp] router-id 172.17.3.3
[SwitchC-bgp] peer 192.168.2.1 as-number 100
[SwitchC-bgp] peer 192.168.2.1 ebgp-max-hop
[SwitchC-bgp] peer 10.1.1.1 as-number 200
[SwitchC-bgp] import-route direct
[SwitchC-bgp] quit# Check the status of BGP peer relationships on Switch A. The command output shows that the BGP peer relationships are in the Established state.
[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
Set the MED.
Set the MED sent from SwitchB to SwitchC through the policy.
# Configure SwitchB.
[SwitchB] route-policy 10 permit node 10
[SwitchB-route-policy] apply cost 100
[SwitchB-route-policy] quit
[SwitchB] bgp 200
[SwitchB-bgp] peer 192.168.1.1 route-policy 10 export
[SwitchB-bgp] quit# Configure SwitchC.
[SwitchC] route-policy 10 permit node 10
[SwitchC-route-policy] apply cost 150
[SwitchC-route-policy] quit
[SwitchC] bgp 200
[SwitchC-bgp] peer 192.168.2.1 route-policy 10 export
[SwitchC-bgp] quit# 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?According to the BGP routing table, the next hop address of the route destined for 172.16.1.0/24 is 192.168.1.2 and service flow is transmitted on the active link SwitchA → SwitchB.
Configure BFD, and set the interval for transmitting BFD packets, the interval for receiving BFD packets, and the local detection multiplier.
# Enable BFD on Switch A. Set the minimum intervals for transmitting and receiving BFD packets to 100 ms and the local detection multiplier to 4.
[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 100 min-rx-interval 100 detect-multiplier 4
[SwitchA-bgp] quit# Enable BFD on Switch B. Set the minimum intervals for transmitting and receiving BFD packets to 100 ms and the local detection multiplier to 4.
[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 100 min-rx-interval 100 detect-multiplier 4
[SwitchB-bgp] quit# Display all BFD sessions on Switch A.
[SwitchA] display bgp bfd session all
Local_Address Peer_Address LD/RD Interface
192.168.1.1 192.168.1.2 8201/8201 Vlanif20
Tx-interval(ms) Rx-interval(ms) Multiplier Session-State
100 100 4 Up
Wtr-interval(m)
0
Verify the configuration.
# Run the shutdown command on VLANIF20 of SwitchB to simulate faults on the active link.
[SwitchB] interface vlanif 20
[SwitchB-Vlanif20] shutdown# Check the BGP routing table 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: 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?According to the BGP routing table, the standby link SwitchA → SwitchC → SwitchB takes effect after the active link fails. The next hop address of the route destined for 172.16.1.0/24 becomes 192.168.2.2.
Configuration Files
Configuration file of SwitchA
#
sysname SwitchA
#
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 GigabitEthernet1/0/0
port link-type trunk
port trunk allow-pass vlan 10
#
interface GigabitEthernet2/0/0
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 ebgp-max-hop 255
peer 192.168.1.2 bfd min-tx-interval 100 min-rx-interval 100 detect-multiplier 4
peer 192.168.1.2 bfd enable
peer 192.168.2.2 as-number 200
peer 192.168.2.2 ebgp-max-hop 255
#
ipv4-family unicast
undo synchronization
peer 192.168.1.2 enable
peer 192.168.2.2 enable
#
return configuration file of SwitchB
#
sysname SwitchB
#
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 GigabitEthernet1/0/0
port link-type trunk
port trunk allow-pass vlan 30
#
interface GigabitEthernet2/0/0
port link-type trunk
port trunk allow-pass vlan 20
#
interface GigabitEthernet3/0/0
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 ebgp-max-hop 255
peer 192.168.1.1 bfd min-tx-interval 100 min-rx-interval 100 detect-multiplier 4
peer 192.168.1.1 bfd enable
#
ipv4-family unicast
undo synchronization
network 172.16.1.0 255.255.255.0
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
#
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 GigabitEthernet1/0/0
port link-type trunk
port trunk allow-pass vlan 10
#
interface GigabitEthernet2/0/0
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
peer 192.168.2.1 ebgp-max-hop 255
#
ipv4-family unicast
undo synchronization
import-route direct
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

