125x引入路由
现场ebgp学到的路由,压制了ospf引入的路由,导致流量没有按照预期规划实现:
现场配置了preference 20,导致ebgp的路由会优于ospf路由,现场表示如果先配置preference,则生效的是bgp路由,如果先配置路由引入,则生效的是ospf路由
实验室复现确实存在该问题:
1)先配置preference再配置import ospf:
[2012-S125X-AF-bgp-default-11]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
[2012-S125X-AF-bgp-default-11]address-family ipv4
[2012-S125X-AF-bgp-default-ipv4-11]import-route ospf 10
[2012-S125X-AF-bgp-default-ipv4-11]qu
[2012-S125X-AF-bgp-default-11]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
[2012-S125X-AF-bgp-default-11]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)先配置import ospf再配置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
[2012-S125X-AF-bgp-default-11]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
[2012-S125X-AF-bgp-default-11]address-family ipv4 unicast
[2012-S125X-AF-bgp-default-ipv4-11]preference 20 200 130
[2012-S125X-AF-bgp-default-11]
[2012-S125X-AF-bgp-default-11]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
[2012-S125X-AF-bgp-default-11]
[2012-S125X-AF-bgp-default-ipv4-11]
[2012-S125X-AF-bgp-default-ipv4-11]qu
[2012-S125X-AF-bgp-default-11]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
2012-S125X-AF-bgp-default-11]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
[2012-S125X-AF-bgp-default-11]
经过分析逻辑:
1)先配置preference的话,EBGP学习到的路由是20,而OSPF学习到的路由是150,此时路由表中生效的是BGP路由,然后在BGP中配置import ospf(注意:BGP只能引入路由表中生效的路由),所以无法引入。此时,生效的是BGP路由;
2)未配置preference的情况下,EBGP学习到的路由是20,而OSPF学习到的路由是150,此时路由表中生效的路由是ospf路由类型,此时先在BGP中配置import ospf,可以将该ospf路由引入到BGP路由表中(pref-val 32768 );然后再配置preference,此时BGP 路由表中有两条,而自身引入的 pref-val 大,所以BGP路由表优选的是OSPF