认证培训,h3c认证体系,网络工程师
丰沃创新

MPLS实验总结

  • 发布时间: 2018-5-25 9:35:36

想了很久才决定要写这篇文章。因为我感觉有好多可以说,并且要写出博文有点困难。还是尽力吧,不写出来可能也很快就忘了。

按照我的习惯是先上拓扑:

这就是我的拓扑。

实验参数如下:

IGP用OSPF,实现全网互通。

全部路由器都雇用CEF。

R1用LOOPBACK 1  =11.1.1.1 模拟外网,R5用loopback 1=55.5.5.5 模拟外网。

配置OSPF不作说明。

先介绍配置MPLS 。

R1  和R5建立IGBP关系。

在配置过程中我会故意放入一些不优的配置,以便分析。

R1#ip cef

mpls label range 100 199 这一条命令在实际应用中不要启用。在这里只是为了试验一下这条命令而已。MPLS的LDP协议是自动为我们分配标签的,这条命令的作用在于指定标签的范围。

mpls ldp router-id Loopback1   (记住Loopback1 没有NETWORK进BGP和OSPF的,是为了模拟来自CE的路由)

no mpls ip propagate-ttl forwarded 这条命令也很重要。 下面这一段讲解这一条命令的作用:、

no mpls ip propagate-ttl forwarded  这条命令的意思是,不看IP包的TTL值,因为在PE上,MPLS会copy  IP包中的TTL值填充MPLS包头中的TTL字段。 例如当一个数据包进入MPLS网络时,也就是刚进入PE。 假设IP包中的TTL值=6,这时PE先减去1 ,TTL=6-1=5。然后将TTL填充进MPLS包头的TTL,所以这时MPLS包头的TTL值就是5。 之后在MPLS网络中传输时,因为在MPLS网络中是不看IP包头的,所以IP包头的TTL值不会减少,但是MPLS的TTL值每经过一个路由器就减少1,(当减少为0时丢弃。其实当路由器收到一个TTL=1的包时就要丢弃了。)最后,在连接目的网络的PE上面,MPLS包头的TTL值先减去1 ,之后再copy回去覆盖了IP包头的TTL字段。这样子的话,在外部网络的用户就可以tracert  MPLS网络,得知MPLS网络的结构。 所以我们需要这条no mpls ip propagate-ttl forwarded 命令,不要从IP包中复制TTL值,直接填充MPLS的TTL=255. Traceroute就是利用TTL的技术来实现的,第一次发包TTL是1,包到达下一跳后,TTL变成0,包被丢弃,并响应一个TTL超时。然后,依次递增TTL,依次响应TTL超时,就能发现路径了。如果ISP网络没有禁用TTL,那么客户就可以利用Traceroute探查到ISP的内部路由了,启用如下命令,防止该事情发生。   forwarded是指NO掉CE过来的TTL值,local是指自己的也要NO掉,一般在边界路由器打上forwarded就好,保证自己还是可以traceroute的,默认不打,两个全部NO掉。 MPLS的每个技术解释起来都有一大堆话,或许是我太啰嗦了== 

#router bgp 100

no synchronization

bgp router-id 1.1.1.1

bgp log-neighbor-changes

network 11.1.1.0 mask 255.255.255.0

neighbor 45.1.1.5 remote-as 100

  no auto-summary

!        

!        

interface Serial0/0

ip address 12.1.1.1 255.255.255.0

mpls ldp discovery transport-address interface

这条命令的作用是用接口的地址与邻居建立LDP关系。使用直连接口地址可保证下 一跳可达。建立之后在R2上:R2#show mpls  ldp  discovery Local LDP Identifier:    2.2.2.2:0    Discovery Sources:    Interfaces:        Serial0/0 (ldp): xmit/recv            LDP Id: 11.1.1.1:0; IP addr: 12.1.1.1; no host route        FastEthernet1/0 (ldp): xmit/recv            LDP Id: 3.3.3.3:0; no host route显示no host route 是正常的。

mpls ip 

serial restart-delay 0

!        

R2:

ip cef

no ip domain lookup

mpls label range 200 299

mpls ldp router-id Loopback0

R3:

ip cef

no ip domain lookup

mpls label range 300 399

mpls ldp router-id Loopback0

R4:

ip cef

no ip domain lookup

mpls label range 400 499

mpls ldp router-id Loopback0

R5:

ip cef

mpls label range 500 599

no mpls ip propagate-ttl forwarded

interface Loopback0

ip address 5.5.5.5 255.255.255.0

interface Loopback1

ip address 55.5.5.5 255.255.255.0

ip ospf network point-to-point

!        

interface Serial0/0

ip address 45.1.1.5 255.255.255.0

mpls ldp discovery transport-address interface

mpls ip 

serial restart-delay 0

router ospf 100

router-id 5.5.5.5

log-adjacency-changes

