四、MPLS-配置

4 MPLS-配置

4.1 MPLS基本配置

4.1.1 必要配置

  • 每台路由器开启CEF交换,命令全局模式下IP CEF;
  • 每个接口激活标签交换和默认激活LDP,命令接口下MPLS IP ;

可以修改是否激活哪个协议,而不是默认的LDP协议

4.1.2 可选配置

  • 配MPLS-ID,否则的话会自己选ROUTER-ID,建议配置为LOOPBACK接口地址;
  • TTL配置,默认开始,可以关闭
  • 条件通告

MPLS分发模式,如不想通告某个路由的标签。

4.1.3 查看及验证

4.2 MPLS基础实验

配置顺序:

  • 接口配置
  • 运行IGP(OSPF)
  • 配置LDP ROUTERID,设定标签范围
  • 接口激活MPLS及LDP

4.2.1 基础配置

R1(config)#interface fastEthernet 0/0
R1(config-if)#ip address 10.1.12.1 255.255.255.0
R1(config-if)#no shutdown
R1(config)#interface loopback 0
R1(config-if)#ip address 1.1.1.1 255.255.255.255
R1(config-if)#no shutdown

R1(config)#router ospf 1
R1(config-router)#network 10.1.12.1 0.0.0.0 area 0
R1(config-router)#network 1.1.1.1 255.255.255.255 area 0

R1(config)#mpls ldp router-id loopback 0
R1(config)#mpls label range 100 199

R1(config)#interface fastEthernet 0/0
R1(config-if)#mpls ip
R2(config)#interface fastEthernet 0/0
R2(config-if)#ip address 10.1.12.2 255.255.255.0
R2(config-if)#no shutdown
R2(config)#interface fastEthernet 1/0
R2(config-if)#ip address 10.1.23.2 255.255.255.0
R2(config-if)#no shutdown
R2(config)#interface loopback 0
R2(config-if)#ip address 2.2.2.2 255.255.255.255
R2(config-if)#no shutdown

R2(config)#router ospf 1
R2(config-router)#router-id 2.2.2.2
R2(config-router)#network 10.1.12.2 0.0.0.0 area 0
R2(config-router)#network 10.1.23.2 0.0.0.0 area 0
R2(config-router)#network 2.2.2.2 255.255.255.255 area 0

R2(config)#mpls ldp router-id loopback 0
R2(config)#mpls label range 200 299

R2(config)#interface fastEthernet 0/0
R2(config-if)#mpls ip
R2(config)#interface fastEthernet 1/0
R2(config-if)#mpls ip
R3(config)#interface fastEthernet 1/0
R3(config-if)#ip address 10.1.23.3 255.255.255.0
R3(config-if)#no shutdown
R3(config)#interface fastEthernet 0/0
R3(config-if)#ip address 10.1.34.3 255.255.255.0
R3(config-if)#no shutdown
R3(config)#interface loopback 0
R3(config-if)#ip address 3.3.3.3 255.255.255.255
R3(config-if)#no shutdown

R3(config)#router ospf 1
R3(config-router)#router-id 3.3.3.3
R3(config-router)#network 10.1.23.3 0.0.0.0 area 0
R3(config-router)#network 10.1.34.3 0.0.0.0 area 0
R3(config-router)#network 3.3.3.3 255.255.255.255 area 0

R3(config)#mpls ldp router-id loopback 0
R3(config)#mpls label range 300 399

R3(config)#interface fastEthernet 1/0
R3(config-if)#mpls ip
R3(config)#interface fastEthernet 0/0
R3(config-if)#mpls ip
R4(config)#interface fastEthernet 0/0
R4(config-if)#ip address 10.1.34.4 255.255.255.0
R4(config-if)#no shutdown
R4(config)#interface loopback 0
R4(config-if)#ip address 4.4.4.4 255.255.255.0
R4(config-if)#no shutdown

R4(config)#router ospf 1
R4(config-router)#router-id 4.4.4.4
R4(config-router)#network 10.1.34.4 0.0.0.0 area 0
R4(config-router)#network 4.4.4.4 255.255.255.255 area 0

R4(config)#mpls ldp router-id loopback 0
R4(config)#mpls label range 400 499

R4(config)#interface fastEthernet 0/0
R4(config-if)#mpls ip

4.2.2 查看基础信息

R1#show mpls ldp discovery
 Local LDP Identifier:
    1.1.1.1:0
    Discovery Sources:
    Interfaces:
        FastEthernet0/0 (ldp): xmit/recv
            LDP Id: 2.2.2.2:0

查看R1的邻居,显示为R2

R1#show mpls ldp neighbor
    Peer LDP Ident: 2.2.2.2:0; Local LDP Ident 1.1.1.1:0
        TCP connection: 2.2.2.2.59285 - 1.1.1.1.646
        State: Oper; Msgs sent/rcvd: 14/15; Downstream
        Up time: 00:04:14
        LDP discovery sources:
          FastEthernet0/0, Src IP addr: 10.1.12.2
        Addresses bound to peer LDP Ident:
          10.1.12.2       2.2.2.2         10.1.23.2

查看邻居是否启动,显示对方为2.2.2.2

