配置CE使用公网GRE隧道接入VPN示例

组网需求

  1. PE1和PE2位于MPLS骨干网
  2. CE1和PE1之间为公共网络,期间通过设备R1互联
  3. CE2与PE2直连
  4. CE1与CE2属于同一个VPN要求他们之间能互通

组网拓扑

配置CE使用公网隧道接入VPN示例

配置思路

  1. 配置各个路由器基本功能以及各个接口IP地址
  2. 配置PE1与PE2之间的OSPF协议,保持互通,并配置MPLS和接口使能MPLS
  3. 配置PE1与PE2的VPN实例,并绑定响应接口
  4. 配置PE1与CE1之间网络互通
  5. 配置PE1与CE1之间隧道的互通
  6. 配置PE2与CE2之间网络互通
  7. 配置PE1与PE2之间BGP协议以及MP-BGP
  8. 路由互相引入

配置命令

  1. 配置各个路由器基本功能以及各个接口IP地址

    • PE1配置

      1
      2
      3
      4
      5
      6
      7
      8
      9
      sys
      sys PE1

      int g0/0/0
      ip add 110.1.1.1 30
      int g0/0/1
      ip add 50.1.1.1 30
      int LoopBack 0
      ip add 1.1.1.9 32
  • PE2配置

    1
    2
    3
    4
    5
    6
    7
    8
    9
    sys
    sys PE2

    int g0/0/0
    ip add 110.1.1.2 30
    int g0/0/1
    ip add 11.1.1.1 30
    int LoopBack 0
    ip add 3.3.3.9 32
  • R1配置

    1
    2
    3
    4
    5
    6
    7
    sys
    sys R1

    int g0/0/0
    ip add 30.1.1.2 30
    int g0/0/1
    ip dd 50.1.1.2 30
  • CE1配置

    1
    2
    3
    4
    5
    6
    7
    sys
    sys CE1

    int g0/0/0
    ip add 30.1.1.1 30
    int g0/0/1
    ip add 21.1.1.1 30
  • CE2配置

    1
    2
    3
    4
    5
    6
    7
    sys
    sys CE2

    int g0/0/0
    ip add 41.1.1.1 30
    int g0/0/1
    ip add 11.1.1.2 30
  1. 配置PE1与PE2之间的OSPF协议,保持互通,并配置MPLS和接口使能MPLS

    • PE1配置

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      sys
      ospf 10
      area 0
      network 1.1.1.9 0.0.0.0
      network 110.1.1.0 0.0.0.3

      mpls lsr-id 1.1.1.9
      mpls
      lsp-trigger all
      quit
      mpls ldp

      int g0/0/0
      mpls
      mpls ldp
  • PE2配置

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    sys

    ospf 10
    area 0
    network 3.3.3.9 0.0.0.0
    network 110.1.1.0 0.0.0.3

    mpls lsr-id 3.3.3.9
    mpls
    lsp-trigger all
    quit
    mpls ldp

    int g0/0/0/
    mpls
    mpls ldp
  1. 配置VPN实例,并在指定接口绑定VPN实例

    • PE1配置

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      sys

      ip vpn-instance vpn1
      route-distinguisher 100:1
      vpn-target 111:1 export-excommunity
      vpn-target 111:1 import-excommunity

      int Tunnel 0/0/0
      ip binding vpn-instance vpn1
      ip add 2.2.2.2 30
  • PE2配置

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    sys

    ip vpn-instance vpn1
    route-distinguisher 200:1
    vpn-target 111:1 export-excommunity
    vpn-target 111:1 import-excommunity

    int g0/0/1
    ip binding vpn-instance vpn1
    ip add 11.1.1.1 30
  1. 配置PE1与R1与CE1之间网络互通

    • PE1配置

      1
      2
      3
      4
      5
      sys

      ospf 20
      area 0
      network 50.1.1.0 0.0.0.3
  • R1配置

    1
    2
    3
    4
    5
    6
    sys

    ospf 20
    area 0
    network 50.1.1.0 0.0.0.3
    network 30.1.1.0 0.0.0.3
  • CE1配置

    1
    2
    3
    4
    5
    sys

    ospf 20
    area 0
    network 30.1.1.0 0.0.0.3
  1. 配置PE2与CE2之间网络互通

    • PE2配置

      1
      2
      3
      4
      5
      6
      7
      8
      sys

      isis 50 vpn-instance vpn1
      network-entity 50.0000.0000.0003.00

      int g0/0/1
      isis enable 50
      isis small-hello
  • CE2配置

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    sys

    isis 50
    network-entity 50.0000.0000.0004.00

    int g0/0/0
    isis enable 50
    isis small-hello

    int g0/0/1
    isis enable 50
    isis small-hello
  1. 配置GRE隧道,指定IP地址、源地址、目的地址、隧道协议

    • PE1配置

      1
      2
      3
      4
      5
      6
      sys

      int Tunnel 0/0/0
      tunnel-protocol gre
      source 50.1.1.1
      destination 30.1.1.1
  • CE1配置

    1
    2
    3
    4
    5
    6
    7
    sys

    int Tunnel 0/0/0
    tunnel-protocol gre
    ip add 2.2.2.1 30
    source 30.1.1.1
    destination 50.1.1.1
  1. 配置GRE隧道路由,实现网络互通

    • PE1配置

      1
      2
      3
      4
      5
      6
      7
      8
      sys

      isis 50 vpn-instance vpn1
      network-entity 50.0000.0000.0002.00

      int Tunnel 0/0/0
      isis enable 50
      isis small hello
  • CE1配置

    1
    2
    3
    4
    5
    6
    7
    8
    sys

    isis 50
    network-entity 50.0000.0000.0001.00

    int Tunnel 0/0/0
    isis enable 50
    isis small-hello
  1. 配置BGP路由,实现MP-BGP

    • PE1配置

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      sys

      bgp 100
      peer 3.3.3.9 as-number 100
      peer 3.3.3.9 connect-interface LoopBack 0

      ipv4-family vpnv4
      peer 3.3.3.9 enable
      ipv4-family vpn-instance
      import-route isis 50
  • PE2配置

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    sys

    bgp 100
    peer 1.1.1.9 as-number 100
    peer 1.1.1.9 connect-interface LoopBack 0

    ipv4-family vpnv4
    peer 1.1.1.9 enable
    ipv4-family vpn-instance vpn1
    import-route isis 50
  1. 将MPLS骨干网中的路由引入到PE与CE间路由表

    • PE1配置

      1
      2
      3
      4
      sys

      isis 50
      import-route bgp
  • PE2配置

    1
    2
    3
    4
    sys

    isis 50
    import-route bgp

