HCIP-IERS部署企业级路由交换网络_BGP协议特性与配置_BGP属性与路径选择1

目录

第三章 BGP协议特性与配置

实验 3-3 BGP属性与路径选择1

学习目的

拓扑图

场景

学习任务

步骤一.基础配置与IP编址

步骤二.配置IGP及BGP

步骤三.配置AS-Path属性

步骤四.配置Origin属性

步骤五.配置Local-Pref属性

步骤六.配置MED属性

附加实验: 思考并验证

最终设备配置


第三章 BGP协议特性与配置

实验 3-3 BGP属性与路径选择1

学习目的

·掌握通过配置AS-Path属性来影响路径选择的方法

·掌握通过修改Origin属性来影响路径选择的配置方法

·掌握通过修改Local-Pref属性来影响路径选择的配置方法

·掌握通过修改MED属性来影响路径选择的配置方法

拓扑图

图3-3 BGP属性与路径选择

场景

你是公司的网络管理员。公司的网络采用了BGP协议接入了两个服务运营商。公司自己采用了私有的AS号64512,ISP1的AS号为100,公司共有2条链路接入ISP1。ISP2的AS号为200,公司租用了一条线路接入ISP2。现在Internet上的部分用户反应访问公司网站的速度较慢,你通过改变BGP的各种属性达到了调整路由走向的目的。

学习任务

步骤一.基础配置与IP编址

给所有路由器配置物理接口及Loopback接口的IP地址和掩码。注意各Loopback 0接口均使用32位掩码。

[R1]interface Serial 1/0/0

[R1-Serial1/0/0]ip address 10.0.12.1 24

[R1-Serial1/0/0]quit

[R1]interface GigabitEthernet 0/0/2

[R1-GigabitEthernet0/0/2]ip address 10.0.15.1 24

[R1-GigabitEthernet0/0/2]quit

[R1]interface GigabitEthernet 0/0/1

[R1-GigabitEthernet0/0/1]ip address 10.0.111.1 24

[R1-GigabitEthernet0/0/1]quit

[R1]interface LoopBack 0

[R1-LoopBack0]ip address 10.0.1.1 32

[R1-LoopBack0]quit

[R2]interface Serial 1/0/0

[R2-Serial1/0/0]ip address 10.0.12.2 24

[R2-Serial1/0/0]quit

[R2]interface  Serial 2/0/0

[R2-Serial2/0/0]ip address 10.0.23.2 24

[R2-Serial2/0/0]quit

[R2]interface LoopBack 0

[R2-LoopBack0]ip address 10.0.2.2 24

[R2-LoopBack0]quit

[R3]interface GigabitEthernet 0/0/2

[R3-GigabitEthernet0/0/2]ip address 10.0.15.3 24

[R3-GigabitEthernet0/0/2]quit

[R3]interface Serial 2/0/0

[R3-Serial2/0/0]ip address 10.0.23.3 24

[R3-Serial2/0/0]quit

[R3]interface Serial 3/0/0

[R3-Serial3/0/0]ip address 10.0.35.3 24

[R3-Serial3/0/0]quit

[R3]interface loopback 0

[R3-LoopBack0]ip address 10.0.3.3 32

[R3-LoopBack0]quit

[R4]interface GigabitEthernet 0/0/1

[R4-GigabitEthernet0/0/1]ip address 10.0.114.4 24

[R4-GigabitEthernet0/0/1]quit

[R4]interface GigabitEthernet 0/0/0  

[R4-GigabitEthernet0/0/0]ip address 10.0.45.4 24

[R4-GigabitEthernet0/0/0]quit

[R4]interface loopback 0

[R4-LoopBack0]ip address 10.0.4.4 32

[R4-LoopBack0]quit

[R5]interface Serial 1/0/0

[R5-Serial1/0/0]ip address 10.0.35.5 24

[R5-Serial1/0/0]quit

[R5]interface GigabitEthernet 0/0/0

[R5-GigabitEthernet0/0/0]ip address 10.0.45.5 24

[R5-GigabitEthernet0/0/0]quit

[R5]interface loopback 0

[R5-LoopBack0]ip address 10.0.5.5 32

[R5-LoopBack0]quit

配置完成后,测试直连链路的连通性。

