实验要求、
实现 路径控制 分别使用
AS-path
locprf
prefal
med 属性实现选路
R1-R2-R4
R1-R3_R4
实验思路
1.先配置好相应的ip地址,loopback 0,ospf,对等体
R1配置 配置ip,bgp邻居
sy
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 10.0.12.1 24
[Huawei-GigabitEthernet0/0/0]undo sh
[Huawei-GigabitEthernet0/0/0]q
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 10.0.13.1 24
[Huawei-GigabitEthernet0/0/1]undo sh
[Huawei-GigabitEthernet0/0/1]q
[Huawei]int LoopBack 0
[Huawei-LoopBack0]ip add 1.1.1.1 32
[Huawei-LoopBack0]q
[Huawei]
[Huawei]bgp 100
[Huawei-bgp]router-id 1.1.1.1 建立相应的对等体
[Huawei-bgp]peer 10.0.12.2 as-number 200
[Huawei-bgp]peer 10.0.13.3 as-number 200
R2配置 对等体 bgp ip地址
Ospf
[Huawei]q
sy
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 10.0.12.2 24
[Huawei-GigabitEthernet0/0/0]undo sh
[Huawei-GigabitEthernet0/0/0]q
[Huawei]int g0/0/1 ^
[Huawei-GigabitEthernet0/0/1]ip add 10.0.24.2 24
[Huawei-GigabitEthernet0/0/1]undo sh
[Huawei-GigabitEthernet0/0/1]
[Huawei-GigabitEthernet0/0/1]q
[Huawei]int LoopBack 0
[Huawei-LoopBack0]ip add 2.2.2.2 32
[Huawei-LoopBack0]q
[Huawei]bgp 200 建立邻居关系
[Huawei-bgp]router-id 2.2.2.2
[Huawei-bgp]peer 10.0.12.1 as-number 100
[Huawei-bgp]peer 10.0.24.4 as-number 200
[Huawei-bgp]
Huawei]ospf 1 配置ospf宣告内部网段
[Huawei-ospf-1]area 0
[Huawei-ospf-1-area-0.0.0.0]network 10.0.24.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]
R3配置 IP地址 对等体 ospf
sy
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 10.0.13.3 24
[Huawei-GigabitEthernet0/0/0]undo sh
[Huawei-GigabitEthernet0/0/0]q
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 10.0.34.3 24
[Huawei-GigabitEthernet0/0/1]undo sh
[Huawei-GigabitEthernet0/0/1]q
[Huawei]int LoopBack 0
[Huawei-LoopBack0]ip add 3.3.3.3 32
[Huawei-LoopBack0]q
[Huawei]bgp 200 建立对等体关系
[Huawei-bgp]router-id 3.3.3.3
[Huawei-bgp]peer 10.0.13.1 as-number 100
[Huawei-bgp]peer 10.0.34.4 as-number 200
[Huawei-bgp]q
[Huawei]ospf 1 宣告内部网段ospf
[Huawei-ospf-1]area 0
[Huawei-ospf-1-area-0.0.0.0]network 10.0.34.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]
R4配置
sy [Huawei]int g0/0/0 [Huawei-GigabitEthernet0/0/0]ip add 10.0.24.4 24 [Huawei-GigabitEthernet0/0/0]undo sh [Huawei-GigabitEthernet0/0/0]q[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 10.0.34.4 24
[Huawei-GigabitEthernet0/0/1]undo sh
[Huawei-GigabitEthernet0/0/1]q
[Huawei]int LoopBack 0
[Huawei-LoopBack0]ip add 4.4.4.4 32
[Huawei-LoopBack0]q
[Huawei]bgp 200 建立对等体
[Huawei-bgp]router-id 4.4.4.4
[Huawei-bgp]peer 10.0.24.2 as-number 200
[Huawei-bgp]peer 10.0.34.3 as-number 200
[Huawei-bgp]q
[Huawei]ospf 1 ospf内部宣告
[Huawei-ospf-1]area 0
[Huawei-ospf-1-area-0.0.0.0]network 10.0.24.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]network 10.0.34.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]q
步骤二
R2和R3配置配置IBGP下一跳可达
R2配置
[Huawei]bgp 200
[Huawei-bgp]peer 10.0.24.4 next-hop-local
[Huawei-bgp]
R3配置
[Huawei]bgp 200
[Huawei-bgp]peer 10.0.34.4 next-hop-local
[Huawei-bgp]
步骤三
R1和 R4在BGP里宣告自己的id 地址 然后查看
R1配
[Huawei]bgp 100
[Huawei-bgp]network 1.1.1.1 32
[Huawei-bgp]
R4宣告
[Huawei]
[Huawei]bgp 200
[Huawei-bgp]network 4.4.4.4 32
[Huawei-bgp]
查看命令 ,display bgp routing-table
步骤三,通过配置路由条属性使bgp选路控制变化
实验一 : AS-path属性配置
注: 比较路径成本大小,小的为最佳路径
R2配置
[Huawei]route-policy yzq permit node 10 //创建名为yzq的路由策略
Info: New Sequence of this List.
[Huawei-route-policy]apply as-path 666 666 additive //设置as-path属性为666 666
[Huawei-route-policy]q
[Huawei]bgp 200 bgp应用策略
[Huawei-bgp]peer 10.0.24.4 route-policy yzq export
[Huawei-bgp]q
[Huawei]q
refresh bgp all import 刷新bgp属性
做完清除AS-Path 好做下一个实验
R2
Huawei]bgp 200
[Huawei-bgp]undo peer 10.0.24.4 route-policy yzq export
[Huawei-bgp]
OK进入下一个实验
实验二
配置locprf
注:比较本地优先级大小,大的为最佳路径
R3配置
[Huawei]route-policy lzq permit node 10 //创建路由策略名lzq
Info: New Sequence of this List.
[Huawei-route-policy]apply local-preference 666 设置本地优先级为666
[Huawei-route-policy]q
[Huawei]bgp 200 应用lzq策略
[Huawei-bgp]peer 10.0.34.4 route-policy lzq export
[Huawei]q
refresh bgp all import 刷新bgp路由
做完 R3清除Locprf配置 做好做下一个实验准备
3ODg0,size_16,color_FFFFFF,t_70)
R3配置
[Huawei]bgp 200
[Huawei-bgp]undo peer 10.0.34.4 route-policy lzq export
[Huawei-bgp]
OK。完成准备做下一个实验
实验三
MED配置
注:比较MED值大小,小的为最佳路径
R2配置
[Huawei]route-policy qqq permit node 10 //创建qqq路由策略
Info: New Sequence of this List.
[Huawei-route-policy]apply cost + 300 //修改MED值为300
[Huawei-route-policy]q
[Huawei]bgp 200 //bgp应用策略
[Huawei-bgp]peer 10.0.12.1 route-policy qqq export
[Huawei-bgp]q
refresh bgp all import 刷新bgp路由
R1查看效果
完成
实验四
配置策略路由local-Preference
使流量分开走
192.168.1.0网段走R2路由器
192.168.2.0 网段走R3路由器
R1配置 创建2个loopback口,添加192.168.1.0和192.168.2.0网段再从bgp宣告出去
sy Enter system view, return user view with Ctrl+Z. [Huawei]int loopback 1 创建网段 [Huawei-LoopBack1]ip add 192.168.1.1 24 [Huawei-LoopBack1]q[Huawei]int loopback 2 创建网段
[Huawei-LoopBack2]ip add 192.168.2.1 24
[Huawei-LoopBack2]q
[Huawei]bgp 100 宣告
[Huawei-bgp]network 192.168.1.0 24
[Huawei-bgp]network 192.168.2.0 24
[Huawei-bgp]
R4查看bgp路由表
R2配置路由策略LOCAL-preference使192.168.1.1网段走上面
[Huawei]
[Huawei]acl number 2000 创建acl 192.168.1.0网段
[Huawei-acl-basic-2000]rule permit source 192.168.1.0 0.0.0.255
[Huawei-acl-basic-2000]q
[Huawei]route-policy zzz permit node 10 //创建路由策略zzz 10
Info: New Sequence of this List.
[Huawei-route-policy]if-match acl 2000 //匹配acl 2000
[Huawei-route-policy]apply local-preference 2000 //设置加优先级2000
[Huawei-route-policy]q
[Huawei]route-policy zzz permit node 20 //创建路由策略 zzz 20
Info: New Sequence of this List.
[Huawei-route-policy]apply local-preference 1000 // 设置优先级1000
[Huawei-route-policy]q
[Huawei]bgp 200
[Huawei-bgp]peer 10.0.12.1 route-policy zzz import //应用规则
[Huawei-bgp]
R3配置路由策略LOCAL-preference使192.168.2.1网段走上面
[Huawei]acl 2000 //创建acl 2000 设置网段
[Huawei-acl-basic-2000]rule permit source 192.168.2.0 0.0.0.255
[Huawei-acl-basic-2000]q
[Huawei]route-policy ppp permit node 10 //创建策略ppp 10
Info: New Sequence of this List.
[Huawei-route-policy]if-match acl 2000 //匹配acl 2000
[Huawei-route-policy]apply local-preference 2000 //设置本地优先级2000
[Huawei-route-policy]q
[Huawei]route-policy ppp permit node 20 //创建策略 ppp 20
Info: New Sequence of this List.
[Huawei-route-policy]apply local-preference 1000 //设置本地优先级1000
[Huawei-route-policy]q
[Huawei]bgp 200 应用规则
[Huawei-bgp]peer 10.0.13.1 route-policy ppp import
[Huawei-bgp]q
[Huawei]
完成