nihaogirl 发表于 2017-7-9 16:31:13

1.7-BGP⑤

BGP Attributes/BGP属性
(通过BGP的属性,实现对BGP路由的选择/操纵)

BGP Route Selection/BGP的选路原则:


1:
The BGP forwarding table usually has multiple pathways from which to choose for each network.

在BGP路由器的BGP表中,可以存在到达某个特定目标网络的,都能满足"同步"和"下一跳可达"的,多条路径.



2:
BGP is not designed to perform load balancing:
Paths are chosen because of policy.
Paths are not chosen based upon Metric/bandwidth.

BGP默认不执行负载均衡,而是严格按照网管的策略/意志,进行BGP选路.

网管是通过BGP属性/Attribute,去表达其策略/意志的,实现BGP路由选择的控制.

对比:
而IGP是通过最小的Metric,实现路由选择的.

对于BGP,可以通过“maximum-path (1~6)”命令,实现BGP的负载均衡。


3:

The BGP selection process eliminates any multiple pathways through attrition, until a single best pathway is left.

BGP是按照BGP属性,自上而下,依次剔除不是最佳的路由:
直到优选出,到达目标风格的最佳的那一条BGP路由.


4:

That best pathway is submitted to the routing table
manager process and evaluated aggainst the
methods of other routing protocols for reaching that network (administrative distance).

BGP把自己认为“最佳的”那条路由,提交给IP路由表选择的路由,会和别的路由协议(IGP)所获得的路由进行AD比较



5:

The routing protocol with the lowest administrative
distance will be installed in the routing table.

AD最小的那个路由协议所生成的路由,将被注入/优先进路由表,成为最终达到该目标网络的路由.



BGP属性的分类:

Well-known attributes:(公认属性)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Well-known mandatory(公认,强制的)
Well-known discretionary(公认,自决的)


Optional attributes:(可选属性)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Optional transitive attributes(可传递的,partial)
Optional nontransitive attributes(非传递的)

关于“传递”的属性:
1:不论“可传递”还是“非可传递”,如果设备支持这种属性,那么都会传递。
2:如果网络设备不支持的属性:
2-1:对于“可传递”,那么,会被标识为“partial”,来进行继续传递。
2-2:对于“非可传递”,那么这种属性会被丢弃,但BGP这条路由条目,还是正常传递。

Well-known, mandatory & transitive attribute:
AS path
next-hop
origin

origin:(起源代码)

IGP (i) (RIP/IGRP/EIGRP/OSPF/IS-IS)(路由表后面的那个I)
通过BGP中的network command,宣告进BGP的.
R2#router bgp 12
network 120.1.0.0 mask 255.255.0.0

EGP (e)
Redistributed from EGP


Incomplete (?)
Redistributed from IGP or Static


BGP路由优化的前提条件:
A:Sync;B:next-Hop

BGP路由选择的主要比较因素的先后次序:
1:Weight(LAB6)
2:L-P(LAB5)                越大越好
----------------------
3:AS Path (LAB4)            越小越好
4:MED (LAB3)
5:EBGP   VS   IBGP的对比(其实是AD的对比)(LAB2)
6:Closet IBGP Neighbor(LAB1)
7:lowest neighbor BGP router ID (LAB0)

LAB0:IGP为RIP
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   
lowest neighbor BGP router ID
在R3上,调整BGP R-ID,可以控制R5的选路
neighbor 3.3.3.3 shutdown(临时断掉3.3.3.3的邻居)




LAB1:Closet IGP Neighbor
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Step1:将AS345中的IGP更改为:EIGRP
   
在R5上观察
R5#show ip route
D    3.3.3.3
D    4.4.4.4

R5#show ip BGP

*>i 101.0.0.0       4.4.4.4
*i                  3.3.3.3

R5#show ip route
B    101.0.0.0 via 4.4.4.4