R2#show mpls ldp neighbor
    Peer LDP Ident: 1.1.1.1:0; Local LDP Ident 2.2.2.2:0
        TCP connection: 1.1.1.1.646 - 2.2.2.2.59285
        State: Oper; Msgs sent/rcvd: 16/15; Downstream
        Up time: 00:05:00
        LDP discovery sources:
          FastEthernet0/0, Src IP addr: 10.1.12.1
        Addresses bound to peer LDP Ident:
          10.1.12.1       1.1.1.1
    Peer LDP Ident: 3.3.3.3:0; Local LDP Ident 2.2.2.2:0
        TCP connection: 3.3.3.3.23559 - 2.2.2.2.646
        State: Oper; Msgs sent/rcvd: 12/12; Downstream
        Up time: 00:02:11
        LDP discovery sources:
          FastEthernet1/0, Src IP addr: 10.1.23.3
        Addresses bound to peer LDP Ident:
          3.3.3.3         10.1.34.3       10.1.23.3

R2有两个邻居,一个是1.1.1.1,一个为3.3.3.3

R2#show mpls ldp parameters
Protocol version: 1
Session hold time: 180 sec; keep alive interval: 60 sec
Discovery hello: holdtime: 15 sec; interval: 5 sec
Discovery targeted hello: holdtime: 90 sec; interval: 10 sec
Downstream on Demand max hop count: 255
Downstream on Demand Path Vector Limit: 255
LDP for targeted sessions
LDP initial/maximum backoff: 15/120 sec
LDP loop detection: off

查看LDP参数

4.2.3 查看信息表

R1#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/2] via 10.1.12.2, 00:25:41, FastEthernet0/0
     3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/3] via 10.1.12.2, 00:22:52, FastEthernet0/0
     4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/4] via 10.1.12.2, 00:22:52, FastEthernet0/0
     10.0.0.0/24 is subnetted, 3 subnets
C       10.1.12.0 is directly connected, FastEthernet0/0
O       10.1.23.0 [110/2] via 10.1.12.2, 00:25:06, FastEthernet0/0
O       10.1.34.0 [110/3] via 10.1.12.2, 00:22:52, FastEthernet0/0

查看RIB表

R1#show mpls ldp bindings
  lib entry: 1.1.1.1/32, rev 4
        local binding:  label: imp-null
        remote binding: lsr: 2.2.2.2:0, label: 200
  lib entry: 2.2.2.2/32, rev 6
        local binding:  label: 100
        remote binding: lsr: 2.2.2.2:0, label: imp-null
  lib entry: 3.3.3.3/32, rev 12
        local binding:  label: 103
        remote binding: lsr: 2.2.2.2:0, label: 202
  lib entry: 4.4.4.4/32, rev 10
        local binding:  label: 102
        remote binding: lsr: 2.2.2.2:0, label: 201
  lib entry: 10.1.12.0/24, rev 2
        local binding:  label: imp-null
        remote binding: lsr: 2.2.2.2:0, label: imp-null
  lib entry: 10.1.23.0/24, rev 8
        local binding:  label: 101
        remote binding: lsr: 2.2.2.2:0, label: imp-null
  lib entry: 10.1.34.0/24, rev 14
        local binding:  label: 104
        remote binding: lsr: 2.2.2.2:0, label: 203

查看LIB表:

对于1.1.1.1的路由:

本地捆绑的标签为为IMP-NULL,因为直连且PHP,为自己直连路由分配的便签为IMP-NULL;

从R2学到的关于1.1.1.1的路由捆绑的标签为200;

对于2.2.2.2的路由:

本地捆绑的标签值为100;

从R2传过来的标签为IMP-NULL,因为是R2本地直连的路由;

对于3.3.3.3的路由:

本地捆绑的标签值为103;

从R2传过来的标签为202;

R1#show mpls forwarding-table
Local  Outgoing      Prefix            Bytes Label   Outgoing   Next Hop
Label  Label or VC   or Tunnel Id      Switched      interface
100    Pop Label     2.2.2.2/32        0             Fa0/0      10.1.12.2
101    Pop Label     10.1.23.0/24      0             Fa0/0      10.1.12.2
102    201           4.4.4.4/32        0             Fa0/0      10.1.12.2
103    202           3.3.3.3/32        0             Fa0/0      10.1.12.2
104    203           10.1.34.0/24      0             Fa0/0      10.1.12.2

查看LFIB表

LOCAL:本地R1为路由前缀捆绑给的标签

OUTGOING:下一跳提供的

NEXT HOP:从LIB或者FIB来的

R1#show ip cef
Prefix               Next Hop             Interface
0.0.0.0/0            no route
0.0.0.0/8            drop
0.0.0.0/32           receive
1.1.1.1/32           receive              Loopback0
2.2.2.2/32           10.1.12.2            FastEthernet0/0
3.3.3.3/32           10.1.12.2            FastEthernet0/0
4.4.4.4/32           10.1.12.2            FastEthernet0/0
10.1.12.0/24         attached             FastEthernet0/0
10.1.12.0/32         receive              FastEthernet0/0
10.1.12.1/32         receive              FastEthernet0/0
10.1.12.2/32         attached             FastEthernet0/0
10.1.12.255/32       receive              FastEthernet0/0
10.1.23.0/24         10.1.12.2            FastEthernet0/0
10.1.34.0/24         10.1.12.2            FastEthernet0/0
127.0.0.0/8          drop
224.0.0.0/4          drop
224.0.0.0/24         receive
240.0.0.0/4          drop
255.255.255.255/32   receive

查看FIB表,指示下一跳和出接口

4.2.3.1 控制层流程

以4.4.4.4路由为例,R1R2R3都有R4的路由。

