Example for Configuring Basic BGP Functions
Networking Requirements
As shown in Figure 9-23, BGP runs between Switches; an EBGP connection is established between SwitchA and SwitchB; IBGP full-mesh connections are established between SwitchB, SwitchC, and SwitchD.
Configuration Roadmap
The configuration roadmap is as follows:
- Configure IBGP connections between SwitchB, SwitchC, and SwitchD.
- Configure an EBGP connection between SwitchA and SwitchB.
Procedure
- Configure the VLAN to which each interface belongs.
<HUAWEI> system-view [~HUAWEI] sysname SwitchA [*HUAWEI] commit [~SwitchA] vlan batch 10 50 [*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 50 [*SwitchA-10GE1/0/2] quit [*SwitchA] commit
The configurations of SwitchB, SwitchC, and SwitchD 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.1.2 24 [*SwitchA-Vlanif10] quit [*SwitchA] interface vlanif 50 [*SwitchA-Vlanif50] ip address 10.2.1.1 8 [*SwitchA-Vlanif50] quit [*SwitchA] commit
The configurations of SwitchB, SwitchC, and SwitchD are similar to the configuration of SwitchA, and are not provided here.
- Configure IBGP connections.
# Configure SwitchB.
[~SwitchB] bgp 65009 [*SwitchB-bgp] router-id 172.16.2.2 [*SwitchB-bgp] peer 10.1.1.2 as-number 65009 [*SwitchB-bgp] peer 10.1.3.2 as-number 65009 [*SwitchB-bgp] quit [*SwitchB] commit
# Configure SwitchC.
[~SwitchC] bgp 65009 [*SwitchC-bgp] router-id 172.16.3.3 [*SwitchC-bgp] peer 10.1.3.1 as-number 65009 [*SwitchC-bgp] peer 10.1.2.2 as-number 65009 [*SwitchC-bgp] quit [*SwitchC] commit
# Configure SwitchD.
[~SwitchD] bgp 65009 [*SwitchD-bgp] router-id 172.16.4.4 [*SwitchD-bgp] peer 10.1.1.1 as-number 65009 [*SwitchD-bgp] peer 10.1.2.1 as-number 65009 [*SwitchD-bgp] quit [*SwitchD] commit
- Configure an EBGP connection.
# Configure SwitchA.
[~SwitchA] bgp 65008 [*SwitchA-bgp] router-id 172.16.1.1 [*SwitchA-bgp] peer 192.168.1.1 as-number 65009 [*SwitchA-bgp] quit [*SwitchA] commit
# Configure SwitchB.
[~SwitchB] bgp 65009 [~SwitchB-bgp] peer 192.168.1.2 as-number 65008 [*SwitchB-bgp] quit [*SwitchB] commit
# View the status of BGP peers.
[~SwitchB] display bgp peer BGP local router ID : 172.16.2.2 Local AS number : 65009 Total number of peers : 3 Peers in established state : 3 Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv 10.1.1.2 4 65009 49 62 0 00:44:58 Established 0 10.1.3.2 4 65009 56 56 0 00:40:54 Established 0 192.168.1.2 4 65008 49 65 0 00:44:03 Established 1
The preceding command output shows that BGP connections have been established between SwitchB and other Switches.
- Configure SwitchA to advertise route 10.0.0.0/8.
# Configure SwitchA to advertise route 8.0.0.0.
[~SwitchA] bgp 65008 [~SwitchA-bgp] ipv4-family unicast [~SwitchA-bgp-af-ipv4] network 10.0.0.0 255.0.0.0 [*SwitchA-bgp-af-ipv4] quit [*SwitchA-bgp] quit [*SwitchA] commit
# View the BGP routing table of SwitchA.
[~SwitchA] display bgp routing-table BGP Local router ID is 172.16.1.1 Status codes: * - valid, > - best, d - damped, x - best external, a - add path, h - history, i - internal, s - suppressed, S - Stale Origin : i - IGP, e - EGP, ? - incomplete Total Number of Routes: 1 Network NextHop MED LocPrf PrefVal Path/Ogn *> 10.0.0.0 0.0.0.0 0 0 i
# View the BGP routing table of SwitchB.
[~SwitchB] display bgp routing-table BGP Local router ID is 172.16.2.2 Status codes: * - valid, > - best, d - damped, x - best external, a - add path, h - history, i - internal, s - suppressed, S - Stale Origin : i - IGP, e - EGP, ? - incomplete Total Number of Routes: 1 Network NextHop MED LocPrf PrefVal Path/Ogn *> 10.0.0.0 192.168.1.2 0 0 65008i
# View the BGP routing table of SwitchC.
[~SwitchC] display bgp routing-table BGP Local router ID is 172.16.3.3 Status codes: * - valid, > - best, d - damped, x - best external, a - add path, h - history, i - internal, s - suppressed, S - Stale Origin : i - IGP, e - EGP, ? - incomplete Total Number of Routes: 1 Network NextHop MED LocPrf PrefVal Path/Ogn i 10.0.0.0 192.168.1.2 0 100 0 65008i
The preceding command output shows that SwitchC has learned the route to destination 10.0.0.0 in AS 65008. The route, however, is invalid because the next hop 192.168.1.2 of this route is unreachable.
- Configure BGP to import direct routes.
# Configure SwitchB.
[~SwitchB] bgp 65009 [~SwitchB-bgp] ipv4-family unicast [*SwitchB-bgp-af-ipv4] import-route direct [*SwitchB-bgp-af-ipv4] quit [*SwitchB-bgp] quit [*SwitchB] commit
# View the BGP routing table of SwitchA.
[~SwitchA] display bgp routing-table BGP Local router ID is 172.16.1.1 Status codes: * - valid, > - best, d - damped, x - best external, a - add path, h - history, i - internal, s - suppressed, S - Stale Origin : i - IGP, e - EGP, ? - incomplete Total Number of Routes: 4 Network NextHop MED LocPrf PrefVal Path/Ogn *> 10.0.0.0 0.0.0.0 0 0 i *> 10.1.1.0/24 192.168.1.1 0 0 65009? *> 10.1.3.0/24 192.168.1.1 0 0 65009? 192.168.1.0 192.168.1.1 0 0 65009?
# View the BGP routing table of SwitchC.
[~SwitchC] display bgp routing-table BGP Local router ID is 172.16.3.3 Status codes: * - valid, > - best, d - damped, x - best external, a - add path, h - history, i - internal, s - suppressed, S - Stale Origin : i - IGP, e - EGP, ? - incomplete Total Number of Routes: 4 Network NextHop MED LocPrf PrefVal Path/Ogn * i 10.0.0.0 192.168.1.2 0 100 0 65008i *>i 10.1.1.0/24 10.1.3.1 0 100 0 ? i 10.1.3.0/24 10.1.3.1 0 100 0 ? *>i 192.168.1.0 10.1.3.1 0 100 0 ?
The preceding command output shows that the route to destination 8.0.0.0 becomes valid because the next-hop address of this route is the address of SwitchA.
# Run the ping 8.1.1.1 command on SwitchC.
[~SwitchC] ping 10.2.1.1 PING 10.2.1.1: 56 data bytes, press CTRL_C to break Reply from 10.2.1.1: bytes=56 Sequence=1 ttl=254 time=31 ms Reply from 10.2.1.1: bytes=56 Sequence=2 ttl=254 time=47 ms Reply from 10.2.1.1: bytes=56 Sequence=3 ttl=254 time=31 ms Reply from 10.2.1.1: bytes=56 Sequence=4 ttl=254 time=16 ms Reply from 10.2.1.1: bytes=56 Sequence=5 ttl=254 time=31 ms --- 10.2.1.1 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 16/31/47 ms
Configuration Files
Configuration file of SwitchA
# sysname SwitchA # vlan batch 10 50 # interface Vlanif10 ip address 192.168.1.2 255.255.255.0 # interface Vlanif50 ip address 10.2.1.1 255.0.0.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 50 # bgp 65008 router-id 172.16.1.1 peer 192.168.1.1 as-number 65009 # ipv4-family unicast network 10.0.0.0 peer 192.168.1.1 enable # return
Configuration file of SwitchB
# sysname SwitchB # vlan batch 10 20 30 # interface Vlanif10 ip address 192.168.1.1 255.255.255.0 # interface Vlanif20 ip address 10.1.3.1 255.255.255.0 # interface Vlanif30 ip address 10.1.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 # interface 10GE1/0/3 port link-type trunk port trunk allow-pass vlan 30 # bgp 65009 router-id 172.16.2.2 peer 10.1.1.2 as-number 65009 peer 10.1.3.2 as-number 65009 peer 192.168.1.2 as-number 65008 # ipv4-family unicast import-route direct peer 10.1.1.2 enable peer 10.1.3.2 enable peer 192.168.1.2 enable # return
Configuration file of SwitchC
# sysname SwitchC # vlan batch 20 40 # interface Vlanif20 ip address 10.1.3.2 255.255.255.0 # interface Vlanif40 ip address 10.1.2.1 255.255.255.0 # interface 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 20 # interface 10GE1/0/2 port link-type trunk port trunk allow-pass vlan 40 # bgp 65009 router-id 172.16.3.3 peer 10.1.2.2 as-number 65009 peer 10.1.3.1 as-number 65009 # ipv4-family unicast peer 10.1.2.2 enable peer 10.1.3.1 enable # return
Configuration file of SwitchD
# sysname SwitchD # vlan batch 30 40 # interface Vlanif30 ip address 10.1.1.2 255.255.255.0 # interface Vlanif40 ip address 10.1.2.2 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 40 # bgp 65009 router-id 172.16.4.4 peer 10.1.1.1 as-number 65009 peer 10.1.2.1 as-number 65009 # ipv4-family unicast peer 10.1.1.1 enable peer 10.1.2.1 enable # return