LAB2:EBGP VS IBGP
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
在R4上观察:
Step1:如果从R2和R3的两个方向上,都收到BGP路由:

R4#show ip bgp
* i 101.0.0.0      3.3.3.3 (来自IBGP)
*>               24.0.0.2(来自EBGP)

EBGP path over IBGP path

Step2:切断R2/R4的链路:
R4#
*>i 101.0.0.0         3.3.3.3


LAB3:MED(Multi-exit discriminator)(also called the metric)
(整个AS35都从下面链路走)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
MED的特征:
1:MED的取值是越小越好
2:MED只发送给EBGP邻居,用于建议对方如何离开对方的AS,来访问本AS中的网络
3:MED是一种可选的,非传递的属性.
4:MED的默认值:0.

Step1:定义BGP路由:

R2(config)#ip prefix-list B-101 permit 101.0.0.0/8

Step2:在Route-map中,设定路由的MED值:

R2(config)#route-map R2-AS345
R2(config-route-map)#match ip address prefix-list B-101
R2(config-route-map)#set metric 100

Step3:
R2(config-router)#neighbor 24.0.0.4 route-map R2-AS345 out

clear ip bgp * soft out

Step4:

show ip bgp 101.0.0.0/8
R4#show ip bgp

   network                   next hop                      metric
*101.0.0.0

R5#
*> i101.0.0.0   3.3.3.3         

R4有两条路由可以优化,R3和R5都只有一条

LAB4:AS path
(在R1与R3之间,虚拟一个AS100:导致整个AS345都从上面链路走)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

实验需求:

整个AS345的所有路由器,都从R2走

在R1与R3之间,虚拟一个AS100

Step1:通过Prefix-list,定义BGP路由:
R3(config)#ip prefix-list B-101 permit 101.0.0.0/8

Step2:在Route-map中,为此路由添加一个虚拟的AS100
R3#
route-map V-AS100 permit 10
match ip address prefix-list B-110
set as-path prepend 100

step3:在R3的BGP进程中,对来自R1的BGP路由,调用route-map V-AS345
R3(confgi-router)#neighbor 10.0.0.1 route-map V-AS100 in

Step4:
R3#

    Network          Next-hop      metricLocPrf    Weight   Path

*>i 101.0.0.0         4.4.4.4      2000    100      0      120i
*                     13.0.0.1       150                0      120i 100i


LAB5:Local Preference(整个AS345都从下面链路走)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LP的特征:
1:LP的取值越大越好,默认值是100.
2:LP只发送给本AS内的IBGP邻居,用于建议他们如何离开本AS,去访问外网.
3:LP的属性是公认的,自决的,只会在本AS传递的.!!!

R3#
Step1:通过Prefix-list,定义BGP路由:

Step2:作用Route-map,为特定路由设定LP值:
route-map V-AS100 permit 10
match ip address prefix-list B-101
set as-path prepend 100
set local-preference 130

Step3:在R3的BGP进程中,对来自R1对路由,调用route-map V-AS100:
R3(config-router)#neighbor 13.0.0.1 route-map V-AS100 in

Step4:观察:

R3#
      Network      next Hop   Metric    LocPrf      Weight          Path

*>101.0.0.0

R4#

*>i 101.0.0.0

R5#
*>i 101.0.0.0



LAB6:Weight
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Weight的特征:
1:cisco私有的属性.
2:默认值为0,越大越好.
3:不发送给任何BGP邻居,只影响本路由器的选路.

方法1:
R4:(config-router)#neighbor 24.0.0.2 weight 10

方法2:

R4:(config-router)#network101.0.0.0 mask 255.0.0.0 weight 10

方法3:

3-1:定义路由
3-2:
route-map WEI permit 10

match ip address prefix-list B-110
set weight 10

3-3:
R4#(config-router)#neighbor 24.0.0.2 route-map WEI in




来自为知笔记(Wiz)
页: [1]
查看完整版本: 1.7-BGP⑤