125x Introduce Routing
The routes learned by ebgp on site suppress the routes introduced by OSPF, resulting in the traffic not being implemented as expected:
Preference 20 is configured on site, which leads to the better routing of ebgp than OSPF. On site, it indicates that if preference is configured first, BGP routing takes effect; if route introduction is configured first, OSPF routing takes effect.
This problem does exist in laboratory reproduction:
1) Configure preference before import OSPF:
[H3C]display ip routing-table vpn-instance 11
Destinations : 26 Routes : 26
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
6.1.1.0/24 O_ASE2 150 1 60.1.1.10 Vlan60
7.7.7.7/32 O_ASE2 150 1 60.1.1.10 Vlan60
12.12.12.12/32 Direct 0 0 127.0.0.1 InLoop0
20.1.1.0/24 O_ASE2 150 1 60.1.1.10 Vlan60
20.20.20.0/24 BGP 20 0 30.1.1.30 Vlan30
[H3C]address-family ipv4
[H3C]import-route ospf 10
[H3C]qu
[H3C]dis th
#
#
ip vpn-instance 11
peer 20.1.1.2 as-number 200
peer 30.1.1.30 as-number 200
#
address-family ipv4 unicast
preference 20 150 130
import-route ospf 10
peer 20.1.1.2 enable
peer 30.1.1.30 enable
#
return
[H3C]display ip routing-table vpn-instance 11
Destinations : 26 Routes : 26
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
6.1.1.0/24 O_ASE2 150 1 60.1.1.10 Vlan60
7.7.7.7/32 O_ASE2 150 1 60.1.1.10 Vlan60
12.12.12.12/32 Direct 0 0 127.0.0.1 InLoop0
20.1.1.0/24 O_ASE2 150 1 60.1.1.10 Vlan60
20.20.20.0/24 BGP 20 0 30.1.1.30 Vlan30
2) Configure import OSPF before preference:
#
ip vpn-instance 11
peer 20.1.1.2 as-number 200
peer 30.1.1.30 as-number 200
#
address-family ipv4 unicast
import-route ospf 10
peer 20.1.1.2 enable
peer 30.1.1.30 enable
#
return
[H3C]display ip routing-table vpn-instance 11
Destinations : 26 Routes : 26
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
6.1.1.0/24 O_ASE2 150 1 60.1.1.10 Vlan60
7.7.7.7/32 O_ASE2 150 1 60.1.1.10 Vlan60
12.12.12.12/32 Direct 0 0 127.0.0.1 InLoop0
20.1.1.0/24 O_ASE2 150 1 60.1.1.10 Vlan60
20.20.20.0/24 O_ASE2 150 1 60.1.1.10 Vlan60
[H3C]address-family ipv4 unicast
[H3C]preference 20 200 130
[H3C]dis th
#
ip vpn-instance 11
peer 20.1.1.2 as-number 200
peer 30.1.1.30 as-number 200
#
address-family ipv4 unicast
preference 20 200 130
import-route ospf 10
peer 20.1.1.2 enable
peer 30.1.1.30 enable
#
return
[H3C]qu
[H3C]display ip routing-table vpn-instance 11
Destinations : 26 Routes : 26
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
6.1.1.0/24 O_ASE2 150 1 60.1.1.10 Vlan60
7.7.7.7/32 O_ASE2 150 1 60.1.1.10 Vlan60
12.12.12.12/32 Direct 0 0 127.0.0.1 InLoop0
20.1.1.0/24 O_ASE2 150 1 60.1.1.10 Vlan60
20.20.20.0/24 O_ASE2 150 1 60.1.1.10 Vlan60
[H3C]display bgp routing-table ipv4 vpn-instance 11 20.20.20.0
BGP local router ID: 2.2.2.2
Local AS number: 100
Paths: 2 available, 1 best
BGP routing table information of 20.20.20.0/24:
Imported route.
Original nexthop: 60.1.1.10
OutLabel : NULL
Ext-Community : <OSPF Domain Id: 0.0.0.0:0>, <OSPF Router Id: 12.12.12.12:0:
0>, <OSPF AreaNum: 0.0.0.0 RouteType: 5 Option: 1>, <RT: 111
:1>
RxPathID : 0x0
TxPathID : 0x0
AS-path : (null)
Origin : incomplete
Attribute value : MED 2, pref-val 32768
State : valid, local, best
IP precedence : N/A
QoS local ID : N/A
Traffic index : N/A
From : 30.1.1.30 (1.1.1.1)
Rely nexthop : 30.1.1.30
Original nexthop: 30.1.1.30
OutLabel : NULL
Ext-Community : <RT: 111:1>
RxPathID : 0x0
TxPathID : 0xffffffff
AS-path : 200
Origin : igp
Attribute value : MED 0, pref-val 0
State : valid, external
IP precedence : N/A
QoS local ID : N/A
Traffic index : N/A
After analyzing the logic:
1) If you configure preference first, the route learned by ebgp is 20, and the route learned by OSPF is 150. At this time, BGP route is in effect in the routing table, and then import OSPF is configured in BGP (Note: BGP can only import routes in effect in the routing table), so it cannot be imported. At this time, BGP routing is in effect;
2) When preference is not configured, ebgp learns 20 routes, while OSPF learns 150 routes. At this time, the effective route in the routing table is OSPF route type. At this time, import OSPF can be configured in BGP to introduce the OSPF route into BGP routing table (pref Val 32768); then configure preference. At this time, there are two routes in BGP routing table, while the one introduced by itself Pref Val is large, so OSPF is preferred for BGP routing table.