R4#show mpls ldp binding
  lib entry: 4.4.4.0/24, rev 4
        local binding:  label: imp-null
  lib entry: 4.4.4.4/32, rev 8
        remote binding: lsr: 3.3.3.3:0, label: 300

R4本地绑定4.4.4.4路由便签为IMP-NULL,R4从R3学到的路由压入标签为300

R3#show mpls ldp bindings
  lib entry: 4.4.4.0/24, rev 9
        remote binding: lsr: 4.4.4.4:0, label: imp-null
  lib entry: 4.4.4.4/32, rev 8
        local binding:  label: 300
        remote binding: lsr: 2.2.2.2:0, label: 201

R3本地绑定4.4.4.4路由便签为300,从R2学到的4.4.4.4的标签为201,从R4学到的为IMP-NULL

R2#show mpls ldp bindings

R2#show mpls ldp bindings
  lib entry: 4.4.4.4/32, rev 10
        local binding:  label: 201
        remote binding: lsr: 3.3.3.3:0, label: 300
        remote binding: lsr: 1.1.1.1:0, label: 102

R2本地绑定4.4.4.4路由便签为201,从R3学到的标签为300,从R1学到的标签为102

R1#show mpls ldp bindings
  lib entry: 4.4.4.4/32, rev 10
        local binding:  label: 102
        remote binding: lsr: 2.2.2.2:0, label: 201

R1本地绑定4.4.4.4路由便签为102,从R2学到的为201

即R4本地绑定IMP-NULL给R3,R3绑定300给R2,R2绑定201给R1,R1本地绑定102

4.2.3.2 数据层流程

R1发出IP数据包到4.4.4.4

由于R1始发,如PING,初始为IP包,查CEF表即FIB表。

R1#show ip cef
Prefix               Next Hop             Interface
0.0.0.0/0            no route
0.0.0.0/8            drop
0.0.0.0/32           receive
1.1.1.1/32           receive              Loopback0
2.2.2.2/32           10.1.12.2            FastEthernet0/0
3.3.3.3/32           10.1.12.2            FastEthernet0/0
4.4.4.4/32           10.1.12.2            FastEthernet0/0
10.1.12.0/24         attached             FastEthernet0/0
10.1.12.0/32         receive              FastEthernet0/0
10.1.12.1/32         receive              FastEthernet0/0
10.1.12.2/32         attached             FastEthernet0/0
10.1.12.255/32       receive              FastEthernet0/0
10.1.23.0/24         10.1.12.2            FastEthernet0/0
10.1.34.0/24         10.1.12.2            FastEthernet0/0
127.0.0.0/8          drop
224.0.0.0/4          drop
224.0.0.0/24         receive
240.0.0.0/4          drop
255.255.255.255/32   receive
R1#show ip cef 4.4.4.4 detail
4.4.4.4/32, epoch 0
  local label info: global/102
  nexthop 10.1.12.2 FastEthernet0/0 label 201

查看明细表,显示压入标签201,即控制层面R2位4.4.4.4路由绑定的标签

R2收到压入201的标签包后,查LFIB表

R2#show mpls forwarding-table
Local  Outgoing      Prefix            Bytes Label   Outgoing   Next Hop
Label  Label or VC   or Tunnel Id      Switched      interface
200    Pop Label     1.1.1.1/32        0             Fa0/0      10.1.12.1
201    300           4.4.4.4/32        0             Fa1/0      10.1.23.3
202    Pop Label     3.3.3.3/32        0             Fa1/0      10.1.23.3
203    Pop Label     10.1.34.0/24      0             Fa1/0      10.1.23.3

显示4.4.4.4的入栈为201,出栈为300,出口为F1/0,下一跳为10.1.23.3

R2将标签201置换为300,发给R3,R3接着查自己的LFIB表

R3#show mpls forwarding-table
Local  Outgoing      Prefix            Bytes Label   Outgoing   Next Hop
Label  Label or VC   or Tunnel Id      Switched      interface
300    No Label      4.4.4.4/32        0             Fa0/0      10.1.34.4
301    Pop Label     2.2.2.2/32        0             Fa1/0      10.1.23.2
302    200           1.1.1.1/32        0             Fa1/0      10.1.23.2
303    Pop Label     10.1.12.0/24      0             Fa1/0      10.1.23.2

显示入栈为300的4.4.4.4的路由,显示NO LABEL,弹掉所有标签,变成IP包发给R4

整体流程:

  • R1始发IP,查看CEF即FIB表,压入标签201,发给R2;
  • R2查本地LFIB表,R2将标签201置换为300,发给R3;
  • R3查本地LFIB表,弹出所有标签,变成IP包发给R4;

4.3 MPLS环境中的BGP

4.3.1 试验1

4.3.1.1 OSPF配置

R1配置

R1(config)#interface fastEthernet 0/0
R1(config-if)#ip address 10.1.12.1 255.255.255.0
R1(config-if)#no shutdown 
R1(config)#interface fastEthernet 1/0
R1(config-if)#ip address 10.1.15.1 255.255.255.0
R1(config-if)#no shutdown
R1(config)#interface loopback 0
R1(config-if)#ip address 1.1.1.1 255.255.255.255
R1(config-if)#no shutdown

R1(config)#router ospf 1
R1(config-router)#router-id 1.1.1.1
R1(config-router)#network 10.1.12.1 0.0.0.0 area 0
R1(config-router)#network 10.1.15.1 0.0.0.0 area 0
R1(config-router)#network 1.1.1.1 0.0.0.0 area 0