network 5.5.5.5 0.0.0.0 area 0

network 45.1.1.5 0.0.0.0 area 0

!        

router bgp 100

no synchronization

bgp router-id 5.5.5.5

bgp log-neighbor-changes

network 55.5.5.0 mask 255.255.255.0

neighbor 12.1.1.1 remote-as 100

no auto-summary

mpls ldp router-id Loopback1

!        

大体的配置已经帖出来了。

下面讲一个其中的关健点,次末节路由的一个问题。

注意一下我的BPG配置中建立邻居的IP地址,是对方的接口地址。

neighbor 45.1.1.5 remote-as 100

neighbor 12.1.1.1 remote-as 100

学习MPLS最难的是跟踪标签。下面我们就来跟踪一下标签。

R1#show mpls  forwarding-table  Local  Outgoing    Prefix            Bytes tag  Outgoing   Next Hop    tag    tag or VC   or Tunnel Id      switched   interface              100    200         34.1.1.0/24       0          Se0/0      point2point  101    Untagged    2.2.2.2/32        0          Se0/0      point2point  102    202         3.3.3.3/32        0          Se0/0      point2point  103    203         4.4.4.4/32        0          Se0/0      point2point  104    204         5.5.5.5/32        0          Se0/0      point2point  105    Pop tag     23.1.1.0/24       0          Se0/0      point2point  106    205         45.1.1.0/24       0          Se0/0      point2point  R2#show mpls  forwarding-table Local  Outgoing    Prefix            Bytes tag  Outgoing   Next Hop    tag    tag or VC   or Tunnel Id      switched   interface              200    Pop tag     34.1.1.0/24       0          Fa1/0      23.1.1.3     201    Untagged    1.1.1.1/32        0          Se0/0      point2point  202    Untagged    3.3.3.3/32        0          Fa1/0      23.1.1.3     203    302         4.4.4.4/32        0          Fa1/0      23.1.1.3     204    Untagged    5.5.5.5/32        0          Fa1/0      23.1.1.3     205    305         45.1.1.0/24       0          Fa1/0      23.1.1.3     R2#R3#show mpls  for Local  Outgoing    Prefix            Bytes tag  Outgoing   Next Hop    tag    tag or VC   or Tunnel Id      switched   interface              300    201         1.1.1.1/32        0          Fa0/0      23.1.1.2     301    Untagged    2.2.2.2/32        0          Fa0/0      23.1.1.2     302    Untagged    4.4.4.4/32        0          Fa0/1      34.1.1.4     303    403         5.5.5.5/32        77         Fa0/1      34.1.1.4     304    Pop tag     12.1.1.0/24       635        Fa0/0      23.1.1.2     305    Pop tag     45.1.1.0/24       5747       Fa0/1      34.1.1.4    

看到一个奇怪的地方 了吧??为什么是POP,明明只是R3而已,应该不是次末节路由才对。可是这个现象是什么回事?

原因是这样的,我们回过头来看一下,我们的BPG建立邻居是用这样地址来建立邻居的:

R1:neighbor 12.1.1.1 remote-as 100

R5:neighbor 45.1.1.5 remote-as 100

对于R1来说,与45.1.1.5建立了邻居,对于45.1.1.0这个网络,R3就是次末节路由。所以显示是POP。我不知道这样讲清不清楚。简单地说,R3是45.1.1.0这个网络的次末节路由。

那么如何解决这个问题呢?

R1:neighbor 5.5.5.5 remote-as 100

        neighbor 5.5.5.5 update-source lo0

R5:neighbor 1.1.1.1 remote-as 100

      neighbor 1.1.1.1 update-source lo0

接下来分析另一个问题:

R2#show mpls  forwarding-table  Local  Outgoing    Prefix            Bytes tag  Outgoing   Next Hop     tag    tag or VC   or Tunnel Id      switched   interface               200    Pop tag     34.1.1.0/24       0          Fa1/0      23.1.1.3      201    Untagged    1.1.1.1/32        0          Se0/0      point2point   202    Untagged    3.3.3.3/32        0          Fa1/0      23.1.1.3      203    302         4.4.4.4/32        0          Fa1/0      23.1.1.3      204    Untagged    5.5.5.5/32        0          Fa1/0      23.1.1.3      205    305         45.1.1.0/24       0          Fa1/0      23.1.1.3      R2# R4#show mpls  forwarding-table  Local  Outgoing    Prefix            Bytes tag  Outgoing   Next Hop    tag    tag or VC   or Tunnel Id      switched   interface              400    300         1.1.1.1/32        0          Fa1/0      34.1.1.3     401    301         2.2.2.2/32        0          Fa1/0      34.1.1.3     402    Untagged    3.3.3.3/32        0          Fa1/0      34.1.1.3     403    Untagged    5.5.5.5/32        63         Se0/0      point2point  404    Pop tag     23.1.1.0/24       0          Fa1/0      34.1.1.3     405    304         12.1.1.0/24       6416       Fa1/0      34.1.1.3     

