当前位置:   article > 正文

MPLS VP Hub and Spoke实验_hub-ce 和hub-pe

hub-ce 和hub-pe


实验拓扑:

在这里插入图片描述

实验要求:

  • R6与R7通信需要经过R1,不可以直通
  • HUB-CE,SPOKE-CE在同一个AS(allow
    -as-loop的合理使用)
  • 各个PE与CE之间均为EBGP关系(也可以做IBGP,OSPF)

实验步骤:

配置Hub-PE与Spoke-PE间使用MP-IBGP

Hub-PE vpn in 团体值 = Spoke-PE的出团体值;vpn out 团体值 = Spoke-PE的入团体值。(所有Spoke-PE的出入团体值设为一致,便于扩展以及Hub-Spoke统一管理)

1.执行命令system-view,进入系统视图。
2.执行命令bgp { as-number-plain | as-number-dot },进入BGP视图。
3.执行命令peer ipv4-address as-number as-number,将对端PE配置为对等体。
4.执行命令peer ipv4-address connect-interface loopback interface-number,指定BGP建立TCP(Transmission Control Protocol)连接的接口。 

PE之间必须使用32位掩码的Loopback接口地址来建立MP-IBGP对等体关系,以便能够迭代到隧道。以Loopback接口地址为目的地址的路由通过MPLS骨干网上的IGP发布给对端PE。

5.执行命令ipv4-family vpnv4 [ unicast ],进入BGP-VPNv4地址族视图。
6.执行命令peer ipv4-address enable,使能对等体交换VPN-IPv4路由信息的能力。

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

配置PE上的VPN实例

配置Hub-PE上的VPN实例 
Hub-PE需配置两个VPN实例(VPN-in和VPN-out):

 - VPN-in用于接收并维护所有Spoke-PE发布的VPNv4路由。
 - VPN-out用于维护Hub站点及所有Spoke站点的路由,并发布给所有Spoke-PE。

1.执行命令system-view,进入系统视图。
2.执行命令ip vpn-instance VPN-in,创建并进入VPN-in实例视图。 
3.执行命令ipv4-family,使能VPN-in实例IPv4地址族,并进入VPN-in实例IPv4地址族视图。
4.执行命令route-distinguisher route-distinguisher,配置VPN-in实例IPv4地址族的RD。
5.执行命令vpn-target vpn-target1 &<1-8> import-extcommunity,为VPN-in实例IPv4地址族配置VPN-target扩展团体属性,使得该实例IPv4地址族可以接收所有Spoke-PE发布的VPNv4路由。 

6.执行命令quit,退回VPN实例视图。
7.执行命令quit,退回系统视图。
8.执行命令ip vpn-instance VPN-out,创建并进入VPN-out实例视图。
9.执行命令ipv4-family,使能VPN-out实例IPv4地址族,并进入VPN-out实例IPv4地址族视图。
10.执行命令route-distinguisher route-distinguisher,配置VPN-out实例IPv4地址族的RD。
11.执行命令vpn-target vpn-target2 &<1-8> export-extcommunity,为VPN-out实例IPv4地址族配置VPN-target扩展团体属性,发布Hub站点及所有Spoke站点的路由。  

配置Spoke-PE上的VPN实例 
每个Spoke-PE上配置一个VPN实例。
1.执行命令system-view,进入系统视图。
2.执行命令ip vpn-instance vpn-instance-name,进入VPN-in的VPN实例视图。
3.执行命令ipv4-family,进入VPN实例IPv4地址族视图。
4.执行命令route-distinguisher route-distinguisher,配置VPN-in实例IPv4地址族的RD。
5.执行命令vpn-target vpn-target2 &<1-8> import-extcommunity,配置VPN-target扩展团体属性,使得该实例可以接收Hub-PE发布的VPNv4路由。 

6.执行命令vpn-target vpn-target1 &<1-8> export-extcommunity,配置VPN-target扩展团体属性,发布本Spoke-PE所接入的站点的路由。 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28

配置接口与VPN实例绑定

Hub-PE上需要使用两个接口或子接口:一个绑定VPN-in,用于接收Spoke-PE发来的路由;另一个绑定VPN-out,用于发布Hub站点及所有Spoke站点的路由。

  • 配置VPN实例后,需要将本设备上属于该VPN的接口与该VPN实例绑定,否则该接口将属于公网接口,无法转发VPN数据。
  • 绑定VPN实例的接口将属于私网接口,需重新配置IP地址,以实现PE-CE间的路由交互。
  • 接口与VPN实例绑定后,将删除接口上已经配置的IP地址、路由协议等三层特性(包括IPv4和IPv6)。
  • 去使能VPN下的某个地址族(IPv4或IPv6)时,将清理接口下该类地址的配置;当VPN实例下没有地址族配置时,将解除接口与VPN实例的绑定关系。

在Hub-PE及所有Spoke-PE上进行如下配置。