R2配置

R2(config)#interface fastEthernet 0/0
R2(config-if)#ip address 10.1.12.2 255.255.255.0
R2(config-if)#no shutdown
R2(config)#interface fastEthernet 1/0
R2(config-if)#ip address 10.1.23.2 255.255.255.0
R2(config-if)#no shutdown
R2(config)#interface loopback 0
R2(config-if)#ip address 2.2.2.2 255.255.255.255
R2(config-if)#no shutdown

R2(config)#router ospf 1
R2(config-router)#router-id 2.2.2.2
R2(config-router)#network 10.1.12.2 0.0.0.0 area 0
R2(config-router)#network 10.1.23.2 0.0.0.0 area 0
R2(config-router)#network 2.2.2.2 0.0.0.0 area 0

R3配置

R3(config)#interface fastEthernet 1/0
R3(config-if)#ip address 10.1.23.3 255.255.255.0
R3(config-if)#no shutdown
R3(config)#interface fastEthernet 0/0
R3(config-if)#ip address 10.1.34.3 255.255.255.0
R3(config-if)#no shutdown
R3(config)#interface loopback 0
R3(config-if)#ip address 3.3.3.3 255.255.255.255
R3(config-if)#no shutdown

R3(config)#router ospf 1
R3(config-router)#router-id 3.3.3.3
R3(config-router)#network 10.1.23.3 0.0.0.0 area 0
R3(config-router)#network 10.1.34.3 0.0.0.0 area 0
R3(config-router)#network 3.3.3.3 0.0.0.0 area 0

R4配置

R4(config)#interface fastEthernet 0/0
R4(config-if)#ip address 10.1.34.4 255.255.255.0
R4(config-if)#no shutdown
R4(config)#interface fastEthernet 1/0
R4(config-if)#ip address 10.1.46.4 255.255.255.0
R4(config-if)#no shutdown
R4(config)#interface loopback 0
R4(config-if)#ip address 4.4.4.4 255.255.255.255
R4(config-if)#no shutdown

R4(config)#router ospf 1
R4(config-router)#router-id 4.4.4.4
R4(config-router)#network 10.1.34.4 0.0.0.0 area 0
R4(config-router)#network 10.1.46.4 0.0.0.0 area 0
R4(config-router)#network 4.4.4.4 0.0.0.0 area 0

R5配置,不需要运行OSPF

R5(config)#interface fastEthernet 1/0
R5(config-if)#ip address 10.1.15.5 255.255.255.0
R5(config-if)#no shutdown
R5(config)#interface loopback 0
R5(config-if)#ip address 5.5.5.5 255.255.255.255
R5(config-if)#no shutdown
R5(config-if)#exit

R6配置,不需要运行OSPF

R6(config)#interface fastEthernet 1/0

R6(config)#interface fastEthernet 1/0
R6(config-if)#ip address 10.1.46.6 255.255.255.0
R6(config-if)#no shutdown
R6(config)#interface loopback 0
R6(config-if)#ip address 6.6.6.6 255.255.255.255
R6(config-if)#no shutdown
R1#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/2] via 10.1.12.2, 00:15:43, FastEthernet0/0
     3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/3] via 10.1.12.2, 00:09:46, FastEthernet0/0
     4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/4] via 10.1.12.2, 00:05:33, FastEthernet0/0
     10.0.0.0/24 is subnetted, 5 subnets
C       10.1.15.0 is directly connected, FastEthernet1/0
C       10.1.12.0 is directly connected, FastEthernet0/0
O       10.1.23.0 [110/2] via 10.1.12.2, 00:16:03, FastEthernet0/0
O       10.1.46.0 [110/4] via 10.1.12.2, 00:05:33, FastEthernet0/0
O       10.1.34.0 [110/3] via 10.1.12.2, 00:10:00, FastEthernet0/0

R1R2R3R4上路由都有了。

4.3.1.2 运行BGP

R1R4基于IBGP关系,R1R5、R4R6基于EBGP关系

R1(config)#router bgp 1234 
R1(config-router)#bgp router-id 1.1.1.1
R1(config-router)#neighbor 10.1.15.5 remote-as 500
R1(config-router)#neighbor 10.1.34.4 remote-as 1234
R4(config)#router bgp 1234
R4(config-router)#bgp router-id 4.4.4.4
R4(config-router)#neighbor 10.1.12.1 remote-as 1234
R4(config-router)#neighbor 10.1.46.6 remote-as 600
R5(config)#router bgp 500
R5(config-router)#bgp router-id 5.5.5.5
R5(config-router)#neighbor 10.1.15.1 remote-as 1234
R6(config)#router bgp 600
R6(config-router)#bgp router-id 6.6.6.6
R6(config-router)#neighbor 10.1.46.4 remote-as 1234

4.3.1.3 测试1:BGP路由黑洞

将5.5.5.5路由放入R5

R5(config)#router bgp 500
R5(config-router)#network 5.5.5.5 mask 255.255.255.255
R1#show ip bgp
BGP table version is 2, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 5.5.5.5/32       10.1.15.5                0             0 500 i

这时R1学到了R5放入的5.5.5.5的路由

R4#show ip bgp
BGP table version is 2, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i5.5.5.5/32       10.1.15.5                0    100      0 500 i

R1会把路由传给R4,R4上也有了5.5.5.5的路由

R6#show ip bgp
BGP table version is 2, local router ID is 6.6.6.6
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 5.5.5.5/32       10.1.46.4                              0 1234 500 i

