一.拓扑图

二.需求
1.使用Preva1策略,确保R4通过R2到达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 Preference策略,确保R1通过R2到达192.168.1.0/24
5.使用Local Preference策略,确保R1通过R3到达192.168.2.0/24
6.配置负载均衡,确保R1通过R2和R3到达192.168.3.0/24
7.使用As策略,As 50不接受任何始发于AS123的路由
8.使用自定义community策略,确保192.168.3.0/24路由不会被发布到As 500
9、IBGP使用环回接口建邻,EBGP使用物理接口建邻
10、修改AS 123中的用户网段为Broadcast,方便后续在BGP中宣告
11、BGP宣告路由时,仅宣告24网段的用户路由
三.需求分析
- PreVal 策略:在 AR4 上配置 PreVal 策略,让其去往 192.168.10.0/24 网段时优先选择经 AR2 的路径 ,需设置相关属性使该路径在选路时更优。
- AS_Path 策略:在 AR4 上运用 AS_Path 策略,使其去往 192.168.11.0/24 网段走 AR3 路径 ,可能通过修改 AS_Path 长度或添加特定 AS 号,影响选路。
- MED 策略:配置 MED 策略控制 AR4 到 192.168.12.0/24 路由的路径 ,MED 用于向外部 AS 建议进入本 AS 时的最佳入口路径,需合理设置 MED 值引导流量。
- Local Preference 策略 - 1:在 AS 123 内配置,让 AR1 去往 192.168.1.0/24 网段时优先走 AR2 路径 ,Local Preference 在 AS 内部影响选路,值越高越优先。
- Local Preference 策略 - 2:在 AS 123 内配置,使 AR1 去往 192.168.2.0/24 网段时优先选 AR3 路径 ,同样是设置合适 Local Preference 值。
- 负载均衡:在 AS 123 内对 AR1 进行配置,使其去往 192.168.3.0/24 网段时,通过 AR2 和 AR3 实现负载均衡 ,可借助 BGP 相关属性(如多条路径属性等)实现。
- AS 策略 - 1:在 AS 500 配置策略,使其不接收 AS 123 的路由 ,可能通过 AS_Path 过滤、路由映射等方式拒绝来自 AS 123 的路由更新。
- 自定义 Community 策略:对 192.168.3.0/24 路由设置自定义 Community 属性,使该路由不发布到 AS 500 ,通过设置特定 Community 值,结合路由过滤规则实现。
- BGP 建邻:AS 123 内部 IBGP 使用环回接口建邻,增强稳定性;与外部 AS(AS 400、AS 500 )的 EBGP 使用物理接口建邻 ,需正确配置 IP 地址、邻居关系等参数。
- 网段修改:将 AS 123 中用户网段修改为 Broadcast 类型 ,方便在 BGP 中宣告,涉及子网掩码、网络类型等配置调整。
- BGP 宣告:配置 BGP 宣告路由时,仅宣告 24 网段的用户路由 ,需在 BGP 进程中准确配置网络宣告语句,过滤非 24 网段路由。
五.配置
IP配置
[R1]int l 0
[R1-LoopBack0]ip add 1.1.1.1 32
[R1-LoopBack0]int l 1
[R1-LoopBack1]ip add 192.168.100.1 24
[R1-LoopBack1]int g 0/0/0
[R1-GigabitEthernet0/0/0]ip add 12.0.0.2 24
[R1-GigabitEthernet0/0/0]int g 0/0/1
[R1-GigabitEthernet0/0/1]ip add 13.0.0.2 24
[R1-GigabitEthernet0/0/1]int g 0/0/2
[R1-GigabitEthernet0/0/2]ip add 15.0.0.1 24
[R2]int l 0
[R2-LoopBack0]ip add 2.2.2.2 32
[R2-LoopBack0]int l 1
[R2-LoopBack1]ip add 192.168.20.1 24
[R2-LoopBack1]int g 0/0/0
[R2-GigabitEthernet0/0/0]ip add 24.0.0.2 24
[R2-GigabitEthernet0/0/0]int g 0/0/1
[R2-GigabitEthernet0/0/1]ip add 12.0.0.1 24
[R3]int l 0
[R3-LoopBack0]ip add 3.3.3.3 32
[R3-LoopBack0]int l 1
[R3-LoopBack1]ip add 192.168.30.1 24
[R3-LoopBack1]int g 0/0/0
[R3-GigabitEthernet0/0/0]ip add 34.0.0.2 24
[R3-GigabitEthernet0/0/0]int g 0/0/1
[R3-GigabitEthernet0/0/1]ip add 13.0.0.1 24
[R4]int l 0
[R4-LoopBack0]ip add 192.168.1.1 24
[R4-LoopBack0]int l 1
[R4-LoopBack1]ip add 192.168.2.1 24
[R4-LoopBack1]int l 2
[R4-LoopBack2]ip add 192.168.3.1 24
[R4-LoopBack2]int g 0/0/0
[R4-GigabitEthernet0/0/0]ip add 24.0.0.1 24
[R4-GigabitEthernet0/0/0]int g 0/0/1
[R4-GigabitEthernet0/0/1]ip add 34.0.0.1 24
[R5]int l 0
[R5-LoopBack0]ip add 192.168.10.1 24
[R5-LoopBack0]int l 1
[R5-LoopBack1]ip add 192.168.11.1 24
[R5-LoopBack1]int l 2
[R5-LoopBack2]ip add 192.168.12.1 24
[R5-LoopBack2]int g 0/0/0
[R5-GigabitEthernet0/0/0]ip add 15.0.0.2 24
检查直连

