目录
一、实验拓扑
二、实验需求
三、实验步骤
1、IP地址配置
2、As 200 内部配置OSPF
3、建立BGP邻居关系
4、宣告网段,在BGP中传递网段
5、通过修改MED 使 R1 到达 192.168.2.0/24 网段的路由经过 R3
6、通过修改Preferred-value 属性,使 R4 到达 192.168.0.0/24 网段的路由经过 R3
7、通过As_path 属性,使 R1 到达 192.168.3.0/24 网段的路由经过 R3
8、通过修改Local-pref属性,使 R4 到达 192.168.0.0/24 网段的路由经过 R3
1、按照需求配置IP 地址,R1 和 R4 配环回口模拟业务网段,R2 和 R3 、R4配置Loopbacko 口地址作为 OSPF 的 Router-id 和 IBGP 邻居地址
2、As 200 内部配置OSPF,仅用于实现 BGP 的 TCP 可达,不允许宣告业务网段
3、配置 BGP,R1和R2/R3 建立 EBGP 邻居,R4 和 R2/R3 建立 IBGP 邻居,R1 和 R4 分别把业务网段宣告进 BGP
4、通过修改MED 使 R1 到达 192.168.2.0/24 网段的路由经过 R3
5、通过修改Preferred-value 属性,使 R4 到达 192.168.0.0/24 网段的路由经过 R3
6、通过As_path 属性,使 R1 到达 192.168.3.0/24 网段的路由经过 R3
7、通过修改Local-pref属性,使 R4 到达 192.168.0.0/24 网段的路由经过 R3
[AR1]int g0/0/0
[AR1-GigabitEthernet0/0/0]ip add 100.1.1.1 24
[AR1-GigabitEthernet0/0/0]int g0/0/1
[AR1-GigabitEthernet0/0/1]ip add 100.3.3.1 24
[AR1-GigabitEthernet0/0/1]int l0
[AR1-LoopBack0]ip add 192.168.0.1 24
[AR1-LoopBack0]int l1
[AR1-LoopBack1]ip add 192.168.1.1 24
[AR2]int g0/0/0
[AR2-GigabitEthernet0/0/0]ip add 100.1.1.2 24
[AR2-GigabitEthernet0/0/0]int g0/0/1
[AR2-GigabitEthernet0/0/1]ip add 100.2.2.2 24
[AR2-GigabitEthernet0/0/1]int l0
[AR2-LoopBack0]ip add 2.2.2.2 32
[AR3]int g0/0/0
[AR3-GigabitEthernet0/0/0]ip add 100.3.3.3 24
[AR3-GigabitEthernet0/0/0]int g0/0/1
[AR3-GigabitEthernet0/0/1]ip add 100.4.4.3 24
[AR3-GigabitEthernet0/0/1]int l0
[AR3-LoopBack0]ip add 3.3.3.3 32
[AR4]int g0/0/0
[AR4-GigabitEthernet0/0/0]ip add 100.2.2.4 24
[AR4-GigabitEthernet0/0/0]int g0/0/1
[AR4-GigabitEthernet0/0/1]ip add 100.4.4.4 24
[AR4-GigabitEthernet0/0/1]int l0
[AR4-LoopBack0]ip add 4.4.4.4 32
[AR4-LoopBack0]int l1
[AR4-LoopBack1]ip add 192.168.2.1 24
[AR4-LoopBack1]int l2
[AR4-LoopBack2]ip add 192.168.3.1 24
[AR2]ospf 1 router-id 2.2.2.2
[AR2-ospf-1]a 0
[AR2-ospf-1-area-0.0.0.0]network 100.2.2.0 0.0.0.255
[AR2-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0
[AR3]ospf 1 router-id 3.3.3.3
[AR3-ospf-1]a 0
[AR3-ospf-1-area-0.0.0.0]network 100.4.4.0 0.0.0.255
[AR3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0
[AR4]ospf 1 router-id 4.4.4.4
[AR4-ospf-1]a 0
[AR4-ospf-1-area-0.0.0.0]network 100.2.2.0 0.0.0.255
[AR4-ospf-1-area-0.0.0.0]network 100.4.4.0 0.0.0.255
[AR4-ospf-1-area-0.0.0.0]network 4.4.4.4 0.0.0.0
[AR1]bgp 100
[AR1-bgp]peer 100.1.1.2 as-number 200
[AR1-bgp]peer 100.3.3.3 as-number 200
[AR2]bgp 200
[AR2-bgp]peer 100.1.1.1 as-number 100
[AR2-bgp]peer 4.4.4.4 as 200
[AR2-bgp]peer 4.4.4.4 connect-interface l0 # 修改更新源
[AR2-bgp]peer 4.4.4.4 next-hop-local # 更改下一跳
[AR3]bgp 200
[AR3-bgp]peer 100.3.3.1 as-number 100
[AR3-bgp]peer 4.4.4.4 as-number 200
[AR3-bgp]peer 4.4.4.4 connect-interface l0
[AR3-bgp]peer 4.4.4.4 next-hop-local
[AR4]bgp 200
[AR4-bgp]peer 2.2.2.2 as 200
[AR4-bgp]peer 2.2.2.2 connect-interface l0
[AR4-bgp]peer 3.3.3.3 as 200
[AR4-bgp]peer 3.3.3.3 connect-interface l0
(R1 和 R4 分别把业务网段宣告进 BGP)
[AR1]bgp 100
[AR1-bgp]network 192.168.0.0 24
[AR1-bgp]network 192.168.1.0 24
[AR4]bgp 200
[AR4-bgp]network 192.168.2.0 24
[AR4-bgp]network 192.168.3.0 24
只有被BGP宣告的网段,才能互通
(即将R2的cost【增大】)
[AR2]acl 2000
[AR2-acl-basic-2000]rule permit source 192.168.2.0 0.0.0.255 # 抓取流量,配置路由策略
[AR2]route-policy med permit node 10 # 配置空节点
[AR2-route-policy]if-match acl 2000
[AR2-route-policy]apply cost 200 # 修改cost值
[AR2]route-policy med permit node 20 # 配置空节点放行其他
[AR2]bgp 200
[AR2-bgp]peer 100.1.1.1 route-policy med export # 在R2出方向调用策略med
# 重置BGP进程命令——reset bgp all
要使 R4 到达192.168.0.0/24 网段的路由经过R3,可将R3的Preferred-value改大
[AR4]acl 2000
[AR4-acl-basic-2000]rule permit source 192.168.0.0 0.0.0.255
[AR4]route-policy pv permit node 10
[AR4-route-policy]if-match acl 2000
[AR4-route-policy]apply preferred-value 120
[AR4]bgp 200
[AR4-bgp]peer 3.3.3.3 route-policy pv import
[AR4]dis bgp routing-table
[AR1]acl 2000
[AR1-acl-basic-2000]rule permit source 192.168.3.0 0.0.0.255
[AR1]route-policy as permit node 10
[AR1-route-policy]if-match acl 2000
[AR1-route-policy]apply as-path 200 200 additive
[AR1]route-policy as permit node 20
[AR1]bgp 100
[AR1-bgp]peer 100.1.1.2 route-policy as import
[AR3-acl-basic-2000]rule permit source 192.168.0.0 0.0.0.255
[AR3]route-policy lp permit node 10
[AR3-route-policy]if-match acl 2000
[AR3-route-policy]apply local-preference 300
[AR3]route-policy lp permit node 20
[AR3-bgp]peer 4.4.4.4 route-policy lp export