BGP routes can be locally imported or learned from peers. The locally imported routes take precedence over the routes learned from peers during BGP route selection. It is unusual for locally imported routes and the routes learned from peers to carry the same destination IP address and coexist in the routing table. Generally, locally imported routes can be the routes imported using the network or import-route command and the automatically and manually summarized routes. Precedences of these routes are described as follows:
Summarized routes take precedence over non-summarized routes.
Summarized routes that are manually generated using the aggregate command take precedence over summarized routes that are automatically generated based on the summary automatic command settings.
The routes imported using the network command take precedence over the routes imported using the import-route command.
In Figure 1, Switch A and Switch B are EBGP peers, and Switch B, Switch C, and Switch D are IBGP peers.
The configurations on Switch C are as follows:
# bgp 65001 # ipv4-family unicast network 10.1.2.0 255.255.255.252 //Advertise the route 10.1.2.0/30. network 10.1.3.0 255.255.255.252 //Advertise the route 10.1.3.0/30. import-route direct //Import direct routes. #
The configurations on Switch D are as follows:
# bgp 65001 # ipv4-family unicast network 10.1.3.0 255.255.255.252 //Advertise the route 10.1.3.0/30. network 10.1.4.0 255.255.255.252 //Advertise the route 10.1.4.0/30. import-route direct //Import direct routes. #
Run the display bgp routing-table [ ip-address ] command to check the configurations.
# Display the routing table of Switch D.
[HUAWEID] display bgp routing-table
BGP Local router ID is 10.1.3.2 Status codes: * - valid, > - best, d - damped, h - history, i - internal, s - suppressed, S - Stale Origin : i - IGP, e - EGP, ? - incomplete Total Number of Routes: 10 Network NextHop MED LocPrf PrefVal Path/Ogn *>i 10.1.2.0/30 10.1.4.2 0 100 0 i *> 10.1.3.0/30 0.0.0.0 0 0 i * 0.0.0.0 0 0 ? *> 10.1.3.2/32 0.0.0.0 0 0 ? *> 10.1.4.0/30 0.0.0.0 0 0 i * 0.0.0.0 0 0 ? i 10.1.4.2 0 100 0 ? *> 10.1.4.1/32 0.0.0.0 0 0 ? *> 127.0.0.0 0.0.0.0 0 0 ? *> 127.0.0.1/32 0.0.0.0 0 0 ?
The preceding command output shows that three routes 10.1.4.0/30 are available in the routing table. The route with the next hop address 10.1.4.2 is learned from a peer (Switch C). Therefore, BGP first excludes this route from route selection.
[HUAWEID] display bgp routing-table 10.1.4.0 30
BGP local router ID : 10.1.3.2 Local AS number : 65001 Paths: 3 available, 1 best, 1 select BGP routing table entry information of 10.1.4.0/30: Network route. From: 0.0.0.0 (0.0.0.0) Route Duration: 00h03m51s Direct Out-interface: GigabitEthernet0/0/4 Original nexthop: 10.1.4.1 Qos information : 0x0 AS-path Nil, origin igp, MED 0, pref-val 0, valid, local, best, select, pre 0 Advertised to such 2 peers: 10.1.3.1 10.1.4.2 BGP routing table entry information of 10.1.4.0/30: Imported route. From: 0.0.0.0 (0.0.0.0) Route Duration: 00h04m10s Direct Out-interface: GigabitEthernet0/0/4 Original nexthop: 10.1.4.1 Qos information : 0x0 AS-path Nil, origin incomplete, MED 0, pref-val 0, valid, local, pre 0, not preferred for route type Not advertised to any peer yet BGP routing table entry information of 10.1.4.0/30: From: 10.1.4.2 (10.1.2.2) Route Duration: 00h02m24s Relay IP Nexthop: 0.0.0.0 Relay IP Out-Interface: GigabitEthernet0/0/4 Original nexthop: 10.1.4.2 Qos information : 0x0 AS-path Nil, origin incomplete, MED 0, localpref 100, pref-val 0, internal, pre 255 Not advertised to any peer yet
The preceding command output shows that the route imported using the network command is selected as the optimal route.
The configurations on Switch B are as follows:
bgp 65001 # ipv4-family unicast summary automatic aggregate 10.0.0.0 255.0.0.0 import-route direct #
Run the display bgp routing-table [ ip-address ] command to check the configurations.
# Display the routing table of Switch B.
[HUAWEIB] display bgp routing-table
BGP Local router ID is 10.1.1.2 Status codes: * - valid, > - best, d - damped, h - history, i - internal, s - suppressed, S - Stale Origin : i - IGP, e - EGP, ? - incomplete Total Number of Routes: 14 Network NextHop MED LocPrf PrefVal Path/Ogn *> 10.0.0.0 127.0.0.1 0 ? * 127.0.0.1 0 ? s> 10.1.1.0/30 0.0.0.0 0 0 ? *> 10.1.1.2/32 0.0.0.0 0 0 ? s> 10.1.2.0/30 0.0.0.0 0 0 ? i 10.1.2.2 0 100 0 i *> 10.1.2.1/32 0.0.0.0 0 0 ? s> 10.1.3.0/30 0.0.0.0 0 0 ? i 10.1.3.2 0 100 0 i *> 10.1.3.1/32 0.0.0.0 0 0 ? *>i 10.1.4.0/30 10.1.3.2 0 100 0 i * i 10.1.2.2 0 100 0 ? *> 127.0.0.0 0.0.0.0 0 0 ? *> 127.0.0.1/32 0.0.0.0 0 0 ?
The preceding command output shows that two summarized routes 10.0.0.0 are available in the routing table.
[HUAWEIB] display bgp routing-table 10.0.0.0
BGP local router ID : 10.1.1.2 Local AS number : 65001 Paths: 2 available, 1 best, 1 select BGP routing table entry information of 10.0.0.0/8: Aggregated route. Route Duration: 00h17m04s Direct Out-interface: NULL0 Original nexthop: 127.0.0.1 Qos information : 0x0 AS-path Nil, origin incomplete, pref-val 0, valid, local, best, select, active, pre 255 Aggregator: AS 65001, Aggregator ID 10.1.1.2 Advertised to such 3 peers: 10.1.1.1 10.1.3.2 10.1.2.2 BGP routing table entry information of 10.0.0.0/8: Summary automatic route Route Duration: 00h17m04s Direct Out-interface: NULL0 Original nexthop: 127.0.0.1 Qos information : 0x0 AS-path Nil, origin incomplete, pref-val 0, valid, local, pre 255, not preferred for route type Aggregator: AS 65001, Aggregator ID 10.1.1.2 Not advertised to any peer yet
The preceding command output shows that the route generated using the aggregate command is selected as the optimal route.