修改环回接口网络类型
[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
OSPF配置
[R1]ospf 1 rou 1.1.1.1
[R1-ospf-1]a 0
[R1-ospf-1-area-0.0.0.0]net 1.1.1.1 0.0.0.0
[R1-ospf-1-area-0.0.0.0]net 12.0.0.2 0.0.0.0
[R1-ospf-1-area-0.0.0.0]net 13.0.0.2 0.0.0.0
[R1-ospf-1-area-0.0.0.0]net 192.168.100.1 0.0.0.0
[R2]ospf 1 rou 2.2.2.2
[R2-ospf-1]a 0
[R2-ospf-1-area-0.0.0.0]net 2.2.2.2 0.0.0.0
[R2-ospf-1-area-0.0.0.0]net 192.168.20.1 0.0.0.0
[R2-ospf-1-area-0.0.0.0]net 12.0.0.1 0.0.0.0
[R3]ospf 1 rou 3.3.3.3
[R3-ospf-1]a 0
[R3-ospf-1-area-0.0.0.0]net 3.3.3.3 0.0.0.0
[R3-ospf-1-area-0.0.0.0]net 192.168.30.1 0.0.0.0
[R3-ospf-1-area-0.0.0.0]net 13.0.0.1 0.0.0.0
测试
BGP配置
启动BGP协议
[R4]bgp 400
[R4-bgp]router-id 4.4.4.4
[R4-bgp]peer 24.0.0.2 as 123
[R4-bgp]peer 34.0.0.2 as 123
[R2]bgp 123
[R2-bgp]router-id 2.2.2.2
[R2-bgp]peer 24.0.0.1 as 400
[R2-bgp]peer 1.1.1.1 as 123
[R2-bgp]peer 1.1.1.1 con l0
[R2-bgp]peer 1.1.1.1 next-hop-local
[R3]bgp 123
[R3-bgp]router-id 3.3.3.3
[R3-bgp]peer 34.0.0.1 as 400
[R3-bgp]peer 1.1.1.1 as 123
[R3-bgp]peer 1.1.1.1 con l0
[R3-bgp]peer 1.1.1.1 next-hop-local
[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 con l0
[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 con l0
[R1-bgp]peer 3.3.3.3 next-hop-local
[R1-bgp]peer 15.0.0.2 as 500
[R5]bgp 500
[R5-bgp]router-id 5.5.5.5
[R5-bgp]peer 15.0.0.1 as 123
检查邻接关系:
BGP宣告
[R4]bgp 400
[R4-bgp]net 192.168.1.0 24
[R4-bgp]net 192.168.2.0 24
[R4-bgp]net 192.168.3.0 24
[R2]bgp 123
[R2-bgp]net 192.168.20.0 24
[R3]bgp 123
[R3-bgp]net 192.168.30.0 24
[R1]bgp 123
[R1-bgp]net 192.168.100.0 24
[R5]bgp 500
[R5-bgp]net 192.168.10.0 24
[R5-bgp]net 192.168.11.0 24
[R5-bgp]net 192.168.12.0 24
使用PreVa1策略,确保R4通过R2到达192.168.10.0/24
[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 100
Info: New Sequence of this List.
[R4-route-policy]q
[R4]bgp 400
[R4-bgp]peer 24.0.0.2 route-policy pv import
使用AS_Path策略,确保R4通过R3到达192.168.11.0/24
[R4]ip ip-prefix ap permit 192.168.11.0 24
[R4]route-policy pv permit node 20
Info: New Sequence of this List.
[R4-route-policy]if-match ip-prefix ap
[R4-route-policy]apply as-path 123 additive
[R4-route-policy]q
配置MED策略,确保R4通过R3到达192.168.12.0/24
[R4]ip ip-prefix med permit 192.168.12.0 24
[R4]route-policy pv permit node 30
Info: New Sequence of this List.
[R4-route-policy]if-match ip-prefix med
[R4-route-policy]apply cost 20
[R4-route-policy]q
三个配置完成后检查R4 BGP
使用Local Preference策略,确保R1通过R2到达192.168.1.0/24
[R1]ip ip-prefix lp1 permit 192.168.1.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 100
Info: New Sequence of this List.
[R1-route-policy]q
[R1]bgp 123
[R1-bgp]peer 2.2.2.2 route-policy lp1 import
使用Local Preference策略,确保R1通过R3到达192.168.2.0/24
[R1]ip ip-prefix lp2 permit 192.168.2.0 24
[R1]route-policy lp2 permit node 10
Info: New Sequence of this List.
[R1-route-policy]if-match ip-prefix lp2
[R1-route-policy]apply local-preference 200
[R1-route-policy]q
[R1]route-policy lp2 permit node 100
Info: New Sequence of this List.
[R1-route-policy]q
[R1]bgp 123
[R1-bgp]peer 3.3.3.3 route-policy lp2 import
配置负载均衡,确保R1通过R2和R3到达192.168.3.0/24
[R1]bgp 123
[R1-bgp]maximum load-balancing 2
检查R1BGP:
使用As策略,AS 500不接受任何始发于AS 123的路由
[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 import
使用自定义Community策略,确保192.168.3.0/24路由不会被发布到AS 500
[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]net 192.168.3.0 24 route-policy com-1
[R4-bgp]peer 24.0.0.2 advertise-community
[R4-bgp]peer 34.0.0.2 advertise-community
[R2]bgp 123
[R2-bgp]peer 1.1.1.1 advertise-community
[R3]bgp 123
[R3-bgp]peer 1.1.1.1 advertise-community
[R2]ip community-filter 1 permit 400:111
[R2]route-policy com permit 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-route-policy]q
[R3]ip community-filter 1 permit 400:111
[R3]route-policy com permit 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-route-policy]q
[R2]bgp 123
[R2-bgp]peer 24.0.0.1 route-policy com import
[R3]bgp 123
[R3-bgp]peer 34.0.0.1 route-policy com import
检查是否成功


942

被折叠的 条评论
为什么被折叠?



