BGP路由优选原则!
1.首先丢弃下一跳(NEXT_HOP)不可达的路由;
2.优选Preferred-value值最大的路由;
3.优选本地优先级(LOCAL_PREF)最高的路由;
4.优选聚合路由;
5.优选AS路径(AS_PATH)最短的路由;
6.依次选择ORIGIN属性为IGP、EGP、Incomplete的路由;
7.优选MED值最低的路由;
8.依次选择从EBGP、联盟、IBGP学来的路由;
9.优选下一跳度量值最低的路由;
10.优选CLUSTER_LIST长度最短的路由;
11.优选ORIGINATOR_ID最小的路由;
12.优选Router ID最小的路由器发布的路由。
13.优选地址最小的对等体发布的路由。
该实验基本配置:(注意为了不影响现象,每一条做完以后,将之前的配置undo)
[R1]dis cu con bgp
#
bgp 100
network 1.1.1.1 255.255.255.255
undo synchronization
peer 12.12.12.2 as-number 200
peer 10.0.12.2 as-number 200
peer 13.13.13.3 as-number 200
#
Return
[R2]dis cu | be bgp
bgp 200
network 2.2.2.2 255.255.255.255
undo synchronization
peer 12.12.12.1 as-number 100
peer 10.0.12.1 as-number 100
peer 4.4.4.4 as-number 200
peer 4.4.4.4 connect-interface LoopBack0
#
ospf 1
area 0.0.0.0
network 2.2.2.2 0.0.0.0
network 24.24.24.0 0.0.0.255
#
load xml-configuration
#
user-interface con 0
user-interface vty 0 4
#
Return
[R3]dis cu | be bgp
bgp 200
network 3.3.3.3 255.255.255.255
undo synchronization
peer 4.4.4.4 as-number 200
peer 13.13.13.1 as-number 100
peer 4.4.4.4 connect-interface LoopBack0
#
ospf 1
area 0.0.0.0
network 3.3.3.3 0.0.0.0
network 34.34.34.0 0.0.0.255
#
load xml-configuration
#
user-interface con 0
user-interface vty 0 4
#
Return
[R4]dis cu | be bgp
bgp 200
network 4.4.4.4 255.255.255.255
undo synchronization
peer 2.2.2.2 as-number 200
peer 3.3.3.3 as-number 200
peer 2.2.2.2 connect-interface LoopBack0
peer 3.3.3.3 connect-interface LoopBack0
#
ospf 1
area 0.0.0.0
network 4.4.4.4 0.0.0.0
network 24.24.24.0 0.0.0.255
network 34.34.34.0 0.0.0.255
#
load xml-configuration
#
user-interface con 0
user-interface vty 0 4
#
Return
R1R2R3之间用物理口建立了ebgp邻居,R2R3R4之间用换回口做ibgp邻居,使用ospf使得换回口之间tcp可达!
缺省情况下,路由器向IBGP对等体发布路由时,不将自身地址作为下一跳
查看R4BGP路由表
R4]dis bgp routing-table 1.1.1.1
BGP local router ID : 4.4.4.4
Local AS number : 200
Paths: 2 available, 0 best
BGP routing table entry information of 1.1.1.1/32:
From : 2.2.2.2 (2.2.2.2)
Original nexthop: 10.0.12.1
AS-path : 100
Origin : igp
Attribute value : MED 0, localpref 100, pref-val 0, pre 255
State : internal,
Not advertised to any peers yet
BGP routing table entry information of 1.1.1.1/32:
From : 3.3.3.3 (3.3.3.3)
Original nexthop: 13.13.13.1
AS-path : 100
Origin : igp
Attribute value : MED 0, localpref 100, pref-val 0, pre 255
State : internal,
Not advertised to any peers yet
1.1.1.1这条路由不是最优的,显然不会将它放入ip路由表中
为了保证IBGP邻居能够找到下一跳,可以配置将自身地址作为下一跳
[R2-bgp]peer 4.4.4.4 next-hop-local
[R3-bgp]peer 4.4.4.4 next-hop-local
再看R4bgp路由表
[R4]dis bgp routing-table
Total Number of Routes: 5
BGP Local router ID is 4.4.4.4
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 1.1.1.1/32 2.2.2.2 0 100 0 100i
* i 3.3.3.3 0 100 0 100i
i 2.2.2.2/32 2.2.2.2 0 100 0 i
i 3.3.3.3/32 3.3.3.3 0 100 0 i
*> 4.4.4.4/32 0.0.0.0 0 0 i
Preferred-value是华三私有的首选值,类似于cisco的weight,也是本地有效的
R2R3中引入OSPF的路由,查看R1bgp路由表:
dis bgp routing-table
Total Number of Routes: 13
BGP Local router ID is 1.1.1.1
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 4.4.4.4/32 10.0.12.2 1562 0 200?
* 12.12.12.2 1562 0 200?
* 13.13.13.3 1562 0 200?
默认选择最优的是来自下一条10.0.12.2的路由,先提一下最后一条原则:选择地址最小的,显然10.0.12.2是最小的地址
修改首选值,来做选路!
[R1-bgp]peer 13.13.13.3 preferred-value 1313
*> 4.4.4.4/32 13.13.13.3 1562 1313 200?
* 12.12.12.2 1562 0 200?
* 10.0.12.2 1562 0 200?
来自R3的路由的首选值都变成了1313,r1优选来自r3的路由,preferred-value默认为0,且越到越优先,并且只在本地有效!