<R1>ping -c 1 10.0.12.2

  PING 10.0.12.2: 56  data bytes, press CTRL_C to break

    Reply from 10.0.12.2: bytes=56 Sequence=1 ttl=255 time=29 ms

  --- 10.0.12.2 ping statistics ---

    1 packet(s) transmitted

    1 packet(s) received

    0.00% packet loss

    round-trip min/avg/max = 29/29/29 ms

[R1]ping -c 1 10.0.15.3

  PING 10.0.15.3: 56  data bytes, press CTRL_C to break

    Reply from 10.0.15.3: bytes=56 Sequence=1 ttl=255 time=59 ms

  --- 10.0.15.3 ping statistics ---

    1 packet(s) transmitted

    1 packet(s) received

    0.00% packet loss

    round-trip min/avg/max = 59/59/59 ms

<R2>ping -c 1 10.0.23.3

  PING 10.0.23.3: 56  data bytes, press CTRL_C to break

    Reply from 10.0.23.3: bytes=56 Sequence=1 ttl=255 time=32 ms

  --- 10.0.23.3 ping statistics ---

    1 packet(s) transmitted

    1 packet(s) received

    0.00% packet loss

    round-trip min/avg/max = 32/32/32 ms

[R3]ping -c 1 10.0.35.5

  PING 10.0.35.5: 56  data bytes, press CTRL_C to break

    Reply from 10.0.35.5: bytes=56 Sequence=1 ttl=255 time=36 ms

  --- 10.0.35.5 ping statistics ---

    1 packet(s) transmitted

    1 packet(s) received

    0.00% packet loss

    round-trip min/avg/max = 36/36/36 ms

<R4>ping -c 1 10.0.45.5

  PING 10.0.45.5: 56  data bytes, press CTRL_C to break

    Reply from 10.0.45.5: bytes=56 Sequence=1 ttl=255 time=11 ms

  --- 10.0.45.5 ping statistics ---

    1 packet(s) transmitted

    1 packet(s) received

    0.00% packet loss

round-trip min/avg/max = 11/11/11 ms

步骤二.配置IGP及BGP

在AS 64512内部使用OSPF作为IGP,所有设备属于区域0。

R1的G0/0/1和Loopback 0连接的网段运行OSPF。

[R1]router id 10.0.1.1

[R1]ospf 1

[R1-ospf-1]area 0

[R1-ospf-1-area-0.0.0.0]network 10.0.111.1 0.0.0.0

[R1-ospf-1-area-0.0.0.0]network 10.0.1.1 0.0.0.0

[R1-ospf-1-area-0.0.0.0]quit

 [R1-ospf-1]quit

在S1上创建Vlan 111,配置Vlanif地址与R1进行互联。

创建Vlan114,配置Vlanif地址与R4进行互联。

互联接口使用Access模式,S1的Vlanif 111、Vlanif 114 和Loopback 0连接的网段运行OSPF。

[S1]router id 10.0.11.11

[S1]vlan batch 111 114

[S1]interface vlan 111

[S1-Vlanif111]ip address 10.0.111.11 24

[S1-Vlanif111]quit

[S1]interface  vlan 114

[S1-Vlanif114]ip address 10.0.114.11 24

[S1-Vlanif114]quit

[S1]interface loopback 0

[S1-LoopBack0]ip address 10.0.11.11 32

[S1-LoopBack0]quit

[S1]interface GigabitEthernet 0/0/1

[S1-GigabitEthernet0/0/1]port link-type access

[S1-GigabitEthernet0/0/1]port default vlan 111

[S1-GigabitEthernet0/0/1]quit

[S1]interface GigabitEthernet 0/0/4

[S1-GigabitEthernet0/0/4]port link-type access

[S1-GigabitEthernet0/0/4]port default vlan 114

[S1-GigabitEthernet0/0/4]quit

[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]quit

[S1-ospf-1]quit

R4的G0/0/1和Loopback 0连接的网段运行OSPF,

[R4]router id 10.0.4.4

[R4]ospf 1

[R4-ospf-1]area 0

[R4-ospf-1-area-0.0.0.0]network 10.0.114.4 0.0.0.0

[R4-ospf-1-area-0.0.0.0]network 10.0.4.4 0.0.0.0

[R4-ospf-1-area-0.0.0.0]quit

[R4-ospf-1]quit

检查是否学习到其他设备的Loopback 0地址所在的网段。

