首页 > 其他分享 >华为 bgp案例

华为 bgp案例

时间:2023-02-02 16:45:05浏览次数:36  
标签:R4 10.0 R1 R2 R3 bgp 案例 华为

1、实验拓扑图

2、实验步骤

1、配置设备的ip地址

1、R1
sys
sysname R1
[R1] int g0/0/0
[R1] ip add 10.0.12.1 24
[R1] undo shut
[R1] int g0/0/1
[R1] ip add 10.0.13.1 24
[R1] int loop0
[R1] ip add 1.1.1.1 32

2、R2
sys
sysname R2
[R2] int g0/0/0
[R2] ip add 10.0.12.2 24
[R2] int g0/0/1
[R2] ip add 10.0.24.2 24
[R2] int loop0
[R2] ip add 2.2.2.2 32

3、R3
sys
sysname R3
[R3] int g0/0/0
[R3] ip add 10.0.13.3 24
[R3] int g0/0/1
[R3] ip add 10.0.34.3 24
[R3] int loop0
[R3] ip add 3.3.3.3 32

4、R4
sys
sysname R4
[R4] int g0/0/0
[R4] ip add 10.0.24.4 24
[R4] int g0/0/1
[R4] ip add 10.0.34.4 24
[R4] int loop0
[R4] ip add 4.4.4.4 32

2、配置OSPF协议,使内网可互访

R2
[R2] ospf 1
[R2] area 0
[R2] network 10.0.24.0 0.0.0.255
[R2] network 2.2.2.2 0.0.0.0

R3
[R3] ospf 1
[R3] area 0
[R3] network 10.0.34.0 0.0.0.255
[R3] network 3.3.3.3 0.0.0.0

R4
[R4] ospf 1
[R4] area 0
[R4] network 10.0.24.0 0.0.0.255
[R4] network 10.0.34.0 0.0.0.255
[R4] network 4.4.4.4 0.0.0.0

3、配置BGP

[R1] bgp 100
[R1] router-id 1.1.1.1
[R1] peer 10.0.12.2 as-number 200
[R1] peer 10.0.13.3 as-number 200
[R1] network 1.1.1.1 32

[R2] bgp 200
[R2] router-id 2.2.2.2
[R2] peer 10.0.12.1 as-number 100
[R2] peer 10.0.24.4 as-number 200
[R2] peer 10.0.24.4 next-hop-local
[R3] import-route ospf 1

[R3] bgp 200
[R3] router-id 3.3.3.3
[R3] peer 10.0.13.1 as-number 100
[R3] peer 10.0.34.4 as-number 200
[R3] peer 10.0.34.4 next-hop-local
[R3] import-route ospf 1

[R4] bgp 200
[R4] router-id 4.4.4.4
[R4] peer 10.0.24.2 as-number 200
[R4] peer 10.0.34.3 as-number 200
[R4] network 4.4.4.4 32

4、查看BGP路由

[R1] dis bgp routing-table
[R1] dis ip routing-table
[R1] dis ospf routing

5、使用BGP属性控制选路

从R4到R1的通信,通过R3来传递

方法1:修改本地优先级(local-preference属性),默认值100,越大越优先

1、修改
[R3] route-policy lop permit node 10
[R3] apply local-preference 222
[R3] bgp 200
[R3] peer 10.0.34.4 route-policy lop export
2、查看 [R4] dis bgp routing-table

方法2:修改AS-PATH属性,越小越优先

1、删除前面的路由策略
[R3] bgp 200
[R3] undo peer 10.0.34.4 route-policy lop export
2、修改 [R2] route-policy as permit node 10 [R2] apply as-path 123 123 123 additive [R2] bgp 200 [R2] peer 10.0.24.4 route-policy as export
3、刷新bgp路由表 <R2> reset bgp all
4、查看 [R4] dis bgp routing-table 5、注意:方法1和方法2,修改的是从R4到R1的通信

方法3:修改MED属性,越小越优先

1、删除前面的路由策略
[R2] bgp 200
[R2] undo peer 10.0.24.4 route-policy as export
2、修改 [R2] route-policy med permit node 10 [R2] apply cost + 500 [R2] bgp 200 [R2] peer 10.0.12.1 route-policy med export
3、刷新bgp路由表 <R2> reset bgp all
4、查看 [R1] dis bgp routing-table

5、注意:方法3,修改的是从R1到R4的通信

 

标签:R4,10.0,R1,R2,R3,bgp,案例,华为
From: https://www.cnblogs.com/wuhg/p/17086481.html

相关文章