BGP实验一——路由路径选择

一、拓扑图

BGP实验一——路由路径选择_第1张图片

二、配置命令

1. 配置各设备ip地址

R1:

[Huawei]int GigabitEthernet 0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 10.0.12.1 24
[Huawei-GigabitEthernet0/0/0]quit
[Huawei]int GigabitEthernet 0/0/1

[Huawei-GigabitEthernet0/0/1]ip address 10.0.13.1 24

[Huawei-GigabitEthernet0/0/1]int loop0
[Huawei-LoopBack0]ip address 1.1.1.1 32
[Huawei-LoopBack0]quit

R2:
[Huawei]int GigabitEthernet 0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 10.0.12.2 24
[Huawei-GigabitEthernet0/0/0]quit
[Huawei]int GigabitEthernet 0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 10.0.24.2 24
[Huawei-GigabitEthernet0/0/1]int loop0
[Huawei-LoopBack0]ip address 2.2.2.2 32
[Huawei-LoopBack0]quit

R3:

[Huawei]int GigabitEthernet 0/0/0
[Huawei-GigabitEthernet0/0/0]ip ad
[Huawei-GigabitEthernet0/0/0]ip address 10.0.13.3 24
[Huawei-GigabitEthernet0/0/0]quit
[Huawei]int GigabitEthernet 0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 10.0.34.3 24
[Huawei-GigabitEthernet0/0/1]int loop0
[Huawei-LoopBack0]ip address 3.3.3.3 32
[Huawei-LoopBack0]quit

R4:

[Huawei]int GigabitEthernet 0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 10.0.24.4 24
[Huawei-GigabitEthernet0/0/0]quit
[Huawei]int GigabitEthernet 0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 10.0.34.4 24
[Huawei-GigabitEthernet0/0/1]int loop0
[Huawei-LoopBack0]ip address 4.4.4.4 32
[Huawei-LoopBack0]quit

2. 配置OSPF协议

R2:

[Huawei]ospf 1
[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 2.2.2.2 0.0.0.0

R3:

[Huawei]ospf 1
[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]network 3.3.3.3 0.0.0.0

R4:

[Huawei]ospf 1
[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]network 4.4.4.4 0.0.0.0

​ 至此,R1、R3、R4能互相ping通如下图所示

BGP实验一——路由路径选择_第2张图片

3.配置邻接关系

R1:

[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
[Huawei-bgp]network 1.1.1.1 32

R2:

[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]peer 10.0.24.4 next-hop-local
[Huawei-bgp]import-route ospf 1

R3:

[Huawei]bgp 200
[Huawei-bgp]route-select
[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]peer 10.0.34.4 next-hop-local
[Huawei-bgp]import-route ospf 1

R4:

[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]network 4.4.4.4 32

​ 查看R2中路由表如下图所示

BGP实验一——路由路径选择_第3张图片

4. 修改属性控制选路

​ 题目要求R1到R4路由优先选择R1->R2->R4 ,R4到R1的路由优先选择R4->R3->R1

R3:
[Huawei]route-policy lop permit node 10
[Huawei-route-policy]apply local-preference 222
[Huawei-route-policy]quit
[Huawei]bgp 200
[Huawei-bgp]peer 10.0.34.4 route-policy lop export
[Huawei-bgp]quit
[Huawei]quit
reset bgp all

R2:

[Huawei]route-policy lop permit node 10
[Huawei-route-policy]apply local-preference 222
[Huawei-route-policy]quit
[Huawei]bgp 200
[Huawei-bgp]peer 10.0.12.1 route-policy lop export
[Huawei-bgp]quit
reset bgp all

​ 查看R1路由表
BGP实验一——路由路径选择_第4张图片

​ 下面通过R4ping R1同时在R1的GE0/0/0和GE0/0/1分别抓包,结果如下:(左框为0端口,右为1端口)
BGP实验一——路由路径选择_第5张图片
​ 由上图可知,显然R4 ping R1时走的是R4->R3->R1路径。

你可能感兴趣的:(BGP实验一——路由路径选择)