R4也会把该路由传给R6,

R6#ping 5.5.5.5
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 5.5.5.5, timeout is 2 seconds:
U.U.U
Success rate is 0 percent (0/5)

虽然R6有了路由,但是R6PING不用5.5.5.5

R6#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

     5.0.0.0/32 is subnetted, 1 subnets
B       5.5.5.5 [20/0] via 10.1.46.4, 00:03:22
     6.0.0.0/32 is subnetted, 1 subnets
C       6.6.6.6 is directly connected, Loopback0
     10.0.0.0/24 is subnetted, 1 subnets
C       10.1.46.0 is directly connected, FastEthernet1/0

路由层面OK,但是数据层面没有

因为R6传路由到5.5.5.5, 下一跳是R4,

R4#show ip bgp
BGP table version is 2, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i5.5.5.5/32       10.1.15.5                0    100      0 500 i

R4去往5.5.5.5的下一跳路由是10.1.15.5,可是不是直连路由,需要递归查找

R4#show ip route 10.1.15.5
Routing entry for 10.1.15.0/24
  Known via "ospf 1", distance 110, metric 4, type intra area
  Last update from 10.1.34.3 on FastEthernet0/0, 00:22:31 ago
  Routing Descriptor Blocks:
  * 10.1.34.3, from 1.1.1.1, 00:22:31 ago, via FastEthernet0/0
      Route metric is 4, traffic share count is 1

递归显示下一跳是10.1.34.3

R4传给R3后,

R3#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

     1.0.0.0/32 is subnetted, 1 subnets
O       1.1.1.1 [110/3] via 10.1.23.2, 00:28:24, FastEthernet1/0
     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/2] via 10.1.23.2, 00:28:24, FastEthernet1/0
     3.0.0.0/32 is subnetted, 1 subnets
C       3.3.3.3 is directly connected, Loopback0
     4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/2] via 10.1.34.4, 00:24:00, FastEthernet0/0
     10.0.0.0/24 is subnetted, 5 subnets
O       10.1.15.0 [110/3] via 10.1.23.2, 00:28:24, FastEthernet1/0
O       10.1.12.0 [110/2] via 10.1.23.2, 00:28:24, FastEthernet1/0
C       10.1.23.0 is directly connected, FastEthernet1/0
O       10.1.46.0 [110/2] via 10.1.34.4, 00:24:00, FastEthernet0/0
C       10.1.34.0 is directly connected, FastEthernet0/0

通过查看发现R3中没有5.5.5.5的路由,因为R2R3没有运行BGP

解决办法就是让R2R3都运行BGP,当路由器多时,都运行BGP,都会占用资源,都需要维护IBGP邻居关系

4.3.1.3.1 解决办法1:MPLS

让数据包躲在标签后面,R1R2R3R4运行MPLS,激活邻居关系

R1配置MPLS

R1(config)#mpls ldp router-id loopback 0
R1(config)#mpls label range 100 199
R1(config)#interface fastEthernet 0/0
R1(config-if)#mpls ip

R2配置MPLS

R2(config)#mpls ldp router-id loopback 0
R2(config)#mpls label range 200 299
R2(config)#interface fastEthernet 0/0
R2(config-if)#mpls ip
R2(config)#interface fastEthernet 1/0
R2(config-if)#mpls ip

R3配置MPLS

R3(config)#mpls ldp router-id loopback 0
R3(config)#mpls label range 300 399
R3(config)#interface fastEthernet 1/0
R3(config-if)#mpls ip
R3(config)#interface fastEthernet 0/0
R3(config-if)#mpls ip

R4配置MPLS

R4(config)#mpls ldp router-id loopback 0
R4(config)#mpls label range 400 499
R4(config)#interface fastEthernet 0/0
R4(config-if)#mpls ip
R6#ping 5.5.5.5

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 5.5.5.5, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)

这时依旧还是PING不通,因为R5没有回程路由

R5(config)#ip route 0.0.0.0 0.0.0.0 10.1.15.1

添加一条默认路由

R6#ping 5.5.5.5

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 5.5.5.5, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 136/147/160 ms

这时就可以PING通了

R3#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

     1.0.0.0/32 is subnetted, 1 subnets
O       1.1.1.1 [110/3] via 10.1.23.2, 00:50:17, FastEthernet1/0
     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/2] via 10.1.23.2, 00:50:17, FastEthernet1/0
     3.0.0.0/32 is subnetted, 1 subnets
C       3.3.3.3 is directly connected, Loopback0
     4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/2] via 10.1.34.4, 00:45:52, FastEthernet0/0
     10.0.0.0/24 is subnetted, 5 subnets
O       10.1.15.0 [110/3] via 10.1.23.2, 00:50:17, FastEthernet1/0
O       10.1.12.0 [110/2] via 10.1.23.2, 00:50:17, FastEthernet1/0
C       10.1.23.0 is directly connected, FastEthernet1/0
O       10.1.46.0 [110/2] via 10.1.34.4, 00:45:52, FastEthernet0/0
C       10.1.34.0 is directly connected, FastEthernet0/0

R2R3并没有5.5.5.5的路由,但是为什么能PING通?

R6#traceroute 5.5.5.5

R6#traceroute 5.5.5.5

