配置设备华为三层交换机:S5720-32X-EI-AC。拓扑图如下。MPLS 隧道绑定在PE1的VLAN 20接口和PE2的VLAN 40接口上。CE1与CE2之间的流量进入MPLS 通道。
lsr-id 1.1.1.9 lsr-id 2.2.2.9
| |
|--------------- MPLS --------------|
| |
AS 65410 AS 100 | | AS 100 AS 65430
|----- EBGP ----| |----------- IBGP AS 100 ---------| |----- EBGP -----|
| | | | | |
| | | | | |
10.1.1.1/24 10.1.1.2 1.1.1.9/32 2.2.2.9/32 10.3.1.2 10.3.1.1/24
| | | | | |
|--------------| |---------------------| |---------| |---------------------| |----------------|
| vif20 | | vif20 loopback1 | | | | Loopback1 vif40 | | vif40 |
| | | | | | | | | |
| CE1 0/0/3 |--------| 0/0/6 PE1 0/0/4 |--------| P |--------| 0/0/4 PE2 0/0/6 |----------| 0/0/4 CE2 |
| | | | | | | | | |
| | | vif30 | | | | vif30 | | |
|--------------| |---------------------| |---------| |---------------------| |----------------|
| |
172.1.1.1 172.1.1.2
| |
| |
RID 1.1.1.9 ------- OSPF ------- RID 2.2.2.9
创建虚拟专用网络实例,相当于创建一个独立的虚拟专用网络实例路由表,虚拟专用网络实例之间的路由信息互不影响,不同实例可承载相同的路由信息。之后,将VPN实例绑定在接口vlanif20上,由此接口学习到的路由信息放入到实例a的路由表中。
虚拟专用网络实例的外出扩展团体属性(export-extcommunity)和输入扩展团体属性(import-extcommunity)都设置为111:1。表明发送和接受BGP团体属性为111:1的路由进入a路由表。这两个属性都属于Route Target属性,PE路由器根据此属性决定路由归属与哪个路由表。
但是,当撤销路由时,BGP消息中不带有RT团体属性,这将导致PE路由器中所有的虚拟专用网络示例的路由表中与撤销路由相同的表项都被撤销掉。配置虚拟专用网络实例a的route-distinguisher以解决此地址区分问题,此处配置为100:1。这样将由RD区分撤销哪个VPN实例中的路由。
PE1的物理口0/0/6配置为trunk模式,允许的vlan id为20。其与CE1的0/0/3口直连。
[PE1]
[PE1]ip -instance a
[PE1--instance-a]
[PE1--instance-a]ipv4-family
[PE1--instance-a-af-ipv4]
[PE1--instance-a-af-ipv4]route-distinguisher 100:1
[PE1--instance-a-af-ipv4]
[PE1--instance-a-af-ipv4]-target 111:1 export-extcommunity
[PE1--instance-a-af-ipv4]-target 111:1 import-extcommunity
[PE1--instance-a-af-ipv4]quit
[PE1--instance-a]quit
[PE1]
[PE1]
[PE1]interface Vlanif 20
[PE1-Vlanif20]
[PE1-Vlanif20]ip binding -instance a
[PE1-Vlanif20]ip address 10.1.1.2 255.255.255.0
[PE1-Vlanif20]
[PE1-Vlanif20]quit
[PE1]
[PE1]
[PE1]interface GigabitEthernet 0/0/6
[PE1-GigabitEthernet0/0/6]
[PE1-GigabitEthernet0/0/6]port link-type trunk
[PE1-GigabitEthernet0/0/6]port trunk allow-pass vlan 20
[PE1-GigabitEthernet0/0/6]quit
[PE1]
首先创建回环接口,地址设置为1.1.1.9/32。此接口地址作为BGP自治系统100内的Router-ID使用。另外此地址还做为OSPF配置的Router-ID和MPLS的LSR-ID使用。PE1位于BGP自治区域100内,其内部邻居为2.2.2.9,外部邻居为自治区域65410内的CE1,地址为10.1.1.1。另外,PE1与2.2.2.9之间建立VPNv4通道,承载-target规定的流量。
[PE1]
[PE1]interface LoopBack 1
[PE1-LoopBack1]
[PE1-LoopBack1]ip address 1.1.1.9 32
[PE1-LoopBack1]quit
[PE1]
[PE1]
[PE1]bgp 100
[PE1-bgp]
[PE1-bgp]peer 2.2.2.9 as-number 100
[PE1-bgp]peer 2.2.2.9 connect-interface LoopBack 1
[PE1-bgp]
[PE1-bgp]ipv4-family unicast
[PE1-bgp-af-ipv4]
[PE1-bgp-af-ipv4]undo synchronization # Disable Perform IGP synchronization
[PE1-bgp-af-ipv4]peer 2.2.2.9 enable
[PE1-bgp-af-ipv4]quit
[PE1-bgp]
[PE1-bgp]
[PE1-bgp]ipv4-family v4
[PE1-bgp-af-v4]
[PE1-bgp-af-v4]policy -target
[PE1-bgp-af-v4]peer 2.2.2.9 enable
[PE1-bgp-af-v4]quit
[PE1-bgp]
[PE1-bgp]ipv4-family -instance a
[PE1-bgp-a]
[PE1-bgp-a]import-route direct
[PE1-bgp-a]peer 10.1.1.1 as-number 65410
[PE1-bgp-a]quit
[PE1-bgp]
[PE1-bgp]quit
[PE1]
在接口VLAN 30上启动MPLS以及LDP协议。设置Label-Switch-Router ID表示为回环接口地址1.1.1.9。
[PE1]
[PE1]interface Vlanif 30
[PE1-Vlanif30]
[PE1-Vlanif30]mpls
[PE1-Vlanif30]mpls ldp
[PE1-Vlanif30]quit
[PE1]
[PE1]
[PE1]interface GigabitEthernet 0/0/4
[PE1-GigabitEthernet0/0/4]
[PE1-GigabitEthernet0/0/4]port link-type access
[PE1-GigabitEthernet0/0/4]port default vlan 30
[PE1-GigabitEthernet0/0/4]quit
[PE1]
[PE1]mpls lsr-id 1.1.1.9
[PE1]mpls
[PE1]
OSPF负责通告1.1.1.9的地址。只有在PE1与PE2之间互相学习到2.2.2.9和1.1.1.9的路由之后,两者之间的BGP连接以及LDP连接才可能建立。
[PE1]
[PE1]ospf 1 router-id 1.1.1.9
[PE1-ospf-1]
[PE1-ospf-1]
[PE1-ospf-1]area 0.0.0.0
[PE1-ospf-1-area-0.0.0.0]
[PE1-ospf-1-area-0.0.0.0]network 1.1.1.9 0.0.0.0
[PE1-ospf-1-area-0.0.0.0]network 172.1.1.0 0.0.0.255
[PE1-ospf-1-area-0.0.0.0]
[PE1-ospf-1-area-0.0.0.0]quit
[PE1-ospf-1]quit
[PE1]
PE2的配置与PE1在理论上完全对称。以下为配置完成之后,使用display current-configuration显示的结果。
[PE2]display current-configuration
!Software Version V200R010C00SPC600
#
sysname PE2
#
vlan batch 10 20 30 40
#
diffserv domain default
#
ip -instance a
ipv4-family
route-distinguisher 200:1
-target 111:1 export-extcommunity
-target 111:1 import-extcommunity
#
radius-server template default
#
mpls lsr-id 2.2.2.9
mpls
#
mpls ldp
#
#
...
interface Vlanif1
#
interface Vlanif30
ip address 172.1.1.2 255.255.255.0
mpls
mpls ldp
#
interface Vlanif40
ip binding -instance a
ip address 10.3.1.2 255.255.255.0
#
...
interface GigabitEthernet0/0/4
port link-type access
port default vlan 30
#
interface GigabitEthernet0/0/5
#
interface GigabitEthernet0/0/6
port link-type trunk
port trunk allow-pass vlan 40
#
...
#
interface LoopBack1
ip address 2.2.2.9 255.255.255.255
#
bgp 100
peer 1.1.1.9 as-number 100
peer 1.1.1.9 connect-interface LoopBack1
#
ipv4-family unicast
undo synchronization
peer 1.1.1.9 enable
#
ipv4-family v4
policy -target
peer 1.1.1.9 enable
#
ipv4-family -instance a
import-route direct
peer 10.3.1.1 as-number 65430
#
ospf 1 router-id 2.2.2.9
area 0.0.0.0
network 2.2.2.9 0.0.0.0
network 172.1.1.0 0.0.0.255
#
...
[PE2]
CE1与CE2的BGP配置比较简单,不再累述。
PE1通过OSPF学习到了2.2.2.9的路由。
[PE1]display ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
Destinations : 1 Routes : 1
OSPF routing table status :
Destinations : 1 Routes : 1
Destination/Mask Proto Pre Cost Flags NextHop Interface
2.2.2.9/32 OSPF 10 1 D 172.1.1.2 Vlanif30
OSPF routing table status :
Destinations : 0 Routes : 0
[PE1]
MPLS的标签为1024:
[PE1]display mpls lsp
-------------------------------------------------------------------------------
LSP Information: BGP LSP
-------------------------------------------------------------------------------
FEC In/Out Label In/Out IF Vrf Name
-/32 1024/NULL -/- a
虚拟专用网络实例a的路由表如下:
[PE1]display ip routing-table -instance a
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: a
Destinations : 3 Routes : 3
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.1.1.0/24 Direct 0 0 D 10.1.1.2 Vlanif20
10.1.1.2/32 Direct 0 0 D 127.0.0.1 Vlanif20
10.3.1.0/24 IBGP 255 0 RD 2.2.2.9 Vlanif30
[PE1]
END