查看结果

  1. 查看VPN1的路由

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    dispaly ip routing-table vpn-instance vpn1

    <PE1>dis ip routing-table vpn-instance vpn1
    Route Flags: R - relay, D - download to fib
    ------------------------------------------------------------------------------
    Routing Tables: vpn1
    Destinations : 7 Routes : 7

    Destination/Mask Proto Pre Cost Flags NextHop Interface

    2.2.2.0/30 Direct 0 0 D 2.2.2.2 Tunnel0/0/0
    2.2.2.2/32 Direct 0 0 D 127.0.0.1 Tunnel0/0/0
    2.2.2.3/32 Direct 0 0 D 127.0.0.1 Tunnel0/0/0
    11.1.1.0/30 IBGP 255 0 RD 3.3.3.9 GigabitEthernet
    0/0/0
    21.1.1.0/30 ISIS-L2 15 20 D 2.2.2.1 Tunnel0/0/0
    41.1.1.0/30 IBGP 255 20 RD 3.3.3.9 GigabitEthernet
    0/0/0
    255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
  2. 查看CE1到PC2间的路由

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    display ip routing-table 41.1.1.2

    <CE1>display ip routing-table 41.1.1.2
    Route Flags: R - relay, D - download to fib
    ------------------------------------------------------------------------------
    Routing Table : Public
    Summary Count : 1
    Destination/Mask Proto Pre Cost Flags NextHop Interface

    41.1.1.0/30 ISIS-L2 15 74 D 2.2.2.2 Tunnel0/0/0
吴超 wechat
subscribe to my blog by scanning my public wechat account