David's profile过山车PhotosBlogLists Tools Help

Blog


    August 17

    Cisco跨域三层VPN OptionB配置指导 - 网络的感觉 go home - 51CTO技术博客-领先的IT技术博客

     

    Cisco跨域三层VPN OptionB配置指导

    1 跨域VPN需求产生的背景

    随着MPLS VPN解决方案的流行,网络的规模也在不断增长,在运营商的不同城域网之间,或是同骨干网之间都存在着非常现实的跨越不同自治域问题,这些都需要一个不同于自治系统内MPLS VPN体系结构,即跨域的MPLS VPN,为了支持服务提供商之间的VPN路由选择信息交换,需要一个新的机制,以便可以穿过提供商间的链路来广播路由前缀和标签信息,跨域VPN的出现正是解决这个问题的。

    目前跨域VPN的技术方案主要有三种:

    1)VRF-TO-VRF(背靠背方式) option A

    2)MP-EBGP (单跳的MP-EBGP方式) option B

    3)MULTIHOP-EBGP(多跳的MP-EBGP方式) option C

    我在这篇文章中首先讲述OptionB的跨域VPN方案,即单跳的MP-EBGP方式,其他两种方式在后续的时间也会发布在我的blog中。

    2 OptionB方式跨域VPN描述

    如上图,整个网络中存在3个AS,AS号分别为200、300和400,其中AS200和AS400之间的VPN有互通需求。

    在这个网络中R2、R3和R4为3个AS的ASBR,那么我们在ASBR之间运行MP-EBGP协议,MP-EBGP将自己AS内的所有的VPN信息传递给另外一个AS,传递的是私网路由和标签信息,由于MP-EBGP在传递路由时,是要改变路由的下一跳,根据标签分配的原则,当一个FEC的下一跳被改变时,必须在本地更换标签,因此ASBR在收到AS内的VPN路由信息,再向外发布时,必须给这些VPN路由信息重新分配标签,VPN路由信息伴随着新的标签被发布出去,而在ASBR本地,新旧标签形成一个标签的交换操作,这也是BGPnext-hop-self的来历之一。

    对端的ASBR收到从MP-EBGP来的VPN路由信息后,在本地保存,在继续向自己AS内的PE设备扩散,当这个ASBR向域内的MP-IBGP邻居发布路由时,它可以选择不改变路由的下一跳,或是将路由的下一跳改为自己,如果改变了路由的下一跳,同上面的标签分配原则,也需要为这些VPN路由重新分配标签,在本地形成标签的交换操作。

    3 VPN路由信息扩散的关键点

    改变下一跳

    本文的跨域VPN采用的是改变下一跳的设计,即ASBR在于IBGP对等体建立邻居时,将下一跳指向自己,也就是说ASBR向IBGP邻居发送VPN路由时,会改变VPN路由的下一跳指向ASBR,这样的话在ASBR之间不需要运行额外的如LDP之类的信令协议,由MBGP触发标签即可。反之,如果不改变下一跳,那么在ASBR之间是需要运行LDP之类的信令协议的,个人认为这样做虽然可以实现跨域VPN的互通,但是不是很标准,所以在本文中均是采用改变下一跳的设计来发布VPN路由信息的。

    VPN路由信息的过滤

    报文转发时,需要ASBR都要对VPN的LSP做一次交换。还有一个问题需要注意的是,这种解决方案需要在ASBR上接收本AS内和AS外传过来的所有VPN路由,然后在把VPN给扩散出去,但是MPLS VPN的特性结构中要求,只有一个PE上有VPN匹配一条VPN路由时,这条VPN路由才会被保存下来,因此对于上述ASBR上需要保存VPN路由的需求必须做特殊的配置(因为ASBR上可能根本就没有配置VPN),让ASBR把收到的VPN路由全部的保存下来,而不管,本地是否有和它匹配的VPN。这样的目的可以通过关闭BGP默认的route-target过滤来实现,也可以配置专门的策略来实现对VPN路由信息的控制。为了省事起见,我这里采用直接关闭BGP默认的route-target过滤来实现。

    由于这种方案需要在ASBR上保存所有的VPN路由,因此这本身就是对路由器提出了很高的要求,使ASBR更容易成为故障点。不过只要VPN的路由数量不是很多,这种方案不失为一种配置简单且实用的方案。

    4 数据设计

    由于一般的跨域VPN配置示例都是两个AS,这里我故意调整成了三个AS,其实也没什么变化,就是多配置一些EBGP邻居而已。

    Loopback地址:202.1.1.X/32,X=1、2、3、4、5、6,即路由器序号;

    接口地址:80.X.Y.Z/24,X/Y=路由器序号,Z=1、2,路由器序号小的为1,大的为2;

    IGP:PE-P-PE之间部署OSPF和LDP,ASBR之间不起用任何IGP,只建立MEBGP邻居;

    AS:R1和R2AS号为200,R3的AS号为300,R4和R6的AS号为400;

    Vrf:R1上配置两个vrf

    Vrf20 RD=100:20 RT=100:20 路由为10.0.30.0/24

    Vrf30 RD=100:30 RT=100:30 路由为10.0.30.0/24

    配置为不同vpn相同的路由是客观验证一下vpn路由地址重叠的情况。

    R6上配置两个vrf

    Vrf20 RD=100:20 RT=100:20 路由为60.0.20.0/24

    Vrf30 RD=100:30 RT=100:30 路由为60.0.30.0/24

    验证:从R6上ping R1上的vrf地址,在R4-R5之间的链路上抓包。

    分析报文的标签嵌套情况,正常情况应该是:

    R1-R6方向的报文应该是两层标签,

    R6-R1方向的报文应该是一层标签。

    5 详细配置

    为了节约版本,只罗列出6台路由器的相关配置,其他无关配置均不贴出来。

    [R1]

    R1#

    R1#show run

    !

    version 12.4

    !

    hostname R1

    !

    ip cef

    !

    !

    ip vrf vrf10

    rd 100:10

    route-target export 100:10

    route-target import 100:10

    !

    ip vrf vrf20

    rd 100:20

    route-target export 100:20

    route-target import 100:20

    !

    ip vrf vrf30

    rd 100:30

    route-target export 100:30

    route-target import 100:30

    !

    interface Loopback0

    ip address 202.1.1.1 255.255.255.255

    !

    interface Ethernet4/0

    ip address 80.1.2.1 255.255.255.0

    duplex full

    mpls ip

    !

    interface Ethernet4/6

    ip vrf forwarding vrf20

    ip address 10.0.30.1 255.255.255.0

    duplex half

    !

    interface Ethernet4/7

    ip vrf forwarding vrf30

    ip address 10.0.30.1 255.255.255.0

    duplex half

    !

    router ospf 1

    log-adjacency-changes

    network 80.1.2.0 0.0.0.255 area 0

    network 202.1.1.1 0.0.0.0 area 0

    !

    router bgp 200

    no synchronization

    bgp log-neighbor-changes

    neighbor 202.1.1.2 remote-as 200

    neighbor 202.1.1.2 update-source Loopback0

    no auto-summary

    !

    address-family vpnv4

    neighbor 202.1.1.2 activate

    neighbor 202.1.1.2 send-community extended

    exit-address-family

    !

    address-family ipv4 vrf vrf30

    redistribute connected

    no synchronization

    exit-address-family

    !

    address-family ipv4 vrf vrf20

    redistribute connected

    no synchronization

    exit-address-family

    !

    address-family ipv4 vrf vrf10

    no synchronization

    exit-address-family

    !

    end

    [R2]

    R2#show run

    !

    version 12.4

    !

    hostname R2

    !

    ip cef

    !

    interface Loopback0

    ip address 202.1.1.2 255.255.255.255

    !

    interface Ethernet4/0

    ip address 80.1.2.2 255.255.255.0

    duplex full

    mpls ip

    !

    interface Ethernet4/1

    ip address 80.2.3.1 255.255.255.0

    duplex full

    !

    router ospf 1

    log-adjacency-changes

    network 80.1.2.0 0.0.0.255 area 0

    network 202.1.1.2 0.0.0.0 area 0

    !

    router bgp 200

    no synchronization

    no bgp default route-target filter

    bgp log-neighbor-changes

    neighbor 80.2.3.2 remote-as 300

    neighbor 202.1.1.1 remote-as 200

    neighbor 202.1.1.1 update-source Loopback0

    no auto-summary

    !

    address-family vpnv4

    neighbor 80.2.3.2 activate

    neighbor 80.2.3.2 send-community extended

    neighbor 202.1.1.1 activate

    neighbor 202.1.1.1 send-community extended

    neighbor 202.1.1.1 next-hop-self

    exit-address-family

    !

    end

    [R3]

    R3#show run

    !

    version 12.4

    !

    hostname R3

    !

    ip cef

    !

    no mpls ip

    !

    interface Loopback0

    ip address 202.1.1.3 255.255.255.255

    !

    interface Ethernet4/1

    ip address 80.2.3.2 255.255.255.0

    duplex full

    !

    interface Ethernet4/2

    ip address 80.3.4.1 255.255.255.0

    duplex half

    !

    router bgp 300

    no synchronization

    no bgp default route-target filter

    bgp log-neighbor-changes

    neighbor 80.2.3.1 remote-as 200

    neighbor 80.3.4.2 remote-as 400

    no auto-summary

    !

    address-family vpnv4

    neighbor 80.2.3.1 activate

    neighbor 80.2.3.1 send-community extended

    neighbor 80.3.4.2 activate

    neighbor 80.3.4.2 send-community extended

    exit-address-family

    !

    end

    [R4]

    R4#show run

    !

    version 12.4

    !

    hostname R4

    !

    ip cef

    !

    interface Loopback0

    ip address 202.1.1.4 255.255.255.255

    !

    interface Ethernet4/2

    ip address 80.3.4.2 255.255.255.0

    duplex half

    !

    interface Ethernet4/3

    ip address 80.4.5.1 255.255.255.0

    duplex half

    mpls ip

    !

    router ospf 1

    log-adjacency-changes

    network 80.3.4.0 0.0.0.255 area 0

    network 80.4.5.0 0.0.0.255 area 0

    network 202.1.1.4 0.0.0.0 area 0

    !

    router bgp 400

    no synchronization

    no bgp default route-target filter

    bgp log-neighbor-changes

    neighbor 80.3.4.1 remote-as 300

    neighbor 202.1.1.6 remote-as 400

    neighbor 202.1.1.6 update-source Loopback0

    no auto-summary

    !

    address-family vpnv4

    neighbor 80.3.4.1 activate

    neighbor 80.3.4.1 send-community extended

    neighbor 202.1.1.6 activate

    neighbor 202.1.1.6 send-community extended

    neighbor 202.1.1.6 next-hop-self

    exit-address-family

    !

    end

    [R5]

    R5#show run

    !

    version 12.4

    !

    hostname R5

    !

    ip cef

    !

    interface Loopback0

    ip address 202.1.1.5 255.255.255.255

    !

    interface Ethernet4/0

    ip address 80.5.6.1 255.255.255.0

    duplex half

    mpls ip

    !

    interface Ethernet4/3

    ip address 80.4.5.2 255.255.255.0

    duplex half

    mpls ip

    !

    router ospf 1

    log-adjacency-changes

    network 80.4.5.0 0.0.0.255 area 0

    network 80.5.6.0 0.0.0.255 area 0

    network 202.1.1.5 0.0.0.0 area 0

    !

    end

    [R6]

    R6#show run

    !

    version 12.4

    !

    hostname R6

    !

    ip cef

    !

    ip vrf vrf10

    rd 100:10

    route-target export 100:10

    route-target import 100:10

    !

    ip vrf vrf20

    rd 100:20

    route-target export 100:20

    route-target import 100:20

    !

    ip vrf vrf30

    rd 100:30

    route-target export 100:30

    route-target import 100:30

    !

    interface Loopback0

    ip address 202.1.1.6 255.255.255.255

    !

    interface Ethernet4/0

    ip address 80.5.6.2 255.255.255.0

    duplex half

    mpls ip

    !

    interface Ethernet4/6

    ip vrf forwarding vrf20

    ip address 60.0.20.1 255.255.255.0

    duplex half

    !

    interface Ethernet4/7

    ip vrf forwarding vrf30

    ip address 60.0.30.1 255.255.255.0

    duplex half

    !

    router ospf 1

    log-adjacency-changes

    network 80.5.6.0 0.0.0.255 area 0

    network 202.1.1.6 0.0.0.0 area 0

    !

    router bgp 400

    no synchronization

    bgp log-neighbor-changes

    neighbor 202.1.1.4 remote-as 400

    neighbor 202.1.1.4 update-source Loopback0

    no auto-summary

    !

    address-family vpnv4

    neighbor 202.1.1.4 activate

    neighbor 202.1.1.4 send-community extended

    exit-address-family

    !

    address-family ipv4 vrf vrf30

    redistribute connected

    no synchronization

    exit-address-family

    !

    address-family ipv4 vrf vrf20

    redistribute connected

    no synchronization

    exit-address-family

    !

    address-family ipv4 vrf vrf10

    redistribute connected

    no synchronization

    exit-address-family

    !

    end

    6 调试信息

    查看各个BGP邻居上的私网路由和标签信息

    [R1]

    R1#show bgp vpnv4 uni all

    BGP table version is 15, local router ID is 202.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

    NetworkNext Hop Metric LocPrf Weight Path

    Route Distinguisher: 100:20 (default for vrf vrf20)

    *> 10.0.30.0/24 0.0.0.0 0 32768 ?

    *>i60.0.20.0/24 202.1.1.2 0 100 0 300 400 ?

    Route Distinguisher: 100:30 (default for vrf vrf30)

    *> 10.0.30.0/24 0.0.0.0 0 32768 ?

    *>i60.0.30.0/24 202.1.1.2 0 100 0 300 400 ?

    R1#show bgp vpnv4 uni all labels

    NetworkNext Hop In label/Out label

    Route Distinguisher: 100:20 (vrf20)

    10.0.30.0/24 0.0.0.0 17/aggregate(vrf20)

    60.0.20.0/24 202.1.1.2 nolabel/23

    Route Distinguisher: 100:30 (vrf30)

    10.0.30.0/24 0.0.0.0 18/aggregate(vrf30)

    60.0.30.0/24 202.1.1.2 nolabel/22

    [R2]

    R2#show bgp vpnv4 uni all

    BGP table version is 9, local router ID is 202.1.1.2

    Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

    r RIB-failure, S Stale

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

    NetworkNext Hop Metric LocPrf Weight Path

    Route Distinguisher: 100:20

    *>i10.0.30.0/24 202.1.1.1 0 100 0 ?

    *> 60.0.20.0/24 80.2.3.2 0 300 400 ?

    Route Distinguisher: 100:30

    *>i10.0.30.0/24 202.1.1.1 0 100 0 ?

    *> 60.0.30.0/24 80.2.3.2 0 300 400 ?

    R2#show bgp vpnv4 uni all labels

    NetworkNext Hop In label/Out label

    Route Distinguisher: 100:20

    10.0.30.0/24 202.1.1.1 18/17

    60.0.20.0/24 80.2.3.2 23/20

    Route Distinguisher: 100:30

    10.0.30.0/24 202.1.1.1 19/18

    60.0.30.0/24 80.2.3.2 22/21

    [R3]

    R3#show bgp vpnv4 uni all

    BGP table version is 5, local router ID is 202.1.1.3

    Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

    r RIB-failure, S Stale

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

    NetworkNext Hop Metric LocPrf Weight Path

    Route Distinguisher: 100:20

    *> 10.0.30.0/24 80.2.3.1 0 200 ?

    *> 60.0.20.0/24 80.3.4.2 0 400 ?

    Route Distinguisher: 100:30

    *> 10.0.30.0/24 80.2.3.1 0 200 ?

    *> 60.0.30.0/24 80.3.4.2 0 400 ?

    R3#show bgp vpnv4 uni all labels

    NetworkNext Hop In label/Out label

    Route Distinguisher: 100:20

    10.0.30.0/24 80.2.3.1 19/18

    60.0.20.0/24 80.3.4.2 20/22

    Route Distinguisher: 100:30

    10.0.30.0/24 80.2.3.1 18/19

    60.0.30.0/24 80.3.4.2 21/23

    [R4]

    R4#show bgp vpnv4 uni all

    BGP table version is 9, local router ID is 202.1.1.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

    NetworkNext Hop Metric LocPrf Weight Path

    Route Distinguisher: 100:20

    *> 10.0.30.0/24 80.3.4.1 0 300 200 ?

    *>i60.0.20.0/24 202.1.1.6 0 100 0 ?

    Route Distinguisher: 100:30

    *> 10.0.30.0/24 80.3.4.1 0 300 200 ?

    *>i60.0.30.0/24 202.1.1.6 0 100 0 ?

    R4#show bgp vpnv4 uni all labels

    NetworkNext Hop In label/Out label

    Route Distinguisher: 100:20

    10.0.30.0/24 80.3.4.1 25/19

    60.0.20.0/24 202.1.1.6 22/20

    Route Distinguisher: 100:30

    10.0.30.0/24 80.3.4.1 24/18

    60.0.30.0/24 202.1.1.6 23/21

    [R6]

    R6#show bgp vpnv4 uni all

    BGP table version is 15, local router ID is 202.1.1.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

    NetworkNext Hop Metric LocPrf Weight Path

    Route Distinguisher: 100:20 (default for vrf vrf20)

    *>i10.0.30.0/24 202.1.1.4 0 100 0 300 200 ?

    *> 60.0.20.0/24 0.0.0.0 0 32768 ?

    Route Distinguisher: 100:30 (default for vrf vrf30)

    *>i10.0.30.0/24 202.1.1.4 0 100 0 300 200 ?

    *> 60.0.30.0/24 0.0.0.0 0 32768 ?

    R6#show bgp vpnv4 uni all labels

    NetworkNext Hop In label/Out label

    Route Distinguisher: 100:20 (vrf20)

    10.0.30.0/24 202.1.1.4 nolabel/25

    60.0.20.0/24 0.0.0.0 20/aggregate(vrf20)

    Route Distinguisher: 100:30 (vrf30)

    10.0.30.0/24 202.1.1.4 nolabel/24

    60.0.30.0/24 0.0.0.0 21/aggregate(vrf30)

    从上面的标签信息可以明显的看出MBGP的VPN路由触发的标签情况,即在跨域的时候报文中是靠这些标签指导转发的,也从侧面印证了前文中[改变下一跳]中所描述的VPN路由触发标签分配的情况。

    查看实际的mpls标签转发表

    [R1]

    R1#show mpls forwarding-table

    Local Outgoing Prefix Bytes tag Outgoing Next Hop

    tag tag or VC or Tunnel Id switched interface

    16 Pop tag 202.1.1.2/32 0Et4/0 80.1.2.2

    17 Aggregate 10.0.30.0/24[V] 0

    18 Aggregate 10.0.30.0/24[V] 0

    [R2]

    R2#show mpls forwarding-table

    Local Outgoing Prefix Bytes tag Outgoing Next Hop

    tag tag or VC or Tunnel Id switched interface

    16 Pop tag 202.1.1.1/32 0Et4/0 80.1.2.1

    17 Pop tag 80.2.3.2/32 0Et4/1 80.2.3.2

    18 17 100:20:10.0.30.0/24 \ 0Et4/0 80.1.2.1

    19 18 100:30:10.0.30.0/24 \ 0Et4/0 80.1.2.1

    22 21 100:30:60.0.30.0/24 \ 0Et4/1 80.2.3.2

    23 20 100:20:60.0.20.0/24 \ 0Et4/1 80.2.3.2

    [R3]

    R3#show mpls forwarding-table

    Local Outgoing Prefix Bytes tag Outgoing Next Hop

    tag tag or VC or Tunnel Id switched interface

    16 Pop tag 80.2.3.1/32 0Et4/1 80.2.3.1

    17 Pop tag 80.3.4.2/32 0Et4/2 80.3.4.2

    18 19 100:30:10.0.30.0/24 \ 0Et4/1 80.2.3.1

    19 18 100:20:10.0.30.0/24 \ 0Et4/1 80.2.3.1

    20 22 100:20:60.0.20.0/24 \ 0Et4/2 80.3.4.2

    21 23 100:30:60.0.30.0/24 \ 0Et4/2 80.3.4.2

    [R4]

    R4#show mpls forwarding-table

    Local Outgoing Prefix Bytes tag Outgoing Next Hop

    tag tag or VC or Tunnel Id switched interface

    16 Pop tag 80.3.4.1/32 0Et4/2 80.3.4.1

    17 Pop tag 80.5.6.0/24 0Et4/3 80.4.5.2

    18 Pop tag 202.1.1.5/32 0Et4/3 80.4.5.2

    19 18 202.1.1.6/32 0Et4/3 80.4.5.2

    22 18 100:20:60.0.20.0/24 \ 0Et4/3 80.4.5.2

    23 18 100:30:60.0.30.0/24 \ 0Et4/3 80.4.5.2

    24 18 100:30:10.0.30.0/24 \ 0Et4/2 80.3.4.1

    25 19 100:20:10.0.30.0/24 \ 0Et4/2 80.3.4.1

    [R5]

    R5#show mpls forwarding-table

    Local Outgoing Prefix Bytes tag Outgoing Next Hop

    tag tag or VC or Tunnel Id switched interface

    16 Pop tag 80.3.4.0/24 0Et4/3 80.4.5.1

    17 Pop tag 202.1.1.4/32 73 Et4/3 80.4.5.1

    18 Pop tag 202.1.1.6/32 8236 Et4/0 80.5.6.2

    [R6]

    R6#show mpls forwarding-table

    Local Outgoing Prefix Bytes tag Outgoing Next Hop

    tag tag or VC or Tunnel Id switched interface

    16 Pop tag 80.4.5.0/24 0Et4/0 80.5.6.1

    17 16 80.3.4.0/24 0Et4/0 80.5.6.1

    18 17 202.1.1.4/32 0Et4/0 80.5.6.1

    19 Pop tag 202.1.1.5/32 0Et4/0 80.5.6.1

    20 Aggregate 60.0.20.0/24[V] 0

    21 Aggregate 60.0.30.0/24[V] 0

    从上面的信息我们看出,在ASBR上能够明显的看到VPNV4的路由信息对应的标签转发项。

    公网标签和私网标签

    前面提到从R6上ping R1上的vrf地址,在R4-R5之间的链路上抓包。然后分析报文的标签嵌套情况,正常情况应该是:

    R1-R6方向的报文应该是两层标签,公网标签+私网标签;

    R6-R1方向的报文应该是一层标签,公网标签被弹出,只剩余私网标签。

    可以通过下面的抓包图片进行验证:

    R1-R6方向的两层标签

    R6-R1方向的一层标签

    根据朋友的提醒,在此增加从R6到R1的私网路由trace信息,可以清楚的看到沿途标签信息的变化:

    R6#traceroute vrf vrf30
    Protocol [ip]:   
    Target IP address: 10.0.30.1 
    Source address: 60.0.30.1    
    Numeric display [n]:   
    Resolve AS number in (G)lobal table, (V)RF or(N)one [G]:   
    Timeout in seconds [3]:
    Probe count [3]: 
    Minimum Time to Live [1]:    
    Maximum Time to Live [30]:   
    Port Number [33434]:   
    Loose, Strict, Record, Timestamp, Verbose[none]:
    Type escape sequence to abort.
    Tracing the route to 10.0.30.1

      1 80.5.6.1 [MPLS: Labels 17/21 Exp 0] 180 msec 224 msec 144 msec
      2 80.4.5.1 [MPLS: Label 21 Exp 0] 156 msec 208 msec 192 msec   
      3 80.3.4.1 [MPLS: Label 18 Exp 0] 180 msec 272 msec 236 msec   
      4 80.2.3.1 [MPLS: Label 19 Exp 0] 164 msec 192 msec 364 msec   
      5 10.0.30.1 220 msec 196 msec *

    Cisco跨域三层VPN OptionB配置指导 - 网络的感觉     go home - 51CTO技术博客-领先的IT技术博客

    Cisco跨域三层VPN OptionC配置指导 - 网络的感觉 go home - 51CTO技术博客-领先的IT技术博客

     

    Cisco跨域三层VPN OptionC配置指导

    1 OptionC方式跨域VPN的理解

    之前,我写了一篇OptionB的文档,并提供了相应的配置,对于该文档中相应的内容,我在这里就不再罗嗦了,本文开始对OptionC方式的跨域VPN做分析。

    在OptionB方式中,VPN的路由信息是通过自治系统之间的ASBR来保存和扩散的,当VPN路由比较多的时候,会对ASBR产生巨大的压力;如果经过多个自治系统,每个ASBR上都会维护大量相同的VPN路由,由于这些ASBR一般都承担着公网IP转发的任务,这样对设备的要求就更高了。从另一个方面来看,OptionB方式采用的是一种中继的方式,通过ASBR把VPN路由信息向其他自治系统扩散,这也把这些中间设备强加上必须要支持VPN功能的要求,虽然对于设备而言,这是必须的,但是这样的实现方式个人觉得并不完全符合三层VPN的思想,按照正常的理解,除了接入CE的PE之外,其他设备是不应该看到VPN信息的,这也是OptionC方式所解决的问题。

    OptionC方式的思想就是在跨域的情况下,PE之间仍然可以像域内那样,在PE和PE之间建立直接的MEBGP邻居,交换VPNV4路由信息,这样就不需要中间设备再保存、维护和扩散VPN路由信息。这里需要从两个方面去考虑:信令和转发。在信令层面上,实现跨域MEBGP邻居的建立,并交换VPN路由信息并不是一件困难的事情,只要公网路由可达,建立起邻居,私网的VPN路由信息就可以很轻松的发给对端邻居了。但是,在转发层面上,还有一个最重要的问题需要解决,那就是如何在跨域的情况下建立一条PE到PE的VPN LSP,否则,即便有了VPN路由信息,到了公网部分,根本无法识别数据的私网标签,转发层面上还是不通的。

    这里,需要提到标签IPv4路由,在RFC3107即[Carrying Label Information in BGP-4]中有定义。这里在ASBR之间传递的就不是普通的IP路由信息了,而是携带了标签的公网路由信息,这样,就会在公网上形成一个由BGP触发的公网LSP,在公网上也是靠标签交换就数据传送到目的地,而公网上无法识别的私网标签就可以被封装在内层作为内层标签被转发了。有兴趣的朋友可以看一下RFC3107中所定义的应用场景和具体的update的消息格式,该RFC内容不长,这里不作过多的阐述,下面列举一下普通的update和支持标签IPv4路由信息的update的格式即可。

    普通update消息

    标签ipv4格式的update消息

    2 OptionC方式的数据转发

    仍然沿用跟OptionB方式中大致类似的网络结构,如上图。

    以从R6上的vrf30 ping R1上的vrf30为例,即ping vrf vrf30 10.0.30.1 source 60.0.30.1,从R6àR1方向,IP数据会首先被封装上VPNv4目的路由对应的标签,接着会被封装上标签IPv4路由信息对应的标签,最后才会被封装上LDP标签,其中LDP标签完成LDP域的标签交换,随后通过标签IPv4路由的标签完成EBGP域的标签交换,然后再进入对方自治系统的LDP域,最后通过私网标签完成VPN域的标签交换,达到目的地。也就是说在整个数据传输过程中,最多的时候数据会被封装三层标签,即LDP | EBGP标签 | 私网标签。在上面的拓扑中,能够看到三层标签的位置为R6到R5的出方向,理论上LDP域中都应该是三层标签头,但是由于存在空标签的缘故,有的位置只能显示的看到两层标签。在R5和R6之间抓包如下,可以清楚的看到三层标签:

    在R6上显示各种标签信息,可以明显的看出图中的标签16为LDP标签,标签29为EBGP公网标签,标签18为私网路由标签,显示信息如下:

    私网路由标签

    R6#show bgp vpnv4 unicast all labels

    Network Next Hop In label/Out label

    Route Distinguisher: 100:20 (vrf20)

    10.0.30.0/24 202.1.1.1 nolabel/17

    60.0.20.0/24 0.0.0.0 19/aggregate(vrf20)

    Route Distinguisher: 100:30 (vrf30)

    10.0.30.0/24 202.1.1.1 nolabel/18

    60.0.30.0/24 0.0.0.0 20/aggregate(vrf30)

    公网EBGP标签

    R6#show bgp ipv4 unicast labels

    Network Next Hop In Label/Out Label

    80.1.2.0/24 202.1.1.4 nolabel/25

    80.2.3.0/24 202.1.1.4 nolabel/26

    80.2.3.2/32 202.1.1.4 nolabel/28

    80.5.6.0/24 0.0.0.0 imp-null/nolabel

    202.1.1.1/32 202.1.1.4 nolabel/29

    202.1.1.2/32 202.1.1.4 nolabel/27

    202.1.1.6/32 0.0.0.0 imp-null/nolabel

    LDP标签

    R6#show mpls forwarding-table

    Local Outgoing Prefix Bytes tag Outgoing Next Hop

    tag tag or VC or Tunnel Id switched interface

    16 Pop tag 80.4.5.0/24 0 Et4/0 80.5.6.1

    17 16 202.1.1.4/32 0 Et4/0 80.5.6.1

    18 Pop tag 202.1.1.5/32 0 Et4/0      80.5.6.1

    19 Aggregate 60.0.20.0/24[V] 0

    20 Aggregate 60.0.30.0/24[V] 0

    从上面的显示信息也可以清楚的看出路由的迭代关系与标签之间的关联,即到vrf30 10.0.30.0/24的下一跳为202.1.1.1,到202.1.1.1的下一跳为202.1.1.4,通过路由迭代形成一个三层标签16 | 29 | 18 ,与抓包的数据完全一致。

    3 OptionC方式的关键点

    BGP4的扩展

    通过RFC3107对BGP4进行扩展,使得BGP发布路由信息时可以支持标签IPv4路由信息,所以在配置的时候也要配置支持标签IPv4路由信息的能力,如果不进行配置,那么只是普通的BGP,发布的路由信息也是普通的IPv4路由。

    路由策略的创建:

    在ASBR上应用路由策略,对于从本AS的PE接收的路由,在向对端ASBR发布时,分配MPLS 标签。对于向本AS的PE 发布的路由,如果是带标签的IPv4路由,为其重新分配MPLS 标签。对IPv4 路由分配MPLS标签是通过路由策略控制的,只对满足某些条件的路由分配标签,其它路由还是普通IPv4 路由。缺省情况下,IPv4 路由不带MPLS 标签。

    4 数据设计

    由于一般的跨域VPN配置示例都是两个AS,这里我故意调整成了三个AS,其实也没什么变化,就是多配置一些EBGP邻居而已。

    Loopback地址:202.1.1.X/32,X=1、2、3、4、5、6,即路由器序号;

    接口地址:80.X.Y.Z/24,X/Y=路由器序号,Z=1、2,路由器序号小的为1,大的为2;

    IGP:PE-P-PE之间部署OSPF和LDP,ASBR之间不起用任何IGP,只建立MEBGP邻居;

    AS:R1和R2AS号为200,R3的AS号为300,R4和R6的AS号为400;

    Vrf:R1上配置两个vrf

    Vrf20 RD=100:20 RT=100:20 路由为10.0.30.0/24

    Vrf30 RD=100:30 RT=100:30 路由为10.0.30.0/24

    配置为不同vpn相同的路由是客观验证一下vpn路由地址重叠的情况。

    R6上配置两个vrf

    Vrf20 RD=100:20 RT=100:20 路由为60.0.20.0/24

    Vrf30 RD=100:30 RT=100:30 路由为60.0.30.0/24

    5 详细配置

    为了节约版本,只罗列出6台路由器的相关配置,其他无关配置均不贴出来。具体的配置和显示信息可以参看最后附件中的文档。

    [R1]

    R1#show run

    !

    version 12.4

    !

    hostname R1

    !

    ip cef

    !

    ip vrf vrf10

    rd 100:10

    route-target export 100:10

    route-target import 100:10

    !

    ip vrf vrf20

    rd 100:20

    route-target export 100:20

    route-target import 100:20

    !

    ip vrf vrf30

    rd 100:30

    route-target export 100:30

    route-target import 100:30

    !

    interface Loopback0

    ip address 202.1.1.1 255.255.255.255

    !

    interface Ethernet4/0

    ip address 80.1.2.1 255.255.255.0

    duplex full

    mpls ip

    !

    interface Ethernet4/6

    ip vrf forwarding vrf20

    ip address 10.0.30.1 255.255.255.0

    duplex half

    !

    interface Ethernet4/7

    ip vrf forwarding vrf30

    ip address 10.0.30.1 255.255.255.0

    duplex half

    !

    router ospf 1

    log-adjacency-changes

    network 80.1.2.0 0.0.0.255 area 0

    network 202.1.1.1 0.0.0.0 area 0

    !

    router bgp 200

    bgp log-neighbor-changes

    neighbor 202.1.1.2 remote-as 200

    neighbor 202.1.1.2 update-source Loopback0

    neighbor 202.1.1.6 remote-as 400

    neighbor 202.1.1.6 ebgp-multihop 10

    neighbor 202.1.1.6 update-source Loopback0

    !

    address-family ipv4

    redistribute connected

    neighbor 202.1.1.2 activate

    neighbor 202.1.1.2 send-label

    no neighbor 202.1.1.6 activate

    no auto-summary

    no synchronization

    exit-address-family

    !

    address-family vpnv4

    neighbor 202.1.1.6 activate

    neighbor 202.1.1.6 send-community extended

    exit-address-family

    !

    address-family ipv4 vrf vrf30

    redistribute connected

    no synchronization

    exit-address-family

    !

    address-family ipv4 vrf vrf20

    redistribute connected

    no synchronization

    exit-address-family

    !

    address-family ipv4 vrf vrf10

    no synchronization

    exit-address-family

    !

    end

    [R2]

    R2#show run

    !

    version 12.4

    !

    hostname R2

    !

    ip cef

    !

    interface Loopback0

    ip address 202.1.1.2 255.255.255.255

    !

    interface Ethernet4/0

    ip address 80.1.2.2 255.255.255.0

    duplex full

    mpls ip

    !

    interface Ethernet4/1

    ip address 80.2.3.1 255.255.255.0

    duplex full

    !

    router ospf 1

    log-adjacency-changes

    network 80.1.2.0 0.0.0.255 area 0

    network 202.1.1.2 0.0.0.0 area 0

    !

    router bgp 200

    no synchronization

    no bgp default route-target filter

    bgp log-neighbor-changes

    redistribute connected

    redistribute ospf 1

    neighbor 80.2.3.2 remote-as 300

    neighbor 80.2.3.2 route-map atol out

    neighbor 80.2.3.2 send-label

    neighbor 202.1.1.1 remote-as 200

    neighbor 202.1.1.1 update-source Loopback0

    neighbor 202.1.1.1 next-hop-self

    neighbor 202.1.1.1 route-map ltol out

    neighbor 202.1.1.1 send-label

    no auto-summary

    !

    route-map atol permit 10

    set mpls-label

    !

    route-map ltol permit 10

    match mpls-label

    set mpls-label

    end

    [R3]

    R3#show run

    !

    version 12.4

    !

    hostname R3

    !

    ip cef

    !

    interface Loopback0

    ip address 202.1.1.3 255.255.255.255

    !

    interface Ethernet4/1

    ip address 80.2.3.2 255.255.255.0

    duplex full

    !

    interface Ethernet4/2

    ip address 80.3.4.1 255.255.255.0

    duplex half

    !

    router bgp 300

    no synchronization

    no bgp default route-target filter

    bgp log-neighbor-changes

    neighbor 80.2.3.1 remote-as 200

    neighbor 80.2.3.1 route-map atol out

    neighbor 80.2.3.1 send-label

    neighbor 80.3.4.2 remote-as 400

    neighbor 80.3.4.2 route-map atol out

    neighbor 80.3.4.2 send-label

    no auto-summary

    !

    route-map atol permit 10

    set mpls-label

    !

    end

    [R4]

    R4#show run

    !

    version 12.4

    !

    hostname R4

    !

    ip cef

    !

    interface Loopback0

    ip address 202.1.1.4 255.255.255.255

    !

    interface Ethernet4/2

    ip address 80.3.4.2 255.255.255.0

    duplex half

    !

    interface Ethernet4/3

    ip address 80.4.5.1 255.255.255.0

    duplex half

    mpls ip

    !

    router ospf 1

    log-adjacency-changes

    network 80.4.5.0 0.0.0.255 area 0

    network 202.1.1.4 0.0.0.0 area 0

    !

    router bgp 400

    no synchronization

    no bgp default route-target filter

    bgp log-neighbor-changes

    redistribute connected

    redistribute ospf 1

    neighbor 80.3.4.1 remote-as 300

    neighbor 80.3.4.1 route-map atol out

    neighbor 80.3.4.1 send-label

    neighbor 202.1.1.6 remote-as 400

    neighbor 202.1.1.6 update-source Loopback0

    neighbor 202.1.1.6 next-hop-self

    neighbor 202.1.1.6 route-map ltol out

    neighbor 202.1.1.6 send-label

    no auto-summary

    !

    route-map atol permit 10

    set mpls-label

    !

    route-map ltol permit 10

    match mpls-label

    set mpls-label

    !

    end

    [R5]

    R5#show run

    !

    version 12.4

    !

    hostname R5

    !

    ip cef

    !

    interface Loopback0

    ip address 202.1.1.5 255.255.255.255

    !

    interface Ethernet4/0

    ip address 80.5.6.1 255.255.255.0

    duplex half

    mpls ip

    !

    interface Ethernet4/3

    ip address 80.4.5.2 255.255.255.0

    duplex half

    mpls ip

    !

    router ospf 1

    log-adjacency-changes

    network 80.4.5.0 0.0.0.255 area 0

    network 80.5.6.0 0.0.0.255 area 0

    network 202.1.1.5 0.0.0.0 area 0

    !

    end

    [R6]

    R6#show run

    !

    version 12.4

    !

    hostname R6

    !

    ip cef

    !

    ip vrf vrf10

    rd 100:10

    route-target export 100:10

    route-target import 100:10

    !

    ip vrf vrf20

    rd 100:20

    route-target export 100:20

    route-target import 100:20

    !

    ip vrf vrf30

    rd 100:30

    route-target export 100:30

    route-target import 100:30

    !

    interface Loopback0

    ip address 202.1.1.6 255.255.255.255

    !

    interface FastEthernet0/0

    no ip address

    shutdown

    duplex half

    !

    interface Ethernet4/0

    ip address 80.5.6.2 255.255.255.0

    duplex half

    mpls ip

    !

    interface Ethernet4/6

    ip vrf forwarding vrf20

    ip address 60.0.20.1 255.255.255.0

    duplex half

    !

    interface Ethernet4/7

    ip vrf forwarding vrf30

    ip address 60.0.30.1 255.255.255.0

    duplex half

    !

    router ospf 1

    log-adjacency-changes

    network 80.5.6.0 0.0.0.255 area 0

    network 202.1.1.6 0.0.0.0 area 0

    !

    router bgp 400

    bgp log-neighbor-changes

    neighbor 202.1.1.1 remote-as 200

    neighbor 202.1.1.1 ebgp-multihop 10

    neighbor 202.1.1.1 update-source Loopback0

    neighbor 202.1.1.4 remote-as 400

    neighbor 202.1.1.4 update-source Loopback0

    !

    address-family ipv4

    redistribute connected

    no neighbor 202.1.1.1 activate

    neighbor 202.1.1.4 activate

    neighbor 202.1.1.4 send-label

    no auto-summary

    no synchronization

    exit-address-family

    !

    address-family vpnv4

    neighbor 202.1.1.1 activate

    neighbor 202.1.1.1 send-community extended

    exit-address-family

    !

    address-family ipv4 vrf vrf30

    redistribute connected

    no synchronization

    exit-address-family

    !

    address-family ipv4 vrf vrf20

    redistribute connected

    no synchronization

    exit-address-family

    !

    address-family ipv4 vrf vrf10

    redistribute connected

    no synchronization

    exit-address-family

    !

    end

    根据朋友的提醒,在此增加从R6到R1的私网路由trace信息,可以清楚的看到沿途标签信息的变化:

    R6#traceroute vrf vrf30
    Protocol [ip]:   
    Target IP address: 10.0.30.1 
    Source address: 60.0.30.1    
    Numeric display [n]:   
    Resolve AS number in (G)lobal table, (V)RF or(N)one [G]:   
    Timeout in seconds [3]:
    Probe count [3]: 
    Minimum Time to Live [1]:    
    Maximum Time to Live [30]:   
    Port Number [33434]:   
    Loose, Strict, Record, Timestamp, Verbose[none]:
    Type escape sequence to abort.
    Tracing the route to 10.0.30.1

      1 80.5.6.1 [MPLS: Labels 16/20/18 Exp 0] 300 msec 456 msec 384 msec  
      2 80.4.5.1 [MPLS: Labels 20/18 Exp 0] 320 msec 336 msec 312 msec
      3 80.3.4.1 [MPLS: Labels 24/18 Exp 0] 280 msec 280 msec 328 msec
      4 80.2.3.1 [AS 200] [MPLS: Labels 17/18 Exp 0] 300 msec 264 msec 480 msec  
      5 10.0.30.1 376 msec 388 msec 580 msec   

    Cisco跨域三层VPN OptionC配置指导 - 网络的感觉     go home - 51CTO技术博客-领先的IT技术博客