Type escape sequence to abort.
Tracing the route to 5.5.5.5

  1 10.1.46.4 20 msec 20 msec 24 msec
  2 10.1.34.3 [MPLS: Label 304 Exp 0] 128 msec 120 msec 132 msec
  3 10.1.23.2 [MPLS: Label 203 Exp 0] 120 msec 120 msec 128 msec
  4 10.1.12.1 124 msec 116 msec 128 msec
  5 10.1.15.5 144 msec 140 msec *

TRACER路径,没有显示标签

R6(config)#interface fastEthernet 1/0
R6(config-if)#mpls ip

R5的接口上运行LDP,这个本身不会有影响,因为R4相连的接口没有启动MPLS IP,只是为了用来显示查看标签

R6#traceroute 5.5.5.5

Type escape sequence to abort.
Tracing the route to 5.5.5.5

  1 10.1.46.4 24 msec 16 msec 32 msec
  2 10.1.34.3 [MPLS: Label 304 Exp 0] 92 msec 108 msec 96 msec
  3 10.1.23.2 [MPLS: Label 203 Exp 0] 132 msec 112 msec 132 msec
  4 10.1.12.1 116 msec 112 msec 120 msec
  5 10.1.15.5 148 msec 116 msec *

TRACERT带标签

R6发一个数据包到R4,

R4#show ip cef 5.5.5.5 detail
5.5.5.5/32, epoch 0
  recursive via 10.1.15.5
    nexthop 10.1.34.3 FastEthernet0/0 label 304

R4收到后,查看CEF表,下一跳为R3,需要压入R3给5.5.5.5的标签304

R3#show mpls ldp bindings
  lib entry: 1.1.1.1/32, rev 2
        local binding:  label: 300
        remote binding: lsr: 2.2.2.2:0, label: 200
        remote binding: lsr: 4.4.4.4:0, label: 400
  lib entry: 2.2.2.2/32, rev 4
        local binding:  label: 301
        remote binding: lsr: 2.2.2.2:0, label: imp-null
        remote binding: lsr: 4.4.4.4:0, label: 401
  lib entry: 3.3.3.3/32, rev 6
        local binding:  label: imp-null
        remote binding: lsr: 2.2.2.2:0, label: 201
        remote binding: lsr: 4.4.4.4:0, label: 402
  lib entry: 4.4.4.4/32, rev 8
        local binding:  label: 302
        remote binding: lsr: 2.2.2.2:0, label: 202
        remote binding: lsr: 4.4.4.4:0, label: imp-null
  lib entry: 10.1.12.0/24, rev 10
        local binding:  label: 303
        remote binding: lsr: 2.2.2.2:0, label: imp-null
        remote binding: lsr: 4.4.4.4:0, label: 403
  lib entry: 10.1.15.0/24, rev 12
        local binding:  label: 304
        remote binding: lsr: 2.2.2.2:0, label: 203
        remote binding: lsr: 4.4.4.4:0, label: 404
  lib entry: 10.1.23.0/24, rev 14
        local binding:  label: imp-null
        remote binding: lsr: 2.2.2.2:0, label: imp-null
        remote binding: lsr: 4.4.4.4:0, label: 405
  lib entry: 10.1.34.0/24, rev 16
        local binding:  label: imp-null
        remote binding: lsr: 2.2.2.2:0, label: 204
        remote binding: lsr: 4.4.4.4:0, label: imp-null
  lib entry: 10.1.46.0/24, rev 18
        local binding:  label: 305
        remote binding: lsr: 2.2.2.2:0, label: 205
        remote binding: lsr: 4.4.4.4:0, label: imp-null

R3中找到304标签

  lib entry: 10.1.15.0/24, rev 12
        local binding:  label: 304
        remote binding: lsr: 2.2.2.2:0, label: 203
        remote binding: lsr: 4.4.4.4:0, label: 404

这个是R3给10.1.15.0/24路由前缀分的标签

R4压入R3给10.1.15.0路由前缀分的标签?注意LDP不会为BGP分配标签,只会为IGP分配

R4#show ip bgp
BGP table version is 2, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i5.5.5.5/32       10.1.15.5                0    100      0 500 i

而R4中5.5.5.5是BGP的路由,不是IGP路由

R3中没有5.5.5.5,所以也就不会有5.5.5.5的前缀标签,但是LDP又不会给BGP分配标签,这就意味着R3中不会有5.5.5.5的标签。

看到在R4路由表中,5.5.5.5的路由下一跳是10.1.15.5,虽然不能用BGP中5.5.5.5的前缀标签,但是可以用下一跳10.1.15.5在IGP路由中,所以R4用10.1.15.5标签,R3给的。

R3#show mpls forwarding-table
Local  Outgoing      Prefix            Bytes Label   Outgoing   Next Hop
Label  Label or VC   or Tunnel Id      Switched      interface
300    200           1.1.1.1/32        0             Fa1/0      10.1.23.2
301    Pop Label     2.2.2.2/32        0             Fa1/0      10.1.23.2
302    Pop Label     4.4.4.4/32        0             Fa0/0      10.1.34.4
303    Pop Label     10.1.12.0/24      454           Fa1/0      10.1.23.2
304    203           10.1.15.0/24      590           Fa1/0      10.1.23.2
305    Pop Label     10.1.46.0/24      570           Fa0/0      10.1.34.4

R3收到后,R3给10.1.15.5将304标签替换为203,后发给R2

