BGP community configuration example
Network requirements
As shown in Figure 67, Switch B establishes EBGP connections with Switch A and Switch C. Configure NO_EXPORT community attribute on Switch A to make routes from AS 10 not advertised by AS 20 to any other AS.
Figure 67: Network diagram
Configuration procedure
Configure IP addresses for interfaces. (Details not shown.)
Configure EBGP:
# Configure Switch A.
<SwitchA> system-view [SwitchA] bgp 10 [SwitchA-bgp] router-id 1.1.1.1 [SwitchA-bgp] peer 200.1.2.2 as-number 20 [SwitchA-bgp] address-family ipv4 unicast [SwitchA-bgp-ipv4] peer 200.1.2.2 enable [SwitchA-bgp-ipv4] network 9.1.1.0 255.255.255.0 [SwitchA-bgp] quit
# Configure Switch B.
<SwitchB> system-view [SwitchB] bgp 20 [SwitchB-bgp] router-id 2.2.2.2 [SwitchB-bgp] peer 200.1.2.1 as-number 10 [SwitchB-bgp] peer 200.1.3.2 as-number 30 [SwitchB-bgp] address-family ipv4 unicast [SwitchB-bgp-ipv4] peer 200.1.2.1 enable [SwitchB-bgp-ipv4] peer 200.1.3.2 enable [SwitchB-bgp-ipv4] quit [SwitchB-bgp] quit
# Configure Switch C.
<SwitchC> system-view [SwitchC] bgp 30 [SwitchC-bgp] router-id 3.3.3.3 [SwitchC-bgp] peer 200.1.3.1 as-number 20 [SwitchC-bgp] address-family ipv4 unicast [SwitchC-bgp-ipv4] peer 200.1.3.1 enable [SwitchC-bgp-ipv4] quit [SwitchC-bgp] quit
# Display the BGP routing table on Switch B.
[SwitchB] display bgp routing-table ipv4 9.1.1.0 BGP local router ID: 2.2.2.2 Local AS number: 20 Paths: 1 available, 1 best BGP routing table information of 9.1.1.0/24: From : 200.1.2.1 (1.1.1.1) Relay nexthop : 200.1.2.1 Original nexthop: 200.1.2.1 OutLabel : NULL AS-path : 10 Origin : igp Attribute value : pref-val 0 State : valid, external, best,
# Display advertisement information of network 9.1.1.0 on Switch B.
[SwitchB] display bgp routing-table ipv4 9.1.1.0 advertise-info BGP local router ID: 2.2.2.2 Local AS number: 20 Paths: 1 best BGP routing table information of 9.1.1.0/24: Advertised to peers (1 in total): 200.1.3.2
The output shows that Switch B can advertise the route with the destination 9.1.1.0/24 to other ASs through BGP.
# Display the BGP routing table on Switch C.
[SwitchC] display bgp routing-table ipv4 Total number of routes: 1 BGP local router ID is 3.3.3.3 Status codes: * - valid, > - best, d - dampened, h - history, s - suppressed, S - stale, i - internal, e - external Origin: i - IGP, e - EGP, ? - incomplete Network NextHop MED LocPrf PrefVal Path/Ogn * >e 9.1.1.0/24 200.1.3.1 0 20 10i
The output shows that Switch C has learned route 9.1.1.0/24 from Switch B.
Configure BGP community:
# Configure a routing policy.
[SwitchA] route-policy comm_policy permit node 0 [SwitchA-route-policy-comm_policy-0] apply community no-export [SwitchA-route-policy-comm_policy-0] quit
# Apply the routing policy.
[SwitchA] bgp 10 [SwitchA-bgp] address-family ipv4 unicast [SwitchA-bgp-ipv4] peer 200.1.2.2 route-policy comm_policy export [SwitchA-bgp-ipv4] peer 200.1.2.2 advertise-community
Verifying the configuration
# Display the routing table on Switch B.
[SwitchB] display bgp routing-table ipv4 9.1.1.0 BGP local router ID: 2.2.2.2 Local AS number: 20 Paths: 1 available, 1 best BGP routing table information of 9.1.1.0/24: From : 200.1.2.1 (1.1.1.1) Relay nexthop : 200.1.2.1 Original nexthop: 200.1.2.1 OutLabel : NULL Community : No-Export AS-path : 10 Origin : igp Attribute value : pref-val 0 State : valid, external, best,
# Display advertisement information for the route 9.1.1.0 on Switch B.
[SwitchB] display bgp routing-table ipv4 9.1.1.0 advertise-info BGP local router ID: 2.2.2.2 Local AS number: 20 Paths: 1 best BGP routing table information of 9.1.1.0/24: Not advertised to any peers yet
# Display the BGP routing table on Switch C.
[SwitchC] display bgp routing-table ipv4 Total number of routes: 0
The output shows BGP has not learned any route.