1.执行命令system-view,进入系统视图。
2.执行命令interface interface-type interface-number,进入需要绑定VPN实例的接口视图。
3.(可选)对于以太网接口,执行命令undo portswitch,配置接口切换到三层模式。

缺省情况下,以太网接口处于二层模式。

4.执行命令ip binding vpn-instance vpn-instance-name,将当前接口与VPN实例绑定。 

缺省情况下,接口不与任何VPN实例绑定,属于公网接口。

5.执行命令ip address ip-address { mask | mask-length },配置接口的IP地址。 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

配置PE与CE间路由交换

1.执行命令system-view,进入系统视图。
2.执行命令bgp { as-number-plain | as-number-dot },进入BGP视图。
3.执行命令ipv4-family vpn-instance vpn-instance-name,进入BGP-VPN实例IPv4地址族视图。 
4.执行命令peer { group-name | ipv4-address } allow-as-loop [ number ] [ global-as [ vpn-as ] ],允许路由环路。这里的number取1,允许AS重复1次的路由通过。
  • 1
  • 2
  • 3
  • 4

检查Hub and Spoke配置结果

1.使用display ip routing-table vpn-instance vpn-instance-name命令在Hub-PE上查看VPN-in和VPN-out的路由信息。可以看到:VPN-in的路由表中有到所有Spoke站点的路由;VPN-out的路由有到Hub站点及到所有Spoke站点的路由。 
2.使用display ip routing-table命令在Hub-CE和所有Spoke-CE上查看路由信息,Hub-CE和所有Spoke-CE上有到Hub站点和到所有Spoke站点的路由。 
  • 1
  • 2

实验测试:

查看HUB-PE的bgp表

vpn in
在这里插入图片描述
vpn out
在这里插入图片描述

查看SPOKE-PE的bgp路由表:

在这里插入图片描述

R7 (Spoke-CE)tracert R6(Spoke-CE):

可以看到先去R1(HUB-CE)然后去R6
在这里插入图片描述

实验总结:实验很简单,过程很艰难

  • 起初没配vpn时,想要R1与R6的环回相通,所有配置都对,但就是不行,一怒之下删完后醒悟: 华为设备需要开启 route recursive-lookup tunnel 路由基于隧道进行递归查找
  • Spoke-PE与Spoke-CE之间,绑定vpn-instance之后,邻居关系就断了,一直不行:绑定了vpn-instance的接口那里配置BGP邻居时需要在ipv4-family中的vpn-instance下配置
  • 因为所有CE都划分在AS1,所以注意BGP的防环,运用allow-as-loop
  • 实验结束后写总结时,R2掉线了,重新配了一遍
  • 好艰难,实验简单,很多细节不到位,nonono

实验所有配置

R1

#
interface Ethernet0/0/1
 ip address 21.1.1.1 255.255.255.0
#
interface LoopBack0
 ip address 1.1.1.1 255.255.255.0
#
bgp 1
 peer 12.1.1.2 as-number 100
 peer 21.1.1.2 as-number 100
 #
 ipv4-family unicast
  undo synchronization
  network 1.1.1.0 255.255.255.0
  peer 12.1.1.2 enable
  peer 12.1.1.2 allow-as-loop
  peer 21.1.1.2 enable
#
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

R2

#
sysname R2
#
ip vpn-instance in
 ipv4-family
  route-distinguisher 1:1
  vpn-target 1:1 import-extcommunity
#
ip vpn-instance out
 ipv4-family
  route-distinguisher 2:2
  vpn-target 2:2 export-extcommunity
#
mpls lsr-id 2.2.2.2
mpls
#
mpls ldp
#
interface Ethernet0/0/0
 ip binding vpn-instance in
 ip address 12.1.1.2 255.255.255.0
#
interface Ethernet0/0/1
 ip address 23.1.1.1 255.255.255.0
 mpls
 mpls ldp
#
interface GigabitEthernet0/0/0
 ip binding vpn-instance out
 ip address 21.1.1.2 255.255.255.0
#
interface LoopBack0
 ip address 2.2.2.2 255.255.255.0
#
bgp 100
 peer 4.4.4.4 as-number 100
 peer 4.4.4.4 connect-interface LoopBack0
 peer 5.5.5.5 as-number 100
 peer 5.5.5.5 connect-interface LoopBack0
 #
 ipv4-family unicast
  undo synchronization
  peer 4.4.4.4 enable
  peer 4.4.4.4 reflect-client
  peer 4.4.4.4 next-hop-local
  peer 5.5.5.5 enable
  peer 5.5.5.5 reflect-client
  peer 5.5.5.5 next-hop-local
 #
 ipv4-family vpnv4
  policy vpn-target
  peer 4.4.4.4 enable
  peer 4.4.4.4 reflect-client
  peer 4.4.4.4 next-hop-local
  peer 5.5.5.5 enable
  peer 5.5.5.5 reflect-client
  peer 5.5.5.5 next-hop-local
 #
 ipv4-family vpn-instance in
  peer 12.1.1.1 as-number 1
 #
 ipv4-family vpn-instance out
  peer 21.1.1.1 as-number 1
  peer 21.1.1.1 allow-as-loop 2
