实验环境:
操作系统:Windows 10(1607,14393.351,当时最新测试版),模拟器:GNS3 IOU for Windows 1.5.2(当时最新正式版)
注:当然,只要有思科模拟器都可以做这个实验

实验需求:
现在我们需要在上述实验拓扑中做基于 MPLS 的流量工程,规划出一条如下图所示的 MPLE TE tunnel,让 IOU1 和 IOU4 之间的流量从 MPLS TE tunnel 走(IOU1 → IOU7 → IOU3 → IOU5 → IOU4)。

其他相关文章:
- 具体有关流量工程的一些概念,以及为什么要做流量工程,请看这篇文章:《什么是基于 MPLS 的流量工程(What is Traffic Engineering base on MPLS / What is MPLS TE)?》,本篇实验其实也是该篇文章的延伸,强烈建议您先浏览该篇文章,再来看本篇文章。
实验步骤:
1、先配置 IP 地址、 IGP(ISIS)和 MPLS:
IOU1:
conf t int e 0/0 int e 0/1 int r e 0/0-1 , l 0 router isis ip cef |
IOU2:
conf t int e 0/0 int e 0/1 int e 0/2 int e 0/3 int r e 0/0-3 , l 0 router isis ip cef |
IOU3:
conf t int e 0/0 int e 0/1 int e 0/2 int e 1/0 int r e 0/0-2 , e 1/0 , l 0 router isis ip cef |
IOU4:
conf t int e 0/0 int e 0/1 int r e 0/0-1 router isis ip cef 注意!IOU4 上并没有用 ISIS 将 |
IOU5:
conf t int e 0/1 int e 0/2 int e 0/3 int e 1/0 int r e 0/1-3 , e 1/0 , l 0 router isis ip cef |
IOU6:
conf t int e 0/0 int e 0/3 int r e 0/0 , e 0/3 , l 0 router isis ip cef |
IOU7:
conf t int e 0/1 int e 0/0 int e 0/2 int e 0/3 int r e 0/0-3 , l 0 router isis ip cef |
2、在全局和接口下使能 MPLS Traffic Engineering,同时在 ISIS 里也是要配置 MPLS Traffic Engineering 的相关命令的:
IOU1:
! MPLS TE 全局使能 ! MPLS TE 接口使能 ! 配置 ISIS,让 ISIS 支持 MPLS TE |
IOU2:
mpls traffic-eng tunnels int r e 0/0-3 router isis |
IOU3:
mpls traffic-eng tunnels int r e 0/0-2 , e 1/0 router isis |
IOU4:
mpls traffic-eng tunnels int r e 0/0-1 router isis |
IOU5:
mpls traffic-eng tunnels int r e 0/1-3 , e 1/0 router isis |
IOU6:
mpls traffic-eng tunnels int r e 0/0 , e 0/3 router isis |
IOU7:
mpls traffic-eng tunnels int r e 0/0-3 router isis |
3、在 IOU1 和 IOU4 之间建立那条 MPLS TE tunnel:

