华为AR2220 配置BGP的MED属性控制路由选择

一、组网需求

1、如图所示,所有路由器都配置BGP,RouterA在AS65008中,RouterB和RouterC在AS65009中。RouterA与RouterB、RouterC之间运行EBGP,RouterB和RouterC之间运行IBGP。需求从AS65008到AS65009的流量优先通过RouterC

2、网络拓扑

华为AR2220 配置BGP的MED属性控制路由选择_第1张图片

3、配置思路

采用如下的思路配置BGP的MED属性控制路由选择:
在RouterA和RouterB、RouterA和RouterC之间配置EBGP连接;在RouterB和RouterC之间配置IBGP连接。
通过使用路由策略增大RouterB发送给RouterA的MED值,这样可以使RouterA选择RouterC作为流量发往AS65009的入口设备。

二、操作步骤

1、配置各接口IP地址

system-view
[Huawei]sysname RouterA
[RouterA]interface  GigabitEthernet  0/0/1
[RouterA-GigabitEthernet0/0/1]ip address  200.1.1.2 24
[RouterA-GigabitEthernet0/0/1]q
[RouterA]interface  GigabitEthernet  0/0/2
[RouterA-GigabitEthernet0/0/2]ip address  200.1.2.2 24
[RouterA-GigabitEthernet0/0/2]q

system-view
[Huawei]sysname RouterB
[RouterB]interface  GigabitEthernet  0/0/1
[RouterB-GigabitEthernet0/0/1]ip address  200.1.1.1 24
[RouterB-GigabitEthernet0/0/1]q
[RouterB]interface  GigabitEthernet  0/0/0
[RouterB-GigabitEthernet0/0/0]ip address  9.1.1.1 24
[RouterB-GigabitEthernet0/0/0]q

system-view
[Huawei]sysname RouterC
[RouterC]interface  GigabitEthernet  0/0/0
[RouterC-GigabitEthernet0/0/0]ip address  9.1.1.2 24
[RouterC-GigabitEthernet0/0/0]q
[RouterC]interface  GigabitEthernet  0/0/2
[RouterC-GigabitEthernet0/0/2]ip address  200.1.2.1 24
[RouterC-GigabitEthernet0/0/2]q

2、配置BGP连接

[RouterA]bgp 65008
[RouterA-bgp]router-id 1.1.1.1
[RouterA-bgp]peer  200.1.1.1 as-number 65009
[RouterA-bgp]peer  200.1.2.1 as-number 65009
[RouterA-bgp]q

[RouterB]bgp 65009
[RouterB-bgp]router-id 2.2.2.2
[RouterB-bgp]peer 200.1.1.2 as-number 65008
[RouterB-bgp]peer  9.1.1.2 as-number 65009
[RouterB-bgp]ipv4-family unicast
[RouterB-bgp-af-ipv4]network  9.1.1.0 24
[RouterB-bgp-af-ipv4]q
[RouterB-bgp]q

[RouterC]bgp 65009
[RouterC-bgp]router-id 3.3.3.3
[RouterC-bgp]peer 200.1.2.2 as-number 65008
[RouterC-bgp]peer  9.1.1.1 as-number 65009
[RouterC-bgp]ipv4-family unicast 
[RouterC-bgp-af-ipv4]network 9.1.1.0 24
[RouterC-bgp-af-ipv4]q
[RouterC-bgp]q

3、查看RouterA的路由表,从路由表中可以看出,到目的地址9.1.1.0/24有两条有效路由,其中下一跳为200.1.1.1的路由是最优路由(因为RouterB的Router ID要小一些)。

[RouterA]display  bgp routing-table 9.1.1.0 24

 BGP local router ID : 1.1.1.1
 Local AS number : 65008
 Paths:   2 available, 1 best, 1 select
 BGP routing table entry information of 9.1.1.0/24:
 From: 200.1.1.1 (2.2.2.2)
 Route Duration: 00h02m01s  
 Direct Out-interface: GigabitEthernet0/0/1
 Original nexthop: 200.1.1.1
 Qos information : 0x0
 AS-path 65009, origin igp, MED 0, pref-val 0, valid, external, best, select, ac
tive, pre 255
 Advertised to such 2 peers:
    200.1.1.1
    200.1.2.1
 BGP routing table entry information of 9.1.1.0/24:
 From: 200.1.2.1 (3.3.3.3)
 Route Duration: 00h00m27s  
 Direct Out-interface: GigabitEthernet0/0/2
 Original nexthop: 200.1.2.1
 Qos information : 0x0
 AS-path 65009, origin igp, MED 0, pref-val 0, valid, external, pre 255, not pre
ferred for router ID
 Not advertised to any peer yet

4、配置MED属性

[RouterB]route-policy policy10 permit node 10
[RouterB-route-policy]apply cost 100
[RouterB-route-policy]q

[RouterB]bgp 65009
[RouterB-bgp]peer 200.1.1.2 route-policy policy10 export 
[RouterB-bgp]q

5、查看RouterA路由表,从路由表中可以看出,由于下一跳为200.1.1.1(RouterB)的路由MED值为100,而下一跳为200.1.2.1的MED值为0,所以BGP优先选择MED值较小的路由。

[RouterA]display  bgp routing-table 9.1.1.0 24

 BGP local router ID : 1.1.1.1
 Local AS number : 65008
 Paths:   2 available, 1 best, 1 select
 BGP routing table entry information of 9.1.1.0/24:
 From: 200.1.2.1 (3.3.3.3)
 Route Duration: 00h02m56s  
 Direct Out-interface: GigabitEthernet0/0/2
 Original nexthop: 200.1.2.1
 Qos information : 0x0
 AS-path 65009, origin igp, MED 0, pref-val 0, valid, external, best, select, ac
tive, pre 255
 Advertised to such 2 peers:
    200.1.1.1
    200.1.2.1
 BGP routing table entry information of 9.1.1.0/24:
 From: 200.1.1.1 (2.2.2.2)
 Route Duration: 00h00m29s  
 Direct Out-interface: GigabitEthernet0/0/1
 Original nexthop: 200.1.1.1
 Qos information : 0x0
 AS-path 65009, origin igp, MED 100, pref-val 0, valid, external, pre 255, not p
referred for MED
 Not advertised to any peer yet

 

 

 

你可能感兴趣的:(网络)