R2#show mpls forwarding-table
Local  Outgoing      Prefix            Bytes Label   Outgoing   Next Hop
Label  Label or VC   or Tunnel Id      Switched      interface
200    Pop Label     1.1.1.1/32        0             Fa0/0      10.1.12.1
201    Pop Label     3.3.3.3/32        0             Fa1/0      10.1.23.3
202    302           4.4.4.4/32        0             Fa1/0      10.1.23.3
203    Pop Label     10.1.15.0/24      570           Fa0/0      10.1.12.1
204    Pop Label     10.1.34.0/24      508           Fa1/0      10.1.23.3
205    305           10.1.46.0/24      590           Fa1/0      10.1.23.3

R2收到后,R2发现203对应的为POP,将203弹出变为IP包,交给R1

R1#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/2] via 10.1.12.2, 00:11:14, FastEthernet0/0
     3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/3] via 10.1.12.2, 00:10:58, FastEthernet0/0
     4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/4] via 10.1.12.2, 00:09:39, FastEthernet0/0
     5.0.0.0/32 is subnetted, 1 subnets
B       5.5.5.5 [20/0] via 10.1.15.5, 00:07:09
     10.0.0.0/24 is subnetted, 5 subnets
C       10.1.15.0 is directly connected, FastEthernet1/0
C       10.1.12.0 is directly connected, FastEthernet0/0
O       10.1.23.0 [110/2] via 10.1.12.2, 00:11:28, FastEthernet0/0
O       10.1.46.0 [110/4] via 10.1.12.2, 00:09:53, FastEthernet0/0
O       10.1.34.0 [110/3] via 10.1.12.2, 00:10:03, FastEthernet0/0

R1查询CEF表,发现去往5.5.5.5的是10.1.15.5,转给了R5

总结,没有运行MPLS不用的原因是因为R2R3出现了路由黑洞,没有运行BGP,也就没有5.5.5.5的路由,出现了丢包。运行MPLS后,就通了。(LDP不会为BGP发标签,但是可以为BGP递归的下一跳的标签走)

4.3.1.3.2 解决办法2:MPLS

之前试验中,在OSPF中宣告了R1R4外连的直连网段,所以R1R4有了去往R5R6的路由,就可以为去往R5R6的路由分发标签。

BGP环境中,一般情况下,不会通告AS外路由进OSPF的。即R1R4不应该通告直连路由进OSPF。

R1(config)#router ospf 1
R1(config-router)#no network 10.1.15.1 0.0.0.0 area 0
R4(config)#router ospf 1
R4(config-router)#no network 10.1.46.4 0.0.0.0 area 0
R4#show ip bgp
BGP table version is 3, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
* i5.5.5.5/32       10.1.15.5                0    100      0 500 i

不通告时, R4就没有了5.5.5.5的路由,也就不会优化>。

这时可以直接在R1R4上分别指NEXT-HOP

R1(config)#router bgp 1234
R1(config-router)#neighbor 10.1.34.4 next-hop-self
R4(config)#router bgp 1234
R4(config-router)#neighbor 10.1.12.1 next-hop-self
R4#show ip bgp
BGP table version is 4, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i5.5.5.5/32       10.1.12.1                0    100      0 500 i

这时R4上的BGP路由就优化了,下一跳直接指向R1

R6#ping 5.5.5.5

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 5.5.5.5, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)

这时R6是PING不通R5的。

R4#show ip cef 5.5.5.5
5.5.5.5/32
  nexthop 10.1.34.3 FastEthernet0/0 label 303

R4BGP中,下一跳指向R1,CEF表中是压入标签303,正常情况下是下一跳给的标签,即10.1.12.1给的标签,发给R3

R3#show mpls forwarding-table
Local  Outgoing      Prefix            Bytes Label   Outgoing   Next Hop
Label  Label or VC   or Tunnel Id      Switched      interface
300    200           1.1.1.1/32        0             Fa1/0      10.1.23.2
301    Pop Label     2.2.2.2/32        0             Fa1/0      10.1.23.2
302    Pop Label     4.4.4.4/32        0             Fa0/0      10.1.34.4
303    Pop Label     10.1.12.0/24      4199          Fa1/0      10.1.23.2

R3中303的标签是POP,这时变成IP包,传给了R2,

R2收到IP包后,没有5.5.5.5的路由,就丢弃了。

为什么R3要把标签弹出?因为PHP,R4压标签,用的是R1-R2的标签,R3给的,R3接着发时,需要用到R2给的标签,而R2给R1-R2分配的是IMP-NULL(因为直连),所以R2通告给R3是是弹出。问题出在R2这里。

解决办法:之前R1和R4的直连关系建立在直连接口上,应该建立在LOOPBACK接口上。

之前5.5.5。5的下一跳是10.1.12.1,现在变成R1的LP接口1.1.1.1,这时R4发数据给R5时,递归发现5.5.5.5的下一跳是1.1.1.1(5.5.5.5是BGP路由,LDP不用,用BGP的下一跳路由),而1.1.1.1是IGP路由,就可以用1.1.1.1的标签进行转发。

R1(config)#router bgp 1234
R1(config-router)#no neighbor 10.1.34.4
R1(config-router)#neighbor 4.4.4.4 remote-as 1234
R1(config-router)#neighbor 4.4.4.4 update-source loopback 0
R1(config-router)#neighbor 4.4.4.4 next-hop-self
R4(config)#router bgp 1234
R4(config-router)#no neighbor 10.1.12.1
R4(config-router)#neighbor 1.1.1.1 remote-as 1234
R4(config-router)#neighbor 1.1.1.1 update-source loopback 0
R4(config-router)#neighbor 1.1.1.1 next-hop-self
R6#ping 5.5.5.5

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 5.5.5.5, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)