[R1]display ip routing-table

Route Flags: R - relay, D - download to fib

----------------------------------------------------------------------------

Routing Tables: Public

         Destinations : 18       Routes : 18       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       10.0.1.1/32 Direct  0    0           D   127.0.0.1       LoopBack0

       10.0.4.4/32 OSPF  10   2           D   10.0.111.11 GigabitEthernet0/0/1

     10.0.11.11/32 OSPF  10   1           D   10.0.111.11 GigabitEthernet0/0/1

      10.0.12.0/24 Direct  0    0           D   10.0.12.1       Serial1/0/0

      10.0.12.1/32 Direct  0    0           D   127.0.0.1       Serial1/0/0

      10.0.12.2/32 Direct  0    0           D   10.0.12.2       Serial1/0/0

    10.0.12.255/32 Direct  0    0           D   127.0.0.1       Serial1/0/0

      10.0.15.0/24 Direct  0    0           D   10.0.15.1   GigabitEthernet0/0/2

      10.0.15.1/32 Direct  0    0           D   127.0.0.1   GigabitEthernet0/0/2

    10.0.15.255/32 Direct  0    0           D   127.0.0.1   GigabitEthernet0/0/2

     10.0.111.0/24 Direct  0    0           D   10.0.111.1  GigabitEthernet0/0/1

     10.0.111.1/32 Direct  0    0           D   127.0.0.1   GigabitEthernet0/0/1

   10.0.111.255/32 Direct  0    0           D   127.0.0.1   GigabitEthernet0/0/1

     10.0.114.0/24 OSPF  10   2            D   10.0.111.11 GigabitEthernet0/0/1

      127.0.0.0/8 Direct  0    0           D   127.0.0.1       InLoopBack0

      127.0.0.1/32 Direct  0    0           D   127.0.0.1       InLoopBack0

127.255.255.255/32Direct  0    0           D   127.0.0.1       InLoopBack0

255.255.255.255/32Direct  0    0           D   127.0.0.1       InLoopBack0

[S1]display ip routing-table

Route Flags: R - relay, D - download to fib

----------------------------------------------------------------------------

Routing Tables: Public

        Destinations : 9       Routes : 9

Destination/Mask    Proto  Pre  Cost       Flags NextHop         Interface

       10.0.1.1/32 OSPF    10   1            D   10.0.111.1      Vlanif111

       10.0.4.4/32 OSPF    10   1            D   10.0.114.4      Vlanif114

     10.0.11.11/32 Direct  0    0            D   127.0.0.1       LoopBack0

     10.0.111.0/24 Direct  0    0             D   10.0.111.11     Vlanif111

    10.0.111.11/32 Direct  0    0            D   127.0.0.1       Vlanif111

     10.0.114.0/24 Direct  0    0            D   10.0.114.11     Vlanif114

    10.0.114.11/32 Direct 0    0            D   127.0.0.1       Vlanif114

      127.0.0.0/8 Direct 0    0            D   127.0.0.1       InLoopBack0

      127.0.0.1/32 Direct 0    0            D   127.0.0.1       InLoopBack0

<R4>display ip routing-table

Route Flags: R - relay, D - download to fib

----------------------------------------------------------------------------

Routing Tables: Public

         Destinations : 14       Routes : 14       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       10.0.1.1/32 OSPF  10   2           D   10.0.114.11 GigabitEthernet0/0/1

       10.0.4.4/32 Direct  0    0           D   127.0.0.1       LoopBack0

     10.0.11.11/32 OSPF  10   1           D   10.0.114.11 GigabitEthernet0/0/1

      10.0.45.0/24 Direct  0    0           D   10.0.45.4   GigabitEthernet0/0/0

      10.0.45.4/32 Direct  0    0           D   127.0.0.1   GigabitEthernet0/0/0

    10.0.45.255/32 Direct  0    0           D   127.0.0.1   GigabitEthernet0/0/0

     10.0.111.0/24 OSPF  10   2           D   10.0.114.11 GigabitEthernet0/0/1

     10.0.114.0/24 Direct  0    0           D   10.0.114.4  GigabitEthernet0/0/1

     10.0.114.4/32 Direct  0    0           D   127.0.0.1   GigabitEthernet0/0/1

   10.0.114.255/32 Direct  0    0           D   127.0.0.1   GigabitEthernet0/0/1

      127.0.0.0/8 Direct  0    0           D   127.0.0.1       InLoopBack0

      127.0.0.1/32 Direct  0    0           D   127.0.0.1       InLoopBack0