注意红色字体的部分。untagged是什么意思?

uptagged跟pop的一个不同的地方是,pop只弹出一层标签,而untagged弹出全部标签。

另外,在这里显示untagged表示,这个路由是自己发现的,而不是由邻居告诉我的,发生一次untagged意味着这个标签的所有标签全部冲突。全部弹出。

看一下R4

R4#show mpls  ldp  bindings   tib entry: 1.1.1.1/32, rev 15        local binding:  tag: 402        remote binding: tsr: 3.3.3.3:0, tag: 300        remote binding: tsr: 55.5.5.5:0, tag: 503  tib entry: 2.2.2.2/32, rev 17        local binding:  tag: 403        remote binding: tsr: 3.3.3.3:0, tag: 301        remote binding: tsr: 55.5.5.5:0, tag: 504  tib entry: 3.3.3.0/24, rev 22        remote binding: tsr: 3.3.3.3:0, tag: imp-null  tib entry: 3.3.3.3/32, rev 19        local binding:  tag: 404        remote binding: tsr: 55.5.5.5:0, tag: 505  tib entry: 4.4.4.0/24, rev 5        local binding:  tag: imp-null  tib entry: 4.4.4.4/32, rev 9        remote binding: tsr: 55.5.5.5:0, tag: 500        remote binding: tsr: 3.3.3.3:0, tag: 303  tib entry: 5.5.5.0/24, rev 8        remote binding: tsr: 55.5.5.5:0, tag: imp-null  tib entry: 5.5.5.5/32, rev 11        local binding:  tag: 400        remote binding: tsr: 3.3.3.3:0, tag: 304

奇怪吧?为什么有一个是24位的,有一个是32位的?而且32位的那一条路由的下一跳是3.3.3.3????

R5:interface Loopback0

ip address 5.5.5.5 255.255.255.0

配置时是24位的。所以MPLS将它发送给R4 。

再看32位的,这是OSPF学习到的路由,OSPF认为LOOPBACK口的都是32位的,所以R4的路由表学习到的是32位的路由,下一跳指向45.1.1.5

R4#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 routeGateway of last resort is not set     34.0.0.0/24 is subnetted, 1 subnetsC       34.1.1.0 is directly connected, FastEthernet1/0     1.0.0.0/24 is subnetted, 1 subnetsO       1.1.1.0 [110/67] via 34.1.1.3, 00:09:54, FastEthernet1/0     2.0.0.0/24 is subnetted, 1 subnetsO       2.2.2.0 [110/3] via 34.1.1.3, 00:09:54, FastEthernet1/0     3.0.0.0/24 is subnetted, 1 subnetsO       3.3.3.0 [110/2] via 34.1.1.3, 00:09:54, FastEthernet1/0     4.0.0.0/24 is subnetted, 1 subnetsC       4.4.4.0 is directly connected, Loopback0     5.0.0.0/32 is subnetted, 1 subnetsO       5.5.5.5 [110/65] via 45.1.1.5, 00:09:54, Serial0/0     23.0.0.0/24 is subnetted, 1 subnetsO       23.1.1.0 [110/2] via 34.1.1.3, 00:09:56, FastEthernet1/0     12.0.0.0/24 is subnetted, 1 subnetsO       12.1.1.0 [110/66] via 34.1.1.3, 00:09:56, FastEthernet1/0     45.0.0.0/24 is subnetted, 1 subnetsC       45.1.1.0 is directly connected, Serial0/0tib entry: 5.5.5.0/24, rev 8        remote binding: tsr: 55.5.5.5:0, tag: imp-null这是R5发送给R4 的,但是R4本身没有这条路由,所以本身没有给 这条路由分配标签。tib entry: 5.5.5.5/32, rev 11        local binding:  tag: 400        remote binding: tsr: 3.3.3.3:0, tag: 304这是R3分发给R4的,因为R4本身也有这条5.5.5.5/32的路由,所以本身也会为这条路由分发标签。

5.5.5.5/32这条路由的下一跳是45.1.1.5,而标签表中:

tib entry: 5.5.5.5/32, rev 11        local binding:  tag: 400        remote binding: tsr: 3.3.3.3:0, tag: 304

下一跳是3.3.3.3,这是矛盾的。所以这一标签不可用。

但是对于5.5.5.5/32这条路由,R4认为R5没有给自己这条路由,所以就untagged  了。

虽然这不影响整个网张的连通,你可以试一下,可以ping通整个网络。

但是显然影响到标签的连续性。MPLS网络最重要的是就标签的连续性问题,标签分配的不合理,生期可能会很麻烦。

所以这个问题是必须解决的。解决方法很简单,就是在每个路由器每个loopback 口启用:

ip ospf network point-to-point