前言:你是公司的网络管理员。公司的网络采用了BGP协议接入了两个服务运营商。公司自己采用了私有的AS号64512,ISP1的AS号为100,公司共有2条链路接入ISP1。ISP2的AS号为200,公司租用了一条线路接入ISP2。现在Internet上的部分用户反应访问公司网站的速度较慢,你通过改变BGP的各种属性达到了调整路由走向的目的。
实验拓扑图
基础配置 AR1
AR2
The device is running!
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys ar2
[ar2]int s 2/0/0
[ar2-Serial2/0/0]ip add 10.0.23.2 24
[ar2-Serial2/0/0]int s1/0/0
[ar2-Serial1/0/0]ip add 10.0.12.2 24
[ar2-Serial1/0/0]
Apr 29 2024 14:40:53-08:00 ar2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol PP
P IPCP on the interface Serial1/0/0 has entered the UP state.
[ar2-Serial1/0/0]int l0
[ar2-LoopBack0]ip add 10.0.2.2 24
AR3
The device is running!
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys ar3
[ar3]int s3/0/0
[ar3-Serial3/0/0]ip add 10.0.35.3 24
[ar3-Serial3/0/0]int g0/0/2
[ar3-GigabitEthernet0/0/2]ip add 10.0.15.3 24
Apr 29 2024 14:42:56-08:00 ar3 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/2 has entered the UP state.
[ar3-GigabitEthernet0/0/2]int s 2/0/0
[ar3-Serial2/0/0]ip add 10.00.23.3 24
[ar3-Serial2/0/0]
Apr 29 2024 14:43:23-08:00 ar3 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol PP
P IPCP on the interface Serial2/0/0 has entered the UP state.
[ar3-Serial2/0/0]int l0
[ar3-LoopBack0]ip add 10.0.3.3 32
[ar3-LoopBack0]int l1
[ar3-LoopBack1]ip add 10.1.3.3 24
[ar3-LoopBack1]
AR4
The device is running!
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys ar4
[ar4]int g0/0/0
[ar4-GigabitEthernet0/0/0]ip add 10.0.45.4 24
Apr 29 2024 14:45:38-08:00 ar4 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[ar4-GigabitEthernet0/0/0]int g0/0/1
[ar4-GigabitEthernet0/0/1]ip add 10.0.114.4 24
Apr 29 2024 14:46:56-08:00 ar4 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[ar4-GigabitEthernet0/0/1]int l0
[ar4-LoopBack0]ip add 10.0.4.4 32
[ar4-LoopBack0]
AR5
The device is running!
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys ar5
[ar5]int s1/0/0
[ar5-Serial1/0/0]ip add 10.0.35.5 24
[ar5-Serial1/0/0]
Apr 29 2024 14:48:08-08:00 ar5 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol PP
P IPCP on the interface Serial1/0/0 has entered the UP state.
[ar5-Serial1/0/0]int g0/0/0
[ar5-GigabitEthernet0/0/0]ip add 10.0.45.5 24
Apr 29 2024 14:48:19-08:00 ar5 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[ar5-GigabitEthernet0/0/0]int l0
[ar5-LoopBack0]ip add 10.0.5.5 32
[ar5-LoopBack0]int l 1
[ar5-LoopBack1]ip add 10.1.5.5 24
[ar5-LoopBack1]
二、配置IGP和BGP
在AS64512内部使用OSPF作为IGP,所有设备属于区域0,R1的G0/0/1和lo-0连接的网段运行ospf。
[ar1]router id 10.0.1.1
Info: Router ID has been modified, please reset the relative protocols manually
to update the Router ID.
[ar1]ospf 1
[ar1-ospf-1]area 0
[ar1-ospf-1-area-0.0.0.0]network 10.0.111.1 0.0.0.0
[ar1-ospf-1-area-0.0.0.0]network 10.0.1.1 0.0.0.0
[ar1-ospf-1-area-0.0.0.0]
在S1上创建vlan111,配置vlanif地址与R1进行互联。
创建vlan114,配置vlanif地址与R4进行互联。
互联接口使用Access模式,S1的Vlanif 111、Vlanif 114 和Loopback 0连接的网段运行OSPF。
<Huawei>sys
[Huawei]sys s1
[s1]int l0
[s1-LoopBack0]ip add 10.0.11.11 32
[s1-LoopBack0]int l1
[s1-LoopBack1]ip add 10.1.11.11 24
[s1-LoopBack1]q
[s1]router id 10.0.11.11
[s1]vlan
[s1]vlan b
[s1]vlan batch 111 114
Info: This operation may take a few seconds. Please wait for a moment...done.
[s1]int
[s1]interface Vlan 111
[s1-Vlanif111]ip add 10.0.111.11 24
[s1-Vlanif111]int vlan 114
[s1-Vlanif114]ip add 10.0.114.11 24
[s1-Vlanif114]int g0/0/4
[s1-GigabitEthernet0/0/4]port link-type access
[s1-GigabitEthernet0/0/4]port default vlan 114
[s1-GigabitEthernet0/0/4]q
[s1]int g0/0/1
[s1-GigabitEthernet0/0/1]port link-type access
[s1-GigabitEthernet0/0/1]port default vlan 111
[s1-GigabitEthernet0/0/1]q
[s1]ospf 1
[s1-ospf-1]area 0
[s1-ospf-1-area-0.0.0.0]network 10.0.111.11 0.0.0.0
[s1-ospf-1-area-0.0.0.0]network 10.0.114.11 0.0.0.0
[s1-ospf-1-area-0.0.0.0]network 10.0.11.11 0.0.0.0
[s1-ospf-1-area-0.0.0.0]q
[s1-ospf-1]
R4的G0/0/1和lo0连接的网段运行ospf
<ar4>sys
Enter system view, return user view with Ctrl+Z.
[ar4]router id 10.0.4.4
Info: Router ID has been modified, please reset the relative protocols manually
to update the Router ID.
[ar4]ospf 1
[ar4-ospf-1]area 0
[ar4-ospf-1-area-0.0.0.0]network 10.0.114.4 0.0.0.0
[ar4-ospf-1-area-0.0.0.0]network 10.0.4.4 0.0.0.0
[ar4-ospf-1-area-0.0.0.0]
检查是否学习到其他设备的LoopBack0地址所在的网段。
在R1上进行ping测试
3、在R1,R4,S1上配置BGP,要求使用各自lo0接口建立对等体连接,配置的时候使用对等体组,组名为as64512。
默认情况下,BGP的负载分担是关闭的,在所有 路由器上打开负载分担,设置最大同时使用4条等价路径。
[ar1]bgp 64512
[ar1-bgp]group as64512 internal
[ar1-bgp]peer 10.0.11.11 group as64512
[ar1-bgp]peer 10.0.11.11 connect-interface LoopBack 0
[ar1-bgp]maximum load-balancing 4
[ar1-bgp]
[s1]bgp 64512
[s1-bgp]group as64512 internal
[s1-bgp]peer 10.0.4.4 group as64512
[s1-bgp]peer 10.0.4.4 connect-interface LoopBack 0
[s1-bgp]maximum load-balancing 4
[s1-bgp]peer 10.0.1.1 group as64512
[s1-bgp]peer 10.0.1.1 connect-interface LoopBack 0
[ar4]router id 10.0.4.4
[ar4]bgp 64512
[ar4-bgp]group as64512
[ar4-bgp]peer 10.0.11.11 group as64512
[ar4-bgp]peer 10.0.11.11 connect-interface LoopBack 0
[ar4-bgp]maximum load-balancing 4
3.1 、在R1,R2,R3,R4,R5上配置EBGP,EBGP全部使用物理接口地址建立对等体关系。
注意: R2、R3、R5:要加 maximum load-balancing 4
[ar1]bgp 64512
[ar1-bgp]peer 10.0.12.2 as-number 200
[ar1-bgp]peer 10.0.15.3 as-number 100
[ar2]router id 10.0.2.2
[ar2]bgp 200
[ar2-bgp]peer 10.0.12.1 as-number 64512
[ar2-bgp]peer 10.0.23.3 as-number 100
[ar2-bgp]maximum load-balancing 4
[ar3]router id 10.0.3.3
[ar3]bgp 100
[ar3-bgp]peer 10.0.23.2 as-number 200
[ar3-bgp]peer 10.0.35.5 as-number 100
[ar3-bgp]peer 10.0.15.1 as-number 64512
[ar3-bgp]maximum load-balancing 4
[ar3-bgp]q
[ar4]bgp 64512
[ar4-bgp]peer 10.0.45.5 as-number 100
[ar5]router id 10.0.5.5
Info: Router ID has been modified, please reset the relative protocols manually
to update the Router ID.
[ar5]bgp 100
[ar5-bgp]peer 10.0.45.4 as-number 64512
[ar5-bgp]peer 10.0.35.3 as-number 100
[ar5-bgp]maximum load-balancing 4
4、配置as-path属性
4.1 在S1上创建LoopBack 1,地址为10.1.11.11/24,使用network命令发布到BGP中
[s1]bgp 64512
[s1-bgp]network 10.1.11.11 24
在R2上观察BGP路由表,可看出这时10.1.11.0/24路由 是依据as-path属性来选择下一跳的。
4.2 由于R1到R4之间的带宽有限,现在希望R2能经由AS100来访问10.1.11.0/24,这里通过AS-Path来影响选路。
在R1上创建路由策略as_path,针对10.1.11.0/24这条路由增加2个重复的AS号。
[ar1]acl number 2001
[ar1-acl-basic-2001]rule 5 permit source 10.1.11.0 0.0.0.25
[ar1-acl-basic-2001]q
[ar1]route-policy as_path permit node 10
Info: New Sequence of this List.
[ar1-route-policy]if-match acl 2001
[ar1-route-policy]apply as-path 64512 additive
然后把该策略应用在R1上,让R2从R1上学习到的这条路由的AS-Path有3个值。
[ar1]bgp 64512
[ar1-bgp]peer 10.0.12.2 route-policy as_path export
5、配置origin属性
5.1 我们希望R3通过R5访问AS 64512,查看10.1.11.0/24原来的Origin属性是IGP。
这时,我们将R1对R3通告的该路由修改为incomplete。
6、配置路由策略
6.1 在R3上创建Loopback 1,地址为10.1.3.3/24,发布进BGP。
在R5上创建Loopback 1,地址为10.1.5.5/24,发布进BGP。
6.2 现在希望到达网络10.1.5.0/24的流量从R4发送到目标,到达网络10.1.3.0/24的流量从R1发送到目标。
在R4上创建路由策略Pref4,匹配路由10.1.5.0/24,将其本地优先属性修改为110。
R1上创建路由策略Pref1,匹配路由10.1.3.0/24,将其本地优先属性修改为110,然后将策略应用到IBGP的对等体组上。
7、实验检验