依旧PING不通

R6PINGR5,可以过去,回来时,R5因为默认路由,可以给R1,由于之前R1和R4删除了直连路由进OSPF,所以R1上没有去往10.1.46.6的路由。

这时需要把R6的6.6.6.6路由放进BGP,R1就有了6.6.6.6的路由。

R6(config)#router bgp 600
R6(config-router)#network 6.6.6.6 mask 255.255.255.255
R4#show ip bgp
BGP table version is 9, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i5.5.5.5/32       1.1.1.1                  0    100      0 500 i
*> 6.6.6.6/32       10.1.46.6                0             0 600 i
R1#show ip bgp
BGP table version is 3, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 5.5.5.5/32       10.1.15.5                0             0 500 i
*>i6.6.6.6/32       4.4.4.4                  0    100      0 600 i

这时R1和R4上就有了6.6.6.6的路由,而且是优化的

R6#ping 5.5.5.5 source 6.6.6.6

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 5.5.5.5, timeout is 2 seconds:
Packet sent with a source address of 6.6.6.6
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 124/146/172 ms

这时就可以PING通了

R6#traceroute 5.5.5.5 source 6.6.6.6

Type escape sequence to abort.
Tracing the route to 5.5.5.5

  1 10.1.46.4 20 msec 24 msec 24 msec
  2 10.1.34.3 [MPLS: Label 300 Exp 0] 140 msec 76 msec 136 msec
  3 10.1.23.2 [MPLS: Label 200 Exp 0] 120 msec 124 msec 104 msec
  4 10.1.12.1 136 msec 120 msec 120 msec
  5 10.1.15.5 148 msec 144 msec *

TRACERT查看路径

R3#show mpls ldp bindings
  lib entry: 1.1.1.1/32, rev 2
        local binding:  label: 300
        remote binding: lsr: 2.2.2.2:0, label: 200
        remote binding: lsr: 4.4.4.4:0, label: 400

R3给1.1.1.1分配的标签是300,即R4收到R6包后,BGP路由递归找到下一跳是1.1.1.1。

R3#show mpls forwarding-table
Local  Outgoing      Prefix            Bytes Label   Outgoing   Next Hop
Label  Label or VC   or Tunnel Id      Switched      interface
300    200           1.1.1.1/32        5181          Fa1/0      10.1.23.2
301    Pop Label     2.2.2.2/32        0             Fa1/0      10.1.23.2
302    Pop Label     4.4.4.4/32        4573          Fa0/0      10.1.34.4
303    Pop Label     10.1.12.0/24      6442          Fa1/0      10.1.23.2

R3收到后,把300置换为200,发给R2

R2#show mpls forwarding-table
Local  Outgoing      Prefix            Bytes Label   Outgoing   Next Hop
Label  Label or VC   or Tunnel Id      Switched      interface
200    Pop Label     1.1.1.1/32        5266          Fa0/0      10.1.12.1
201    Pop Label     3.3.3.3/32        0             Fa1/0      10.1.23.3
202    302           4.4.4.4/32        4875          Fa1/0      10.1.23.3
204    Pop Label     10.1.34.0/24      5318          Fa1/0      10.1.23.3

R2针对标签为200的路由是POP,发IP包给R1

R1#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/2] via 10.1.12.2, 00:39:19, FastEthernet0/0
     3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/3] via 10.1.12.2, 00:39:19, FastEthernet0/0
     4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/4] via 10.1.12.2, 00:39:19, FastEthernet0/0
     5.0.0.0/32 is subnetted, 1 subnets
B       5.5.5.5 [20/0] via 10.1.15.5, 00:54:29
     6.0.0.0/32 is subnetted, 1 subnets
B       6.6.6.6 [200/0] via 4.4.4.4, 00:05:58
     10.0.0.0/24 is subnetted, 4 subnets
C       10.1.15.0 is directly connected, FastEthernet1/0
C       10.1.12.0 is directly connected, FastEthernet0/0
O       10.1.23.0 [110/2] via 10.1.12.2, 00:39:30, FastEthernet0/0
	10.1.34.0 [110/3] via 10.1.12.2, 00:39:30, FastEthernet0/0

R1发现去往5.5.5.5的下一条是10.1.15.5,也就到了R5.

R5回包给R6.

R5#show ip bgp
BGP table version is 3, local router ID is 5.5.5.5
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 5.5.5.5/32       0.0.0.0                  0         32768 i
*> 6.6.6.6/32       10.1.15.1                              0 1234 600 i

R5查看BGP路由,下一跳是10.1.15.1,即R1

R1#show ip cef 6.6.6.6
6.6.6.6/32
  nexthop 10.1.12.2 FastEthernet0/0 label 202

R1收到包后,查CEF表,压入标签为202,下一跳给R2

R1#show mpls forwarding-table
Local  Outgoing      Prefix            Bytes Label   Outgoing   Next Hop
Label  Label or VC   or Tunnel Id      Switched      interface
100    Pop Label     2.2.2.2/32        0             Fa0/0      10.1.12.2
101    201           3.3.3.3/32        0             Fa0/0      10.1.12.2
102    202           4.4.4.4/32        0             Fa0/0      10.1.12.2
103    Pop Label     10.1.23.0/24      0             Fa0/0      10.1.12.2
104    204           10.1.34.0/24      0             Fa0/0      10.1.12.2

R1给去往4.4.4.4的标签202是R2分配的,,一次下去。

发表回复