当前位置:文档之家› BGP-AS-PATH

BGP-AS-PATH

[BGP-AS-PATH]

本文档详细描述了BGP中as-path影响选路的具体内容以及利用正则表达式作策略

目录

BGP-TASK-13

第一章题目描述 (1)

1.1原题摘录 (1)

1.2题目概述 (1)

第二章实验设计 (2)

2.1实验top图 (2)

2.2 IP地址规划表 (2)

2.3设计思路 (3)

2.4实验预配置 (3)

2.5实验分析 (6)

第三章实验总结 (14)

第一章题目描述1.1原题摘录

1.2题目概述

第二章实验设计2.1实验top图

2.2 IP地址规划表

2.3设计思路

首先分析整个top图,可以看出,起始时R1和R5环回口之间通信的路径为R1-R4-R5,R5-R4-R1,我们可以通过在R1的f0/0.14的in方向将5.5.5.5/32这个路由的as-path值增大,以及在R5的f0/0.45的in方向将1.1.1.1/32这个路由的as-path值增大,从而使原来的次优路径优于最优路径,将两路由器环回口之间通信的路径改成R1-R2-R3-R5,R5-R3-R2-R1,同理,在R2和R4上做类似的策略将两路由器环回口通信的路径改为R2-R3-R5-R4,R4-R5-R3-R2。然后通过利用正则表达式来实现8和9这两个需求

2.4实验预配置

R1

hostname R1

!

interface Loopback0

ip address 1.1.1.1 255.255.255.255

!

interface FastEthernet0/0.12

encapsulation dot1Q 12

ip address 12.1.1.1 255.255.255.0

!

interface FastEthernet0/0.14

encapsulation dot1Q 14

ip address 14.1.1.1 255.255.255.0

!

router bgp 100

no synchronization

bgp log-neighbor-changes

network 1.1.1.1 mask 255.255.255.255

neighbor 12.1.1.2 remote-as 500

neighbor 14.1.1.4 remote-as 300

end

R2

hostname R2

!

interface Loopback0

ip address 2.2.2.2 255.255.255.255

!

interface FastEthernet0/0.12 encapsulation dot1Q 12

ip address 12.1.1.2 255.255.255.0

!

interface FastEthernet0/0.23 encapsulation dot1Q 23

ip address 23.1.1.2 255.255.255.0

!

router bgp 500

no synchronization

bgp log-neighbor-changes

network 2.2.2.2 mask 255.255.255.255 neighbor 12.1.1.1 remote-as 100 neighbor 23.1.1.3 remote-as 200

!

end

R3

hostname R3

interface Loopback0

ip address 3.3.3.3 255.255.255.255

!

interface FastEthernet0/0.23 encapsulation dot1Q 23

ip address 23.1.1.3 255.255.255.0

!

interface FastEthernet0/0.35 encapsulation dot1Q 35

ip address 35.1.1.3 255.255.255.0

!

router bgp 200

no synchronization

bgp log-neighbor-changes

network 3.3.3.3 mask 255.255.255.255

neighbor 23.1.1.2 remote-as 500 neighbor 35.1.1.5 remote-as 400

no auto-summary

!

end

R4

hostname R4

!

interface Loopback0

ip address 4.4.4.4 255.255.255.255

!

interface FastEthernet0/0.14 encapsulation dot1Q 14

ip address 14.1.1.4 255.255.255.0

!

interface FastEthernet0/0.45 encapsulation dot1Q 45

ip address 45.1.1.4 255.255.255.0

!

router bgp 300

no synchronization

bgp log-neighbor-changes

network 4.4.4.4 mask 255.255.255.255 neighbor 14.1.1.1 remote-as 100 neighbor 45.1.1.5 remote-as 400

!

end

R5

hostname R5

!

interface Loopback0

ip address 5.5.5.5 255.255.255.255

!

!

interface FastEthernet0/0.35 encapsulation dot1Q 35

ip address 35.1.1.5 255.255.255.0

!

interface FastEthernet0/0.45

encapsulation dot1Q 45

ip address 45.1.1.5 255.255.255.0

!

router bgp 400

no synchronization

bgp log-neighbor-changes

network 5.5.5.5 mask 255.255.255.255

neighbor 35.1.1.3 remote-as 200

neighbor 45.1.1.4 remote-as 300

!

end

2.5实验分析

每台路由器通过静态发布的方式将自己的环回口宣告进BGP进程中,现在全网收敛,以R1为例查看BGP表