#
ospf 1 router-id 2.2.2.2
 area 0.0.0.0
  network 23.1.1.0 0.0.0.255
  network 2.2.2.2 0.0.0.0
#
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70

R3

#
sysname R3
#
mpls lsr-id 3.3.3.3
mpls
#
mpls ldp
#
interface Ethernet0/0/0
 ip address 23.1.1.2 255.255.255.0
 mpls
 mpls ldp
#
interface Ethernet0/0/1
 ip address 34.1.1.1 255.255.255.0
 mpls
 mpls ldp
#
interface GigabitEthernet0/0/0
 ip address 35.1.1.1 255.255.255.0
 mpls
 mpls ldp
#
interface LoopBack0
 ip address 3.3.3.3 255.255.255.0
#
ospf 1 router-id 3.3.3.3
 area 0.0.0.0
  network 0.0.0.0 255.255.255.255
#
route recursive-lookup tunnel
#
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32

R4

#
sysname R4
#
ip vpn-instance spoke
 ipv4-family
  route-distinguisher 1:1
  vpn-target 1:1 export-extcommunity
  vpn-target 2:2 import-extcommunity
#
mpls lsr-id 4.4.4.4
mpls
#
mpls ldp
#
interface Ethernet0/0/0
 ip address 34.1.1.2 255.255.255.0
 mpls
 mpls ldp
#
interface Ethernet0/0/1
 ip binding vpn-instance spoke
 ip address 46.1.1.1 255.255.255.0
#
interface LoopBack0
 ip address 4.4.4.4 255.255.255.0
#
bgp 100
 peer 2.2.2.2 as-number 100
 peer 2.2.2.2 connect-interface LoopBack0
 #
 ipv4-family unicast
  undo synchronization
  peer 2.2.2.2 enable
  peer 2.2.2.2 next-hop-local
 #
 ipv4-family vpnv4
  policy vpn-target
  peer 2.2.2.2 enable
  peer 2.2.2.2 next-hop-local
 #
 ipv4-family vpn-instance spoke
  peer 46.1.1.2 as-number 1
#
ospf 1 router-id 4.4.4.4
 area 0.0.0.0
  network 34.1.1.0 0.0.0.255
  network 4.4.4.4 0.0.0.0
#
route recursive-lookup tunnel
#
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50

R5

#
sysname R5
#
ip vpn-instance spoke
 ipv4-family
  route-distinguisher 1:1
  vpn-target 1:1 export-extcommunity
  vpn-target 2:2 import-extcommunity
#
mpls lsr-id 5.5.5.5
mpls
#
mpls ldp
#
interface Ethernet0/0/0
 ip address 35.1.1.2 255.255.255.0
 mpls
 mpls ldp
#
interface Ethernet0/0/1
 ip binding vpn-instance spoke
 ip address 57.1.1.1 255.255.255.0
#
interface LoopBack0
 ip address 5.5.5.5 255.255.255.0
#
bgp 100
 peer 2.2.2.2 as-number 100
 peer 2.2.2.2 connect-interface LoopBack0
 #
 ipv4-family unicast
  undo synchronization
  peer 2.2.2.2 enable
  peer 2.2.2.2 next-hop-local
 #
 ipv4-family vpnv4
  policy vpn-target
  peer 2.2.2.2 enable
  peer 2.2.2.2 next-hop-local
 #
 ipv4-family vpn-instance spoke
  peer 57.1.1.2 as-number 1
#
ospf 1 router-id 5.5.5.5
 area 0.0.0.0
  network 35.1.1.0 0.0.0.255
  network 5.5.5.5 0.0.0.0
#
route recursive-lookup tunnel
#
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50

R6

#
sysname R6
#
interface LoopBack0
 ip address 6.6.6.6 255.255.255.0
#
bgp 1
 peer 46.1.1.1 as-number 100
 #
 ipv4-family unicast
  undo synchronization
  network 6.6.6.0 255.255.255.0
  peer 46.1.1.1 enable
  peer 46.1.1.1 allow-as-loop 2
#
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

R7

#
sysname R7
#
interface Ethernet0/0/0
 ip address 57.1.1.2 255.255.255.0
#
interface LoopBack0
 ip address 7.7.7.7 255.255.255.0
#
bgp 1
 peer 57.1.1.1 as-number 100
 #
 ipv4-family unicast
  undo synchronization
  network 7.7.7.0 255.255.255.0
  peer 57.1.1.1 enable
  peer 57.1.1.1 allow-as-loop 2
#
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/567700
推荐阅读
相关标签
  

闽ICP备14008679号