Example for Configuring Static BFD for IPv4 Static Routes
Networking Requirements
As shown in Figure 2-11, you can configure the default static route on SwitchA so that SwitchA can connect to the external network. Millisecond-level link fault detection must be implemented between SwitchA and SwitchB to improve convergence speed.
Configuration Roadmap
The configuration roadmap is as follows:
Configure a BFD session between SwitchA and SwitchB.
Configure a default route from SwitchA to another device and bind a BFD session to the default route. This configuration can implement millisecond-level link fault detection and improve convergence speed of static routes.
Procedure
- Create VLANs, add interfaces to the VLANs, and assign IP addresses to the VLANIF interfaces. (Details are not provided here.)
- Configure device names. (Details are not provided here.)
- Configure a BFD session between SwitchA and SwitchB.
# Create a BFD session on SwitchA.
<SwitchA> system-view
[~SwitchA] bfd
[*SwitchA-bfd] quit
[*SwitchA] bfd aa bind peer-ip 10.1.1.2
[*SwitchA-bfd-session-aa] discriminator local 10
[*SwitchA-bfd-session-aa] discriminator remote 20
[*SwitchA-bfd-session-aa] commit
[~SwitchA-bfd-session-aa] quit
# Create a BFD session on SwitchB.
<SwitchB> system-view
[~SwitchB] bfd
[*SwitchB-bfd] quit
[*SwitchB] bfd bb bind peer-ip 10.1.1.1
[*SwitchB-bfd-session-bb] discriminator local 20
[*SwitchB-bfd-session-bb] discriminator remote 10
[*SwitchB-bfd-session-bb] commit
[~SwitchB-bfd-session-bb] quit
- Configure a default static route and bind a BFD session to the default static route.
# Configure a default static route to the external network on SwitchA and bind the default static route to the BFD session named aa.
[~SwitchA] ip route-static 0.0.0.0 0 10.1.1.2 track bfd-session aa
[*SwitchA] commit
- Verify the configuration.
# After the configuration is complete, run the display bfd session all command on SwitchA and SwitchB. The command output shows that the BFD session has been established and its status is Up. Run the display current-configuration | include bfd command. The command output shows that the BFD session has been bound to the static route.
Take the display information on SwitchA as an example.
[~SwitchA] display bfd session all
S: Static session D: Dynamic session IP: IP session IF: Single-hop session PEER: Multi-hop session AUTO: Automatically negotiated session -------------------------------------------------------------------------------- Local Remote PeerIpAddr State Type InterfaceName -------------------------------------------------------------------------------- 10 20 10.1.1.2 Up S/IP-PEER - --------------------------------------------------------------------------------
[~SwitchA] display current-configuration | include bfd
bfd
bfd aa bind peer-ip 10.1.1.2
ip route-static 0.0.0.0 0.0.0.0 10.1.1.2 track bfd-session aa
# Check the IP routing table on SwitchA, and you can find that the static route exists in the routing table.
[~SwitchA] display ip routing-table
Proto: Protocol Pre: Preference Route Flags: R - relay, D - download to fib, T - to vpn-instance, B - black hole route
------------------------------------------------------------------------------
Routing Table: _Public_
Destinations : 3 Routes : 3
Destination/Mask Proto Pre Cost Flags NextHop Interface
0.0.0.0/0 Static 60 0 RD 10.1.1.2 Vlanif10
10.1.1.0/24 Direct 0 0 D 10.1.1.1 Vlanif10
10.1.1.1/32 Direct 0 0 D 127.0.0.1 Vlanif10
Run the shutdown command on 10GE1/0/1 of SwitchB to simulate a link fault.
[~SwitchB] interface 10GE 1/0/1
[~SwitchB-10GE1/0/1] shutdown
[*SwitchB-10GE1/0/1] commit
# Check the routing table on SwitchA, and you can find that the default static route 0.0.0.0/0 does not exist. This is because when the default static route is bound to a BFD session, BFD rapidly notifies that the bound static route is unavailable after BFD detects a link fault.
[~SwitchA] display ip routing-table
Proto: Protocol Pre: Preference Route Flags: R - relay, D - download to fib, T - to vpn-instance, B - black hole route
------------------------------------------------------------------------------
Routing Table: _Public_
Destinations : 2 Routes : 2
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.1.1.0/24 Direct 0 0 D 10.1.1.1 Vlanif10
10.1.1.1/32 Direct 0 0 D 127.0.0.1 Vlanif10
Configuration Files
Configuration file of SwitchA
#
sysname SwitchA
#
vlan batch 10
#
bfd
#
interface Vlanif10
ip address 10.1.1.1 255.255.255.0
#
interface 10GE1/0/1
port link-type trunk
port trunk allow-pass vlan 10
#
ip route-static 0.0.0.0 0.0.0.0 10.1.1.2 track bfd-session aa
#
bfd aa bind peer-ip 10.1.1.2
discriminator local 10
discriminator remote 20
#
return
Configuration file of SwitchB
#
sysname SwitchB
#
vlan batch 10 20
#
bfd
#
interface Vlanif10
ip address 10.1.1.2 255.255.255.0
#
interface Vlanif20
ip address 10.2.2.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 20
#
bfd bb bind peer-ip 10.1.1.1
discriminator local 20
discriminator remote 10
#
return