127.255.255.255/32Direct  0    0           D   127.0.0.1       InLoopBack0

255.255.255.255/32Direct  0    0           D   127.0.0.1       InLoopBack0

在R1、R4、S1上配置BGP,要求使用各自的Loopback 0接口建立对等体连接,配置的时候使用对等体组,组名为as64512

默认情况下,BGP的负载分担是关闭的。在所有的路由器上打开负载分担,设置最大同时使用4条等价路径。

[R1]bgp 64512

[R1-bgp]group as64512 internal

[R1-bgp]peer 10.0.11.11 group as64512

[R1-bgp]peer 10.0.11.11 connect-interface LoopBack 0

[R1-bgp]maximum load-balancing 4

[R1-bgp]quit

[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

[S1-bgp]quit

[R4]bgp 64512

[R4-bgp]group as64512 internal

[R4-bgp]peer 10.0.11.11 group as64512

[R4-bgp]peer 10.0.11.11 connect-interface LoopBack 0

[R4-bgp]maximum load-balancing 4

[R4-bgp]quit

在R1、R2、R3、R4、R5上配置EBGP,AS的规划如图所示,EBGP全部使用物理接口地址建立对等体关系。

[R1]bgp 64512

[R1-bgp]peer 10.0.12.2 as-number 200

[R1-bgp]peer 10.0.15.3 as-number 100

[R1-bgp]quit

[R2]router id 10.0.2.2

[R2]bgp 200

[R2-bgp]peer 10.0.12.1 as-number 64512

[R2-bgp]peer 10.0.23.3 as-number 100

[R2-bgp]maximum load-balancing 4

[R2-bgp]quit

[R3]router id 10.0.3.3

[R3]bgp 100   

[R3-bgp]peer 10.0.23.2 as-number 200

[R3-bgp]peer 10.0.35.5 as-number 100

[R3-bgp]peer 10.0.15.1 as-number 64512

[R3-bgp]maximum load-balancing 4

[R3-bgp]quit

[R4]bgp 64512

[R4-bgp]peer 10.0.45.5 as-number 100

[R4-bgp]quit

[R5]router id 10.0.5.5

[R5]bgp 100

[R5-bgp]peer 10.0.35.3 as-number 100

[R5-bgp]peer 10.0.45.4 as-number 64512

[R5-bgp]maximum load-balancing 4

[R5-bgp]quit

步骤三.配置AS-Path属性

在S1上创建Loopback 1,地址为10.1.11.11/24,使用network命令发布到BGP中。

[S1]interface loopback 1

[S1-LoopBack1]ip address 10.1.11.11 24

[S1-LoopBack1]quit

[S1]bgp 64512

[S1-bgp]network 10.1.11.11 255.255.255.0

[S1]quit

在R2上观察BGP路由表,可看出这时10.1.11.0/24路由是依据AS-Path属性来选择下一跳的。

[R2]display bgp routing-table

 BGP Local router ID is 10.0.2.2

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 2

      Network          NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>   10.1.11.0/24 10.0.12.1                                0      64512i

 *                    10.0.23.3                                0      100 64512i

由于R1到R4之间的带宽有限,现在希望R2能经由AS100来访问10.1.11.0/24。

这里通过AS-Path来影响选路。

在R1上创建路由策略as_path,针对10.1.11.0/24这条路由增加2个重复的AS号。

[R1]acl number 2001

[R1-acl-basic-2001]rule 5 permit source 10.1.11.0 0.0.0.255

[R1-acl-basic-2001]quit

[R1]route-policy as_path permit node 10

[R1-route-policy]if-match acl 2001

[R1-route-policy]apply as-path 64512 64512 additive

[R1-route-policy]quit

然后把该策略应用在R1上,让R2从R1上学习到的这条路由的AS-Path有3个值。

[R1]bgp 64512

[R1-bgp]peer 10.0.12.2 route-policy as_path  export

[R1-bgp]quit

在R2上观察BGP路由表。

<R2>display bgp routing-table

 BGP Local router ID is 10.0.2.2

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 2

      Network            NextHop        MED   LocPrf    PrefVal Path/Ogn

 *>   10.1.11.0/24       10.0.23.3                            0      100 64512i

 *                       10.0.12.1                            0      64512 64512 64512i

此时R2经由 AS100访问10.1.11.0/24网段。

步骤四.配置Origin属性

观察R3的路由表。

<R3>display bgp routing-table

 BGP Local router ID is 10.0.3.3

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 2

      Network            NextHop        MED       LocPrf    PrefVal Path/Ogn

 *>   10.1.11.0/24       10.0.15.1                               0      64512i

 * i                     10.0.35.5                  100          0      64512i

到达10.1.11.0/24的下一跳是R1,分析原因。

我们希望R3通过R5访问AS 64512,查看10.1.11.0/24原来的Origin属性是IGP。

这时,我们将R1对R3通告的该路由修改为incomplete。

[R1]route-policy 22 permit node 10

[R1-route-policy]if-match acl 2001

[R1-route-policy]apply origin incomplete

[R1-route-policy]quit

[R1]bgp 64512  

[R1-bgp]peer 10.0.15.3 route-policy 22 export

[R1-bgp]quit

策略生效后观察R3的BGP路由表。

<R3>display bgp routing-table

 BGP Local router ID is 10.0.3.3

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 2

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>i  10.1.11.0/24        10.0.35.5                  100          0      64512i

 *                       10.0.15.1                                0      64512?

这时R3到达网络10.1.11.0/24的下一跳是R5。

步骤五.配置Local-Pref属性

本地优先属性在选路中有很高的优先级。

通过改变本地优先属性可以影响选路。

在R3上创建Loopback 1,地址为10.1.3.3/24,发布进BGP。

[R3]interface loopback 1

[R3-LoopBack1]ip address 10.1.3.3 255.255.255.0

[R3-LoopBack1]quit

[R3]bgp 100

[R3-bgp]network 10.1.3.3 255.255.255.0

[R3-bgp]quit

在R5上创建Loopback 1,地址为10.1.5.5/24,发布进BGP。

[R5]interface loopback 1

[R5-LoopBack1]ip address 10.1.5.5 255.255.255.0

[R5-LoopBack1]quit

[R5]bgp 100

[R5-bgp]network 10.1.5.5 24

[R5-bgp]quit

在S1上观察路由表。

[S1]display bgp routing-table

 BGP Local router ID is 10.0.11.11

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

Total Number of Routes: 5

      Network            NextHop        MED      LocPrf  PrefVal Path/Ogn

 *>i  10.1.3.0/24         10.0.1.1        0          100          0      100i

 * i                        10.0.4.4                   100          0      100i

 *>i  10.1.5.0/24         10.0.1.1                   100          0      100i

 * i                     10.0.4.4        0          100          0      100i

 *>  10.1.11.0/24     0.0.0.0         0                        0      i

现在希望到达网络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的对等体组上。

[R4]acl number 2001

[R4-acl-basic-2001]rule 5 permit source 10.1.5.0 0.0.0.255

[R4-acl-basic-2001]quit

[R4]route-policy Pref4 permit node 10

[R4-route-policy]if-match acl 2001            

[R4-route-policy]apply local-preference 110

[R4-route-policy]quit

[R4]route-policy Pref4 permit node 20   

[R4-route-policy]quit

[R4]bgp 64512

[R4-bgp]peer as64512 route-policy Pref4 export

[R4-bgp]quit

[R1]acl number 2002

[R1-acl-basic-2002]rule 5 permit source 10.1.3.0 0.0.0.255

[R1-acl-basic-2002]quit

[R1]route-policy Pref1 permit node 10

[R1-route-policy]if-match acl 2002

[R1-route-policy]apply local-preference 110

[R1-route-policy]quit

[R1]route-policy Pref1 permit node 20

[R1-route-policy]quit

[R1]bgp 64512

[R1-bgp]peer as64512 route-policy Pref1 export

[R1-bgp]quit

在S1上查看BGP路由表。

[S1]display bgp routing-table

 BGP Local router ID is 10.0.11.11

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? – incomplete

Total Number of Routes: 5

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>i  10.1.3.0/24        10.0.1.1        0          110        0      100i

* i                  10.0.4.4                    100        0      100i

 *>i  10.1.5.0/24        10.0.4.4        0          110        0      100i

* i                      10.0.1.1        0          100        0      100i

 *>   10.1.11.0/24       0.0.0.0         0                      0      i

可以观察到,此时根据Local-Pref属性进行选路,越高越优先。

步骤六.配置MED属性

删除步骤四中通过修改Origin来影响AS100中对10.1.11.0/24选路的路由策略,本实验中通过修改MED值来影响选路。

[R1]bgp 64512  

[R1-bgp]undo peer 10.0.15.3 route-policy 22 export

[R1-bgp]quit

[R1]undo route-policy 22

在R1上创建路由策略med,针对10.1.11.0/24,将MED值修改为100,将该策略应用到对等体R3上。

[R1]route-policy med permit node 10

[R1-route-policy]if-match acl 2001

[R1-route-policy]apply cost 100

[R1-route-policy]quit

[R1]bgp 64512

[R1-bgp]peer 10.0.15.3 route-policy med export

[R1-bgp]quit

在R3上查看BGP路由表。

<R3>display bgp routing-table

 BGP Local router ID is 10.0.15.3

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 4

      Network          NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>   10.1.3.0/24 0.0.0.0         0                      0       i

 *>i  10.1.5.0/24 10.0.35.5       0          100        0       i

 *>i  10.1.11.0/24 10.0.35.5                  100        0       64512i

 *                 10.0.15.1       100                   0       64512i

[R3]display bgp routing-table 10.1.11.0

BGP local router ID : 10.0.3.3

Local AS number : 100

Paths: 2 available, 1 best, 1 select

BGP routing table entry information of 10.1.11.0/24:

From: 10.0.35.5 (10.0.5.5)

Route Duration: 00h00m33s

Relay IP Nexthop: 0.0.0.0

Relay IP Out-Interface: Serial3/0/0

Original nexthop: 10.0.35.5

Qos information : 0x0

AS-path 64512, origin igp, localpref 100, pref-val 0, valid, internal, best, select, active, pre 255

Advertised to such 2 peers:

10.0.23.2

10.0.15.1

BGP routing table entry information of 10.1.11.0/24:

From: 10.0.15.1 (10.0.1.1)

Route Duration: 18h52m36s

Direct Out-interface: GigabitEthernet0/0/2

Original nexthop: 10.0.15.1

Qos information : 0x0

AS-path 64512, origin igp, MED 100, pref-val 0, valid, external, pre 255, not preferred for MED

Not advertised to any peer yet

MED值越小越优先。

最后观察现象,可以和步骤四中达到同样的选路效果。

附加实验: 思考并验证

思考在完成了步骤六以后,关闭R1的S1/0/0接口,那么在R2上学习到的关于10.1.11.0/24的MED值是多少?

思考可否使用路由策略将AS-Path属性里的某个AS删除?

最终设备配置

<R1>display current-configuration

[V200R007C00SPC600]

#

 sysname R1

#

router id 10.0.2.2

#

interface Serial1/0/0

 link-protocol ppp

 ip address 10.0.12.1 255.255.255.0

#

interface Serial3/0/0

 link-protocol ppp

 ip address 10.0.14.1 255.255.255.0

#                                         

interface GigabitEthernet0/0/1

 ip address 10.0.111.1 255.255.255.0

#

interface GigabitEthernet0/0/2

 ip address 10.0.15.1 255.255.255.0

#

interface LoopBack0

 ip address 10.0.1.1 255.255.255.255

#

bgp 64512

 peer 10.0.12.2 as-number 200

 peer 10.0.15.3 as-number 100

 group as64512 internal

 peer 10.0.11.11 as-number 64512

 peer 10.0.11.11 group as64512

 peer 10.0.11.11 connect-interface LoopBack0

 #

 ipv4-family unicast

  undo synchronization

  maximum load-balancing 4

  peer 10.0.12.2 enable

  peer 10.0.12.2 route-policy as_path export

  peer 10.0.15.3 enable

  peer 10.0.15.3 route-policy med export

  peer as64512 enable

  peer as64512 route-policy Pref1 export

  peer 10.0.11.11 enable

  peer 10.0.11.11 group as64512

#

ospf 1

 area 0.0.0.0

  network 10.0.1.1 0.0.0.0

  network 10.0.111.1 0.0.0.0

#

route-policy as_path permit node 10

 if-match acl 2001

 apply as-path 64512 64512 additive

#

route-policy Pref1 permit node 10

 if-match acl 2002                        

 apply local-preference 110

#

route-policy Pref1 permit node 20

#

route-policy med permit node 10

 if-match acl 2001

 apply cost 100

#

return

<R2>display current-configuration

[V200R007C00SPC600]

#

 sysname R2     

#

router id 10.0.2.2

#

interface Serial1/0/0

 link-protocol ppp

 ip address 10.0.12.2 255.255.255.0

#

interface Serial2/0/0

 link-protocol ppp

 ip address 10.0.23.2 255.255.255.0

#

interface LoopBack0

 ip address 10.0.2.2 255.255.255.0

#

bgp 200

 peer 10.0.12.1 as-number 64512

 peer 10.0.23.3 as-number 100

 #

 ipv4-family unicast

  undo synchronization

  maximum load-balancing 4

  peer 10.0.12.1 enable

  peer 10.0.23.3 enable

#

return

<R3>display current-configuration

[V200R007C00SPC600]

#

 sysname R3

#

router id 10.0.3.3

#

interface Serial2/0/0

 link-protocol ppp

 ip address 10.0.23.3 255.255.255.0

#

interface Serial3/0/0

 link-protocol ppp

 ip address 10.0.35.3 255.255.255.0

#

interface GigabitEthernet0/0/2

 ip address 10.0.15.3 255.255.255.0

#

interface LoopBack0

 ip address 10.0.3.3 255.255.255.255

#

interface LoopBack1

 ip address 10.1.3.3 255.255.255.0

#

bgp 100

 peer 10.0.15.1 as-number 64512

 peer 10.0.23.2 as-number 200

 peer 10.0.35.5 as-number 100

 #

 ipv4-family unicast

  undo synchronization

  network 10.1.3.0 255.255.255.0

  maximum load-balancing 4

  peer 10.0.15.1 enable

  peer 10.0.23.2 enable

  peer 10.0.35.5 enable

#

return

<R4>display current-configuration

[V200R007C00SPC600]

#

 sysname R4

#

router id 10.0.4.4

#

interface Serial1/0/0

 link-protocol ppp

 ip address 10.0.14.4 255.255.255.0

#

interface GigabitEthernet0/0/0

 ip address 10.0.45.4 255.255.255.0       

#

interface GigabitEthernet0/0/1

 ip address 10.0.114.4 255.255.255.0

#

interface LoopBack0

 ip address 10.0.4.4 255.255.255.255

#

bgp 64512

 peer 10.0.45.5 as-number 100

 group as64512 internal

 peer 10.0.11.11 as-number 64512

 peer 10.0.11.11 group as64512

 peer 10.0.11.11 connect-interface LoopBack0

 #                                        

 ipv4-family unicast

  undo synchronization

  maximum load-balancing 4

  peer 10.0.45.5 enable

  peer as64512 enable

  peer as64512 route-policy Pref4 export

  peer 10.0.11.11 enable

  peer 10.0.11.11 group as64512

#

ospf 1

 area 0.0.0.0

  network 10.0.114.4 0.0.0.0

  network 10.0.4.4 0.0.0.0

#

route-policy Pref4 permit node 10

 if-match acl 2001

 apply local-preference 110

#

route-policy Pref4 permit node 20

#

return

<R5>display current-configuration

[V200R007C00SPC600]

#

 sysname R5

#

router id 10.0.5.5

#

interface Serial1/0/0

 link-protocol ppp

 ip address 10.0.35.5 255.255.255.0

#

interface GigabitEthernet0/0/0

 ip address 10.0.45.5 255.255.255.0

#

interface LoopBack0

 ip address 10.0.5.5 255.255.255.255

#

interface LoopBack1

 ip address 10.1.5.5 255.255.255.0

#

bgp 100

 peer 10.0.35.3 as-number 100

 peer 10.0.45.4 as-number 64512

 #

 ipv4-family unicast

  undo synchronization

  network 10.1.5.0 255.255.255.0

  maximum load-balancing 4

  peer 10.0.35.3 enable

  peer 10.0.45.4 enable                   

#

return

猜你喜欢

转载自blog.csdn.net/weixin_57099902/article/details/131852007
今日推荐