现在通过修改as-path的值来影响R1和R5以及R2和R4环回口之间的通信,以R1和R5为例

首先在做策略之前查看R1和R5的BGP表,分析两台路由器的环回口之间通信的路径

R1的BGP表

R5的BGP表

通过分析两个路由器的路由表,发现R1和R5两路由器环回口通信的路径为R1-R4-R5,R5-R4-R1,通过在R1和R5上做以下操作来实现更改两环回口通信路径

在R1上操作为

R1(config)#access-list 10 permit 5.5.5.5

R1(config)#route-map 10 permit 10

R1(config-route-map)#match ip add 10

R1(config-route-map)#set as-path prepend 10 20

R1(config)#route-map 10 permit 20

R1(config)#router bgp 100

R1(config-router)#neighbor 14.1.1.4 route-map 10 in

这样做的目的是为了将R4传给R1关于5.5.5.5/32这条路由的as-path改大,从而使R1选择去往5.5.5.5/32这个目的的路径改为R1-R2-R3-R5 同样在R5上操作为

R5(config)#access-list 10 permit 1.1.1.1

R5(config)#route-map 10 permit 10

R5(config-route-map)#match ip add 10

R5(config-route-map)#set as-path prepend 30 40

R5(config)#route-map 10 permit 20

R5(config)#router bgp 400

R5(config-router)#neighbor 45.1.1.4 route-map 10 in

通过这样的操作就使R5去往 1.1.1.1/32这个目的的路径改为R5-R3-R2-R1

在做了策略之后查看R1和R5的BGP表,分析两路由器环回口的通信路径R1的BGP表

R5的BGP表

通过分析上面两个截图内容,可以清楚的看到R1和R5两路由器环回口之间的通信路径为R1-R2-R3-R5,R5-R3-R2-R1,原因就是将原来的最优路径的as-path值增大至大于次优路径,从而使原来的次优路径变为目前的最优路径。

同样,在R2和R4上做类似的操作,这里不再赘述,只看实验结果

做策略前

R2的BGP表

R4的BGP表

作策略后

R2的BGP表

R4的BGP表

通过对比做策略前后R2、R4 BGP表的变化可以得出,R2和R4两路由器环回口之间通信的路径由原来的R2-R1-R4,R4-R2-R1变为了R2-R3-R5-R4,R4-R5-R3-R2

下面通过利用正则表达式将需求AS中的路由附上团体属性

首先在R3上将起始为AS 300的BGP路由附上团体属性为300:300,通过分析top图可以发现,去往AS 300将R3作为最佳路径的下一跳的路由器只有R2,也就是说只有R2才能收到R3传来的4.4.4.4/32这条路由,所以在R3的f0/0.23接口的out方向将自己传给R2的起始为AS 300的BGP路由附上团体属性然后传给R2,具体操作如下

R3(config)#ip as-path access-list 10 permit _300$

R3(config)#route-map 10 permit 10

R3(config-route-map)#match as-path 10

R3(config-route-map)#set community 300:300

R3(config)#route-map 10 permit 20

R3(config)#router bgp 200

R3(config-router)#neighbor 23.1.1.2 route-map 10 out

R3(config-router)#neighbor 23.1.1.2 send-community

Note:ip bgp-community new-format这个命令在每台路由器上都要输入,应为AA:AA这个团体属性是新形式,路由器默认不能识别

然后在R2上查看策略是否有效

由上图可以看出R3上策略生效,这个策略的好处就是,如果R3传给R2起始为AS 300的BGP路由较多时,R2可以通过对这个团体进行操作来对这一组BGP路由做策略,大大节省了不必要的工作

如果也在R2上对R1使用了send-community,那么R1上显示起始为AS 300的BGP路由团体属性也为300:300,如下图

同样,在R5做类似的操作,将经过AS 200的BGP路由附上团体属性123:123,具体操作如下

R5(config)#ip as-path access-list 10 permit _200_

R5(config)#route-map 20 permit 10

R5(config-route-map)#match as-path 10

R5(config-route-map)#set community 123:123

R5(config)#route-map 20 permit 20

R5(config)#router bgp 400

R5(config-router)#neighbor 45.1.1.4 route-map 20 out

Note:由于前面在R5上做过策略,所以现在要起一个route-map 20

现在在R4上查看R5上的策略是否生效

由上图可以看出只要途径AS 200的BGP路由都被附上了团体属性123:123

第三章实验总结

相关主题
文本预览
相关文档 最新文档