由上图可知,这个 MPLS TE tunnel 的路径是这样的: IOU1 → IOU7 → IOU3 → IOU5 → IOU4。
在 IOU1 上配置:
! 建立 IOU1 -> IOU7 -> IOU3 -> IOU5 -> IOU4 的 MPLS TE tunnel IOU1: int tun 14 ip unnumbered l 0 tunnel mode mpls traffic-eng tunnel destination 4.4.4.4 tunnel mpls traffic-eng path-option 10 explicit name A ex ip explicit-path name A enable next-address 17.1.1.7 next-address 37.1.1.3 next-address 35.1.1.5 next-address 45.1.1.4 ip route 4.4.4.4 255.255.255.255 tunnel 14
配置 tunnel 的命令解释:
- int tun 14:即建立一个 tunnel 接口;
- ip unnumbered l 0:从 loopback 0 借用一个 IP 地址过来,因为在 IP 网络下任何接口都是要配置 IP 地址的;
- tunnel mode mpls traffic-eng:把 tunnel 的模式配置成 MPLS TE tunnel;
- tunnel destination 4.4.4.4:设置 tunnel 的目的地是去往 IOU4;
- tunnel mpls traffic-eng path-option 10 explicit name A:设置 tunnel 的路径,10 是路径选项的序号,explicit 表示这个路径将会手工逐跳地、显式地配置出来(与之对应的还有一个 dynamic),A 是路径的名称。
配置路径的命令解释:
- ip explicit-path name A enable:A 是路径的名称,enable 表示启用这条路径(与之对应的还有一个 disable);
- next-address xx.x.x.x:配置这个 MPLS TE tunnel 所经过的每一跳的 IP 地址。
ip route 4.4.4.4 255.255.255.255 tunnel 14:最后再写一个静态路由,让去往 4.4.4.4 的数据包从 tunnel 走就可以了。
注意!如下图所示,在没有配置那条 4.4.4.4 的静态路由之前,IOU1 是没有 4.4.4.4 的路由的,因为在 IOU4 上并没有将 loopback 0 口通告到 ISIS:
IOU1#sh ip ro Codes: L - local, 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, H - NHRP, l - LISP a - application route + - replicated route, % - next hop override 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 i L2 2.2.2.2 [115/10] via 12.1.1.2, 00:40:21, Ethernet0/0 3.0.0.0/32 is subnetted, 1 subnets i L2 3.3.3.3 [115/20] via 17.1.1.7, 00:39:51, Ethernet0/1 [115/20] via 12.1.1.2, 00:39:51, Ethernet0/0 5.0.0.0/32 is subnetted, 1 subnets i L2 5.5.5.5 [115/20] via 12.1.1.2, 00:40:01, Ethernet0/0 6.0.0.0/32 is subnetted, 1 subnets i L2 6.6.6.6 [115/20] via 17.1.1.7, 00:39:51, Ethernet0/1 7.0.0.0/32 is subnetted, 1 subnets i L2 7.7.7.7 [115/10] via 17.1.1.7, 00:39:51, Ethernet0/1 12.0.0.0/8 is variably subnetted, 2 subnets, 2 masks C 12.1.1.0/24 is directly connected, Ethernet0/0 L 12.1.1.1/32 is directly connected, Ethernet0/0 17.0.0.0/8 is variably subnetted, 2 subnets, 2 masks C 17.1.1.0/24 is directly connected, Ethernet0/1 L 17.1.1.1/32 is directly connected, Ethernet0/1
配置了那条关于 4.4.4.4 的静态路由后,路由表就有 4.4.4.4 的路由了:
IOU1#sh ip ro
Codes: L - local, 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, H - NHRP, l - LISP
a - application route
+ - replicated route, % - next hop override
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
i L2 2.2.2.2 [115/10] via 12.1.1.2, 00:41:41, Ethernet0/0
3.0.0.0/32 is subnetted, 1 subnets
i L2 3.3.3.3 [115/20] via 17.1.1.7, 00:41:11, Ethernet0/1
[115/20] via 12.1.1.2, 00:41:11, Ethernet0/0
4.0.0.0/32 is subnetted, 1 subnets
S 4.4.4.4 is directly connected, Tunnel14
5.0.0.0/32 is subnetted, 1 subnets
i L2 5.5.5.5 [115/20] via 12.1.1.2, 00:41:21, Ethernet0/0
6.0.0.0/32 is subnetted, 1 subnets
i L2 6.6.6.6 [115/20] via 17.1.1.7, 00:41:11, Ethernet0/1
7.0.0.0/32 is subnetted, 1 subnets
i L2 7.7.7.7 [115/10] via 17.1.1.7, 00:41:11, Ethernet0/1
12.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 12.1.1.0/24 is directly connected, Ethernet0/0
L 12.1.1.1/32 is directly connected, Ethernet0/0
17.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 17.1.1.0/24 is directly connected, Ethernet0/1
L 17.1.1.1/32 is directly connected, Ethernet0/1
使用一些 show 命令观察一下:
在 IOU1 上 sh ip int brief 可以看到 Tunnel14 这个接口已经起来了:
IOU1#sh ip int brief Interface IP-Address OK? Method Status Protocol Ethernet0/0 12.1.1.1 YES manual up up Ethernet0/1 17.1.1.1 YES manual up up Ethernet0/2 unassigned YES NVRAM administratively down down Ethernet0/3 unassigned YES NVRAM administratively down down Ethernet1/0 unassigned YES NVRAM administratively down down Ethernet1/1 unassigned YES NVRAM administratively down down Ethernet1/2 unassigned YES NVRAM administratively down down Ethernet1/3 unassigned YES NVRAM administratively down down Serial2/0 unassigned YES NVRAM administratively down down Serial2/1 unassigned YES NVRAM administratively down down Serial2/2 unassigned YES NVRAM administratively down down Serial2/3 unassigned YES NVRAM administratively down down Serial3/0 unassigned YES NVRAM administratively down down Serial3/1 unassigned YES NVRAM administratively down down Serial3/2 unassigned YES NVRAM administratively down down Serial3/3 unassigned YES NVRAM administratively down down Loopback0 1.1.1.1 YES manual up up Tunnel14 1.1.1.1 YES TFTP up up
注意,在 IOU1 上 sh mpls forwarding-table 是看不到 MPLS 标签的:
IOU1#sh mpls forwarding-table Local Outgoing Prefix Bytes Label Outgoing Next Hop Label Label or Tunnel Id Switched interface
在 IOU1 上也没有开启 LDP:
IOU1#sh mpls ldp neighbor IOU1# IOU1#sh mpls ldp bindings LIB not enabled
MPLS TE tunnel 的 MPLS 标签其实是由 RSVP 来分配的。
要想在 IOU1 上查看 MPLS 标签要 sh mpls traffic-eng tunnels tunnel 14(这条 show 命令还可以看到这条 MPLS TE tunnel 所经过的每一跳 IP 地址):
IOU1#sh mpls traffic-eng tunnels tunnel 14 Name: IOU1_t14 (Tunnel14) Destination: 4.4.4.4 Status: Admin: up Oper: up Path: valid Signalling: connected path option 10, type explicit A (Basis for Setup, path weight 40) Config Parameters: Bandwidth: 0 kbps (Global) Priority: 7 7 Affinity: 0x0/0xFFFF Metric Type: TE (default) AutoRoute: disabled LockDown: disabled Loadshare: 0 bw-based auto-bw: disabled Active Path Option Parameters: State: explicit path option 10 is active BandwidthOverride: disabled LockDown: disabled Verbatim: disabled InLabel : - OutLabel : Ethernet0/1, 7000 RSVP Signalling Info: Src 1.1.1.1, Dst 4.4.4.4, Tun_Id 14, Tun_Instance 5 RSVP Path Info: My Address: 17.1.1.1 Explicit Route: 17.1.1.7 37.1.1.7 37.1.1.3 35.1.1.3 35.1.1.5 45.1.1.5 45.1.1.4 4.4.4.4 Record Route: NONE Tspec: ave rate=0 kbits, burst=1000 bytes, peak rate=0 kbits RSVP Resv Info: Record Route: NONE Fspec: ave rate=0 kbits, burst=1000 bytes, peak rate=0 kbits Shortest Unconstrained Path Info: Path Weight: 30 (TE) Explicit Route: 12.1.1.1 12.1.1.2 23.1.1.2 23.1.1.3 34.1.1.3 34.1.1.4 4.4.4.4 History: Tunnel: Time since created: 6 minutes, 56 seconds Time since path change: 6 minutes, 56 seconds Number of LSP IDs (Tun_Instances) used: 5 Current LSP: Uptime: 6 minutes, 56 seconds Prior LSP: ID: path option 10 [4] Removal Trigger: configuration changed
在这条 MPLS TE tunnel(IOU1 → IOU7 → IOU3 → IOU5 → IOU4)的其他路由器节点上看 MPLS 标签就可以直接 sh mpls forwarding-table:
IOU7#sh mpls forwarding-table Local Outgoing Prefix Bytes Label Outgoing Next Hop Label Label or Tunnel Id Switched interface 7000 3000 1.1.1.1 14 [5] 0 Et0/2 37.1.1.3 IOU3#sh mpls forwarding-table Local Outgoing Prefix Bytes Label Outgoing Next Hop Label Label or Tunnel Id Switched interface 3000 5000 1.1.1.1 14 [5] 0 Et1/0 35.1.1.5 IOU5#sh mpls forwarding-table Local Outgoing Prefix Bytes Label Outgoing Next Hop Label Label or Tunnel Id Switched interface 5000 Pop Label 1.1.1.1 14 [5] 0 Et0/1 45.1.1.4 IOU4#sh mpls forwarding-table Local Outgoing Prefix Bytes Label Outgoing Next Hop Label Label or Tunnel Id Switched interface PS : 因为在 IOU5 上已经 Pop Label 了,所以 IOU4 收到的就是一个纯的 IP 数据包, IOU4 自然也就没有 MPLS 标签了。
测试:
见证奇迹的时刻到了!
IOU1#tra 4.4.4.4 so l 0 Type escape sequence to abort. Tracing the route to 4.4.4.4 VRF info: (vrf in name/id, vrf out name/id) 1 17.1.1.7 [MPLS: Label 7000 Exp 0] 2 msec 1 msec 1 msec 2 37.1.1.3 [MPLS: Label 3000 Exp 0] 2 msec 1 msec 1 msec 3 35.1.1.5 [MPLS: Label 5000 Exp 0] 1 msec 1 msec 1 msec 4 45.1.1.4 1 msec 1 msec 1 msec
现在 IOU1 去往 IOU4 按照预期的路径去走了。
而且在这里需要注意的是,IOU3、IOU5 和 IOU7 上并没有 4.4.4.4 的路由,MPLS TE tunnel 里的数据包转发全靠 MPLS 标签。如下图所示,这些分别是 IOU3、IOU5 和 IOU7 的 FIB 和 RIB(路由表):
IOU3#sh ip cef 4.4.4.4 0.0.0.0/0 no route IOU5#sh ip cef 4.4.4.4 0.0.0.0/0 no route IOU7#sh ip cef 4.4.4.4 0.0.0.0/0 no route
IOU3#sh ip route 4.4.4.4 % Network not in table IOU5#sh ip route 4.4.4.4 % Network not in table IOU7#sh ip route 4.4.4.4 % Network not in table
那现在 IOU4 是怎么回包的呢?
因为在 IOU4 上 4.4.4.4 的路由并没有通过 ISIS 通告出去,只有在 IOU1 上有一条去往 4.4.4.4 的静态路由,所以 IOU2/3/5/6/7 这些路由器上均没有 4.4.4.4 的路由。那么现在在 IOU4 上 traceroute IOU1 自然也是没有什么显示的,因为中间的那些路由器不知道怎么给 IOU4 回 traceroute 的数据包:
IOU4#p 1.1.1.1 so l 0 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds: Packet sent with a source address of 4.4.4.4 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms IOU4#traceroute 1.1.1.1 so l 0 Type escape sequence to abort. Tracing the route to 1.1.1.1 VRF info: (vrf in name/id, vrf out name/id) 1 * * * 2 * * * 3 12.1.1.1 1 msec 1 msec 1 msec
所以我们现在需要在 IOU4 上配置如下命令,让 ISIS 把 4.4.4.4 的路由通告出去:
IOU4(config)#router isis IOU4(config-router)#passive-interface l 0
然后我们再在 IOU4 上 traceroute 一下 IOU1:
IOU4#traceroute 1.1.1.1 so l 0 Type escape sequence to abort. Tracing the route to 1.1.1.1 VRF info: (vrf in name/id, vrf out name/id) 1 34.1.1.3 0 msec 45.1.1.5 1 msec 34.1.1.3 0 msec 2 25.1.1.2 1 msec 37.1.1.7 0 msec 25.1.1.2 1 msec 3 17.1.1.1 1 msec 12.1.1.1 1 msec 17.1.1.1 1 msec
这个时候你就能看到完整的数据包转发路径了。通过上面的 IP 地址,我们大致可以看出 IOU4 前往 IOU1 走了两条路径:一条是 IOU4 → IOU3 → IOU7 → IOU1,另一条是 IOU4 → IOU5 → IOU2 → IOU1。
注意!这个实验我反复做了很多遍,其实 IOU4 去往 IOU1 还可以这么走(没办法,这个实验拓扑中 IOU4 去往 IOU1 可以做负载均衡的路径有点多):
IOU4#traceroute 1.1.1.1 so l 0 Type escape sequence to abort. Tracing the route to 1.1.1.1 VRF info: (vrf in name/id, vrf out name/id) 1 34.1.1.3 0 msec 45.1.1.5 1 msec 34.1.1.3 0 msec 2 25.1.1.2 1 msec 23.1.1.2 1 msec 25.1.1.2 1 msec 3 12.1.1.1 1 msec 1 msec 1 msec
这里还有两条数据包转发路径,一条路径是:IOU4 → IOU3 → IOU2 → IOU1,另一条路径是:IOU4 → IOU5 → IOU2 → IOU1。但总的来说,这些回包都是三跳的,没有四跳。
如下图所示,我们去查 IOU4 上的 FIB 和 RIB,发现确实是有两条负载均衡的路径:
IOU4#sh ip cef 1.1.1.1 1.1.1.1/32 nexthop 34.1.1.3 Ethernet0/0 nexthop 45.1.1.5 Ethernet0/1
IOU4#sh ip ro Codes: L - local, 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, H - NHRP, l - LISP a - application route + - replicated route, % - next hop override Gateway of last resort is not set 1.0.0.0/32 is subnetted, 1 subnets i L2 1.1.1.1 [115/30] via 45.1.1.5, 00:19:22, Ethernet0/1 [115/30] via 34.1.1.3, 00:19:22, Ethernet0/0 2.0.0.0/32 is subnetted, 1 subnets i L2 2.2.2.2 [115/20] via 45.1.1.5, 00:19:22, Ethernet0/1 [115/20] via 34.1.1.3, 00:19:22, Ethernet0/0 3.0.0.0/32 is subnetted, 1 subnets i L2 3.3.3.3 [115/10] via 34.1.1.3, 00:19:22, Ethernet0/0 4.0.0.0/32 is subnetted, 1 subnets C 4.4.4.4 is directly connected, Loopback0 5.0.0.0/32 is subnetted, 1 subnets i L2 5.5.5.5 [115/10] via 45.1.1.5, 00:20:10, Ethernet0/1 6.0.0.0/32 is subnetted, 1 subnets i L2 6.6.6.6 [115/20] via 45.1.1.5, 00:19:12, Ethernet0/1 7.0.0.0/32 is subnetted, 1 subnets i L2 7.7.7.7 [115/20] via 34.1.1.3, 00:19:12, Ethernet0/0 34.0.0.0/8 is variably subnetted, 2 subnets, 2 masks C 34.1.1.0/24 is directly connected, Ethernet0/0 L 34.1.1.4/32 is directly connected, Ethernet0/0 45.0.0.0/8 is variably subnetted, 2 subnets, 2 masks C 45.1.1.0/24 is directly connected, Ethernet0/1 L 45.1.1.4/32 is directly connected, Ethernet0/1
所以,数据包最终并没有从 MPLS TE tunnel 里走(其实也很明显,如果要从 MPLS TE tunnel 里走的话,IOU4 → IOU5 → IOU3 → IOU7 → IOU1,这要有四跳才对,而不是三跳)。综上所述,MPLS TE tunnel 是一个单向的 tunnel,管去不管回。
如果一去一回都要走 MPLS TE tunnel 的话,你需要在 IOU4 上也配置一个 MPLS TE tunnel:
IOU4: int tun 14 ip unnumbered Loopback0 tunnel mode mpls traffic-eng tunnel destination 1.1.1.1 tunnel mpls traffic-eng path-option 10 explicit name A ex ip explicit-path name A enable next-address 45.1.1.5 next-address 35.1.1.3 next-address 37.1.1.7 next-address 17.1.1.1 ip route 1.1.1.1 255.255.255.255 tunnel 14
现在 IOU4 去往 IOU1 也按照预期的路径去走了:
IOU4#traceroute 1.1.1.1 so l 0 Type escape sequence to abort. Tracing the route to 1.1.1.1 VRF info: (vrf in name/id, vrf out name/id) 1 45.1.1.5 [MPLS: Label 5001 Exp 0] 2 msec 1 msec 1 msec 2 35.1.1.3 [MPLS: Label 3001 Exp 0] 2 msec 1 msec 1 msec 3 37.1.1.7 [MPLS: Label 7001 Exp 0] 2 msec 1 msec 1 msec 4 17.1.1.1 2 msec 1 msec 1 msec
我们再来看一下 IOU1 去往 IOU4 的路径:
IOU1#tra 4.4.4.4 so l 0 Type escape sequence to abort. Tracing the route to 4.4.4.4 VRF info: (vrf in name/id, vrf out name/id) 1 17.1.1.7 [MPLS: Label 7000 Exp 0] 2 msec 1 msec 1 msec 2 37.1.1.3 [MPLS: Label 3000 Exp 0] 2 msec 1 msec 1 msec 3 35.1.1.5 [MPLS: Label 5000 Exp 0] 1 msec 1 msec 1 msec 4 45.1.1.4 2 msec 1 msec 1 msec
一来一回都走 MPLS TE tunnel 了,也都是四跳的,没问题。
本文完。如有疑问,欢迎在下方留言;如本文有什么错误,欢迎在下方留言指正,谢谢。
发表评论?