目录
第一步:配置IP及环回
联通测试,确保IP配置正常:
第二步:起OSPF(IGP)
联通测试:
第三步:起BGP协议
将回环接口修改成相同类型
第四步:宣告BGP路由
第五步:实现相关要求
1、使用PreVal策略,确保R4通过R3到达192.168.10.0/24
编辑
2、使用AS_Path策略,确保R4通过R3到达192.168.11.0/24
编辑
3、配置MED策略,确保R4通过R3到达192.168.12.0/24
4、使用Local Perference策略,确保R1通过R2到达192.168.1.0/24
编辑
5、使用Local Perference策略,确保R1通过R3到达192.168.2.0/24
编辑6、配置负载均衡,确保R1通过R2和R3到达192.168.3.0/24
编辑7、使用AS策略,AS 500不接受任何始发于AS 123的路由
编辑8、使用自定义Community策略,确保192.168.3.0/24路由不被发布到AS 500
编辑编辑
编辑编辑9、IBGP使用换回接口建邻,EBGP使用物理接口建邻10、修改AS 123中的用户网段为Broadcast,方便后续在BGP中宣告11、BGP宣告路由时,仅宣告24网段的用户路由
要求:
1、使用PreVal策略,确保R4通过R3到达192.168.10.0/24
2、使用AS_Path策略,确保R4通过R3到达192.168.11.0/24
3、配置MED策略,确保R4通过R3到达192.168.12.0/24
4、使用Local Perference策略,确保R1通过R2到达192.168.1.0/24
5、使用Local Perference策略,确保R1通过R3到达192.168.2.0/24
6、配置负载均衡,确保R1通过R2和R3到达192.168.3.0/24
7、使用AS策略,AS 500不接受任何始发于AS 123的路由
8、使用自定义Community策略,确保192.168.3.0/24路由不被发布到AS 500
9、IBGP使用换回接口建邻,EBGP使用物理接口建邻
10、修改AS 123中的用户网段为Broadcast,方便后续在BGP中宣告
11、BGP宣告路由时,仅宣告24网段的用户路由
[r1]int g 0/0/0
[r1-GigabitEthernet0/0/0]ip a 11.0.0.1 24
[r1]int g 0/0/1
[r1-GigabitEthernet0/0/1]ip a 13.0.0.1 24
[r1]int g 0/0/2
[r1-GigabitEthernet0/0/2]ip a 15.0.0.1 24
[r1]int l 0
[r1-LoopBack0]ip a 1.1.1.1 32
[r1]int l 1
[r1-LoopBack1]ip a 192.168.10.1 24
[r2]int g 0/0/0
[r2-GigabitEthernet0/0/0]ip a 12.0.0.2 24
[r2]int g 0/0/1
[r2-GigabitEthernet0/0/1]ip a 11.0.0.2 24
[r2]int l 0
[r2-LoopBack0]ip a 2.2.2.2 32
[r2]int l 1
[r2-LoopBack1]ip a 192.168.20.1 24
[r3]int g 0/0/0
[r3-GigabitEthernet0/0/0]ip a 14.0.0.3 24
[r3-GigabitEthernet0/0/0]int g 0/0/1
[r3-GigabitEthernet0/0/1]ip a 13.0.0.3 24
[r3]int l 0
[r3-LoopBack0]ip a 3.3.3.3 32
[r3]int l 1
[r3-LoopBack1]ip a 192.168.30.1 24
[r4]int g 0/0/0
[r4-GigabitEthernet0/0/0]ip a 12.0.0.4 24
[r4]int g 0/0/1
[r4-GigabitEthernet0/0/1]ip a 14.0.0.4 24
[r4]int l 0
[r4-LoopBack0]ip a 192.168.1.1 24
[r4]int l 1
[r4-LoopBack1]ip a 192.168.2.1 24
[r4]int l 2
[r4-LoopBack2]ip a 192.168.3.1 24
[r5]int g 0/0/0
[r5-GigabitEthernet0/0/0]ip a 15.0.0.1 24
[r5]int l 0
[r5-LoopBack0]ip a 192.168.10.1 24
[r5]int l 1
[r5-LoopBack1]ip a 192.168.11.1 24
[r5]int l 2
[r5-LoopBack2]ip a 192.168.12.1 24
[r1]ospf 1 router-id 1.1.1.1
[r1-ospf-1]area 0
[r1-ospf-1-area-0.0.0.0]network 1.1.1.1 0.0.0.0
[r1-ospf-1-area-0.0.0.0]network 11.0.0.1 0.0.0.0
[r1-ospf-1-area-0.0.0.0]network 13.0.0.1 0.0.0.0
[r1-ospf-1-area-0.0.0.0]network 192.168.100.1 0.0.0.0
[r2]ospf 1 router-id 2.2.2.2
[r2-ospf-1]area 0
[r2-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0
[r2-ospf-1-area-0.0.0.0]network 11.0.0.2 0.0.0.0
[r2-ospf-1-area-0.0.0.0]network 192.168.20.1 0.0.0.0
[r3]ospf 1 router-id 3.3.3.3
[r3-ospf-1]area 0
[r3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0
[r3-ospf-1-area-0.0.0.0]network 13.0.0.3 0.0.0.0
[r3-ospf-1-area-0.0.0.0]network 192.168.30.1 0.0.0.0
[r1]bgp 123
[r1-bgp]router-id 1.1.1.1
[r1-bgp]peer 2.2.2.2 as 123
[r1-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[r1-bgp]peer 2.2.2.2 next-hop-local
[r1-bgp]peer 3.3.3.3 as 123
[r1-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[r1-bgp]peer 3.3.3.3 next-hop-local
[r2]bgp 123
[r2-bgp]router-id 2.2.2.2
[r2-bgp]peer 12.0.0.3 as 400
[r2-bgp]peer 1.1.1.1 as 123
[r2-bgp]peer 1.1.1.1 connect-interface LoopBack 0
[r2-bgp]peer 1.1.1.1 next-hop-local
[r3]bgp 123
[r3-bgp]router-id 3.3.3.3
[r3-bgp]peer 14.0.0.4 as 400
[r3-bgp]peer 1.1.1.1 as 123
[r3-bgp]peer 1.1.1.1 connect-interface LoopBack 0
[r3-bgp]peer 1.1.1.1 next-hop-local
[r4]bgp 400
[r4-bgp]router-id 4.4.4.4
[r4-bgp]peer 12.0.0.2 as 123
[r4-bgp]peer 14.0.0.3 as 123
[r5]bgp 500
[r5-bgp]router-id 5.5.5.5
[r5-bgp]peer 15.0.0.5 as 123
[r1]int l 1
[r1-LoopBack1]ospf network-type broadcast
[r2]int l 1
[r2-LoopBack1]ospf network-type broadcast
[r3]int l 1
[r3-LoopBack1]ospf network-type broadcast
[r1]bgp 123
[r1-bgp]network 192.168.100.0 24
[r2]bgp 123
[r2-bgp]network 192.168.20.0 24
[r3]bgp 123
[r3-bgp]network 192.168.30.0 24
[r4]bgp 400
[r4-bgp]network 192.168.1.0 24
[r4-bgp]network 192.168.2.0 24
[r4-bgp]network 192.168.3.0 24
[r5]bgp 500
[r5-bgp]network 192.168.10.0 24
[r5-bgp]network 192.168.11.0 24
[r5-bgp]network 192.168.12.0 24
查看路由学习情况
PV属性,是华为的私有属性,可以看做为权重,数值越大,对应的路由优先级越高。默认值为0。 因为PV值是所有选路原则中的第一条原则,所以,该属性是本设备上选路最方便的一个属性——该属性只有在本地生效,无法传递给任何BGP对等体。
[r4]ip ip-prefix PV permit 192.168.10.0 24
[r4]route-policy PV permit node 10
Info: New Sequence of this List.
[r4-route-policy]if-match ip-prefix PV
[r4-route-policy]apply preferred-value 100
[r4-route-policy]q
[r4]route-policy PV permit node 80
Info: New Sequence of this List.
[r4-route-policy]q
[r4]bgp 400
[r4-bgp]peer 12.0.0.2 route-policy PV import
AS-Path属性越短则该路由越优,因为这条路径距离目的地所要经过的AS个数更少。
AS_Path属性最开始是空的列表,当该路由被通告给一个EBGP对等体邻居时,才会被加上一个AS号,在每次经过一个AS时,都会在AS_Path属性的最前端增加最新的AS号。而该属性在IBGP对等体之间传播时,这条属性是不会发生改变的。
[r4]ip ip-prefix AS permit 192.168.11.0 24
[r4]route-policy AS permit node 10
Info: New Sequence of this List.
[r4-route-policy]if-match ip-prefix AS
[r4-route-policy]apply as-path 123 overwrite
[r4-route-policy]q
MED值是继承了IGP协议的度量值。
MED属性值可以传递给自己的EBGP对等体,并且该EBGP对等体可以将该路由传递给自己的IBGP对等体,并且因为AS-BY-AS规则,该属性在IBGP对等体之间传递时不变。
MED属性可以干扰访问本地的流量的走向。也就是说,本AS的策略调整可以影响到别的AS对路径的判断,这是在BGP选路中唯一一个可以影响到其他AS的属性。
BGP规定,非本地始发的BGP路由信息,在传递给自己的EBGP对等体时,将MED值修改为0。
[r4]ip ip-prefix MED permit 192.168.12.0 24
[r4]route-policy MED permit node 20
Info: New Sequence of this List.
[r4-route-policy]if-match ip-prefix MED
[r4-route-policy]apply cost 10
[r4-route-policy]q
[r4]route-policy MED permit node 10
Info: New Sequence of this List.
该属性的默认值为100,并且LP属性只能在IBGP对等体之间传递,而不能在EBGP对等体之间传递。
如果路由在传递到本地时并不携带LP属性,则BGP在决策时,使用缺省值来计算。该属性越大越优。该属性的传递范围为本AS内部。该属性是AS内部优选路由的最佳选择。
[r1]ip ip-prefix LP permit 192.168.1.0 24
[r1]route-policy LP permit node 10
Info: New Sequence of this List.
[r1-route-policy]if-match ip-prefix LP
[r1-route-policy]apply local-preference 200
[r1-route-policy]q
[r1]bgp 123
[r1-bgp]peer 2.2.2.2 route-policy LP import
[r1]ip ip-prefix LP1 permit 192.168.2.0 24
[r1]route-policy LP1 permit node 10
Info: New Sequence of this List.
[r1-route-policy]if-match ip-prefix LP1
[r1-route-policy]apply local-preference 200
[r1-route-policy]q
[r1]route-policy LP1 permit node 20
Info: New Sequence of this List.
[r1-route-policy]q
[r1]bgp 123
[r1-bgp]peer 3.3.3.3 route-policy LP1 import
[r1]bgp 123
[r1-bgp]maximum load-balancing 2
[r5]ip as-path-filter 1 deny _123$
[r5]ip as-path-filter 1 permit .*
[r5]bgp 500
[r5-bgp]peer 15.0.0.1 as-path-filter 1 export
[r2]bgp 123
[r2-bgp]peer 1.1.1.1 advertise-community
[r2]ip community-filter 1 permit 400:111
[r2]route-policy com deny node 10
Info: New Sequence of this List.
[r2-route-policy]if-match community-filter 1
[r2-route-policy]apply community no-export additive
[r2-route-policy]q
[r2]route-policy com permit node 100
Info: New Sequence of this List.
[r2]bgp 123
[r2-bgp]peer 12.0.0.4 route-policy com import
[r3]bgp 123
[r3-bgp]peer 1.1.1.1 advertise-community
[r3]ip community-filter 1 permit 400:111
[r3]route-policy com deny node 10
Info: New Sequence of this List.
[r3-route-policy]if-match community-filter 1
[r3-route-policy]apply community no-export additive
[r3-route-policy]q
[r3]route-policy com permit node 100
Info: New Sequence of this List.
[r3]bgp 123
[r3-bgp]peer 14.0.0.4 route-policy com import
[r4]route-policy com-1 permit node 10
Info: New Sequence of this List.
[r4-route-policy]apply community 400:111
[r4-route-policy]q
[r4]bgp 400
[r4-bgp]network 192.168.3.0 24 route-policy com-1
[r4-bgp]peer 12.0.0.2 advertise-ext-community
[r4-bgp]peer 14.0.0.3 advertise-ext-community
OVER