素材来源:华为路由器配置指南
一边学习一边整理试验笔记,并与大家分享,侵权即删,谢谢支持!
附上汇总贴:玩转华为ENSP模拟器系列 | 合集_COCOgsta的博客-CSDN博客_ensp实验大全
通过在CE上使用OSPF多实例实现局域网不同业务的隔离。
分公司A(Site1)与分公司B(Site2)需要通过运营商的骨干网和总公司相互通信。分公司A和分公司B各自负责不同的业务,且需要访问总公司的不同区域,这个区域可以是有业务联系的相关部门,也可以是不同的服务器,因此需要为分公司A和分公司B实现业务隔离。如果使用传统的BGP/MPLS IP VPN技术,需要在总公司侧分别为分公司A和分公司B架设一台CE设备,导致成本偏高。为了解决这个问题,可以在总公司侧使用MCE技术,即在总公司侧使用一台MCE设备接入不同VPN的Site,实现业务隔离。如图1所示:
CE1和CE2为分公司A和分公司B的CE设备,分别属于a和b。
MCE作为VPN多实例交换的设备接入总公司侧的a和b的Site。
a和b使用不同的VPN-Target属性。
DeviceA和DeviceB分别为总公司内用于与分公司A和分公司B通信的设备。
要求属于相同VPN的用户之间能互相访问,不同VPN的用户之间不能互相访问。
具体配置过程请参见后面的配置文件。
完成此步配置后,PE之间应能互相学习到对方的Loopback1的地址。
以PE2为例:
[~PE2-Ethernet1/0/2]dis ip routing-table
Route Flags: R - relay, D - download to fib, T - to -instance, B - black hole
route
------------------------------------------------------------------------------
Routing Table : _public_
Destinations : 15 Routes : 15
Destination/Mask Proto Pre Cost Flags NextHop Interface
1.1.1.9/32 OSPF 10 1 D 172.1.1.1 Ethernet1/0/0
2.2.2.9/32 Direct 0 0 D 127.0.0.1 LoopBack1
10.5.1.0/24 Direct 0 0 D 10.5.1.1 Ethernet1/0/1
10.5.1.1/32 Direct 0 0 D 127.0.0.1 Ethernet1/0/1
10.5.1.255/32 Direct 0 0 D 127.0.0.1 Ethernet1/0/1
10.5.2.0/24 Direct 0 0 D 10.5.2.1 Ethernet1/0/2
10.5.2.1/32 Direct 0 0 D 127.0.0.1 Ethernet1/0/2
10.5.2.255/32 Direct 0 0 D 127.0.0.1 Ethernet1/0/2
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
172.1.1.0/24 Direct 0 0 D 172.1.1.2 Ethernet1/0/0
172.1.1.2/32 Direct 0 0 D 127.0.0.1 Ethernet1/0/0
172.1.1.255/32 Direct 0 0 D 127.0.0.1 Ethernet1/0/0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
[~PE2-Ethernet1/0/2]
具体配置过程请参见后面的配置文件。
完成此步配置后,在PE上执行命令display mpls ldp session,应能看见PE之间的MPLS LDP会话状态为“Operational”。
以PE2为例:
[~PE2-Ethernet1/0/0]dis mpls ldp session
LDP Session(s) in Public Network
Codes: LAM(Label Advertisement Mode), SsnAge Unit(DDDD:HH:MM)
An asterisk (*) before a session means the session is being deleted.
--------------------------------------------------------------------------
PeerID Status LAM SsnRole SsnAge KASent/Rcv
--------------------------------------------------------------------------
1.1.1.9:0 Operational DU Active 0000:00:00 1/1
--------------------------------------------------------------------------
TOTAL: 1 Session(s) Found.
[~PE2-Ethernet1/0/0]
配置PE1。
PE1:
ip -instance a
ipv4-family
route-distinguisher 100:1
-target 111:1 export-extcommunity
-target 111:1 import-extcommunity
ip -instance b
ipv4-family
route-distinguisher 100:2
-target 222:2 export-extcommunity
-target 222:2 import-extcommunity
interface Ethernet1/0/0
ip binding -instance a
ip address 10.1.1.2 255.255.255.0
interface Ethernet1/0/1
ip binding -instance b
ip address 10.2.1.2 255.255.255.0
配置PE2。
PE2:
ip -instance a
ipv4-family
route-distinguisher 200:1
-target 111:1 export-extcommunity
-target 111:1 import-extcommunity
ip -instance b
ipv4-family
route-distinguisher 200:2
-target 222:2 export-extcommunity
-target 222:2 import-extcommunity
interface Ethernet1/0/1
ip binding -instance a
ip address 10.5.1.1 255.255.255.0
interface Ethernet1/0/2
ip binding -instance b
ip address 10.5.2.1 255.255.255.0
MCE:
ip -instance a
ipv4-family
route-distinguisher 100:1
-target 111:1 export-extcommunity
-target 111:1 import-extcommunity
ip -instance b
ipv4-family
route-distinguisher 100:2
-target 222:2 export-extcommunity
-target 222:2 import-extcommunity
interface Ethernet1/0/0
ip binding -instance a
ip address 10.5.1.2 255.255.255.0
interface Ethernet1/0/1
ip binding -instance b
ip address 10.5.2.2 255.255.255.0
interface Ethernet1/0/2
ip binding -instance a
interface Ethernet1/0/3
ip binding -instance b
ip address 10.4.1.2 255.255.255.0
具体配置过程请参见后面的配置文件。
完成此步配置后,在PE1上执行命令display bgp v4 all peer可以看见PE1与PE2的IBGP对等体关系及PE1与CE1、CE2之间建立EBGP对等体关系均为“Established”。
[~PE1-bgp]dis bgp v4 all peer
BGP local router ID : 1.1.1.9
Local AS number : 100
Total number of peers : 3 Peers in established state : 3
Peer V AS MsgRcvd MsgSent OutQ Up/Down State Pr
efRcv
2.2.2.9 4 100 5 9 0 00:01:28 Established
0
Peer of IPv4-family for instance :
VPN-Instance a, Router ID 1.1.1.9:
Peer V AS MsgRcvd MsgSent OutQ Up/Down State Pr
efRcv
10.1.1.1 4 65410 4 4 0 00:00:30 Established
1
VPN-Instance b, Router ID 1.1.1.9:
Peer V AS MsgRcvd MsgSent OutQ Up/Down State Pr
efRcv
10.2.1.1 4 65420 4 4 0 00:00:02 Established
1
[~PE1-bgp]
配置PE2。
PE2:
ospf 100 -instance a
import-route bgp
area 0.0.0.0
network 10.5.1.0 0.0.0.255
ospf 200 -instance b
import-route bgp
area 0.0.0.0
network 10.5.2.0 0.0.0.255
bgp 100
ipv4-family -instance a
import-route ospf 100
ipv4-family -instance b
import-route ospf 200
配置MCE。
MCE:
ospf 100 -instance a
area 0.0.0.0
network 10.5.1.0 0.0.0.255
ospf 200 -instance b
area 0.0.0.0
network 10.5.2.0 0.0.0.255
MCE:
ospf 100 -instance a
import-route rip 100
-instance-capability simple
ospf 200 -instance b
import-route rip 200
-instance-capability simple
未配置“-instance-capability simple”命令前,MCE可以收到外部路由,但无法形成路由表及转发表
[~MCE-ospf-100]dis ospf 100 routing
OSPF Process 100 with Router ID 10.3.1.2
Routing Tables
Routing for Network
Destination Cost Type NextHop AdvRouter Area
10.5.1.0/24 1 Direct 10.5.1.2 10.3.1.2 0.0.0.0
Total Nets: 1
Intra Area: 1 Inter Area: 0 ASE: 0 NSSA: 0
[~MCE-ospf-100]
[~MCE-ospf-100]dis ospf 100 lsdb
OSPF Process 100 with Router ID 10.3.1.2
Link State Database
Area: 0.0.0.0
Type LinkState ID AdvRouter Age Len Sequence Metric
Router 10.3.1.2 10.3.1.2 33 36 80000004 1
Router 10.5.1.1 10.5.1.1 175 36 80000002 1
Network 10.5.1.1 10.5.1.1 175 32 80000001 0
AS External Database
Type LinkState ID AdvRouter Age Len Sequence Metric
External 10.1.1.0 10.5.1.1 277 36 80000001 1
External 11.11.11.11 10.5.1.1 277 36 80000001 1
[~MCE-ospf-100]
[~MCE-ospf-100]dis ip routing-table -instance a
Route Flags: R - relay, D - download to fib, T - to -instance, B - black hole
route
------------------------------------------------------------------------------
Routing Table : a
Destinations : 8 Routes : 8
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.3.1.0/24 Direct 0 0 D 10.3.1.2 Ethernet1/0/2
10.3.1.2/32 Direct 0 0 D 127.0.0.1 Ethernet1/0/2
10.3.1.255/32 Direct 0 0 D 127.0.0.1 Ethernet1/0/2
10.5.1.0/24 Direct 0 0 D 10.5.1.2 Ethernet1/0/0
10.5.1.2/32 Direct 0 0 D 127.0.0.1 Ethernet1/0/0
10.5.1.255/32 Direct 0 0 D 127.0.0.1 Ethernet1/0/0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
[~MCE-ospf-100]
配置了“-instance-capability simple”后,可以收到外部路由
[~MCE-ospf-100]dis ospf 100 routing
OSPF Process 100 with Router ID 10.3.1.2
Routing Tables
Routing for Network
Destination Cost Type NextHop AdvRouter Area
10.5.1.0/24 1 Direct 10.5.1.2 10.3.1.2 0.0.0.0
Routing for ASEs
Destination Cost Type Tag NextHop AdvRouter
10.1.1.0/24 1 Type2 3489661028 10.5.1.1 10.5.1.1
11.11.11.11/32 1 Type2 3489661028 10.5.1.1 10.5.1.1
Total Nets: 3
Intra Area: 1 Inter Area: 0 ASE: 2 NSSA: 0
[~MCE-ospf-100]
[~MCE-ospf-100] dis ospf 100 lsdb
OSPF Process 100 with Router ID 10.3.1.2
Link State Database
Area: 0.0.0.0
Type LinkState ID AdvRouter Age Len Sequence Metric
Router 10.3.1.2 10.3.1.2 25 36 80000005 1
Router 10.5.1.1 10.5.1.1 285 36 80000002 1
Network 10.5.1.1 10.5.1.1 285 32 80000001 0
AS External Database
Type LinkState ID AdvRouter Age Len Sequence Metric
External 10.1.1.0 10.5.1.1 387 36 80000001 1
External 11.11.11.11 10.5.1.1 387 36 80000001 1
[~MCE-ospf-100]
[~MCE-ospf-100]dis ip routing-table -instance a
Route Flags: R - relay, D - download to fib, T - to -instance, B - black hole
route
------------------------------------------------------------------------------
Routing Table : a
Destinations : 10 Routes : 10
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.1.1.0/24 O_ASE 150 1 D 10.5.1.1 Ethernet1/0/0
10.3.1.0/24 Direct 0 0 D 10.3.1.2 Ethernet1/0/2
10.3.1.2/32 Direct 0 0 D 127.0.0.1 Ethernet1/0/2
10.3.1.255/32 Direct 0 0 D 127.0.0.1 Ethernet1/0/2
10.5.1.0/24 Direct 0 0 D 10.5.1.2 Ethernet1/0/0
10.5.1.2/32 Direct 0 0 D 127.0.0.1 Ethernet1/0/0
10.5.1.255/32 Direct 0 0 D 127.0.0.1 Ethernet1/0/0
11.11.11.11/32 O_ASE 150 1 D 10.5.1.1 Ethernet1/0/0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
[~MCE-ospf-100]
配置MCE。
MCE:
rip 100 -instance a
version 2
network 10.0.0.0
import-route ospf 100
rip 200 -instance b
version 2
network 10.0.0.0
import-route ospf 200
配置DeviceA。
DeviceA:
rip 100
version 2
network 10.0.0.0
network 33.0.0.0
配置DeviceB。
DeviceB:
rip 200
version 2
network 10.0.0.0
network 44.0.0.0
完成上述配置后,在MCE设备上执行命令display ip routing-table -instance命令,可以看到去往对端CE的路由。
以a为例:
[~MCE-rip-200]dis ip routing-table -instance a
Route Flags: R - relay, D - download to fib, T - to -instance, B - black hole
route
------------------------------------------------------------------------------
Routing Table : a
Destinations : 11 Routes : 11
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.1.1.0/24 O_ASE 150 1 D 10.5.1.1 Ethernet1/0/0
10.3.1.0/24 Direct 0 0 D 10.3.1.2 Ethernet1/0/2
10.3.1.2/32 Direct 0 0 D 127.0.0.1 Ethernet1/0/2
10.3.1.255/32 Direct 0 0 D 127.0.0.1 Ethernet1/0/2
10.5.1.0/24 Direct 0 0 D 10.5.1.2 Ethernet1/0/0
10.5.1.2/32 Direct 0 0 D 127.0.0.1 Ethernet1/0/0
10.5.1.255/32 Direct 0 0 D 127.0.0.1 Ethernet1/0/0
11.11.11.11/32 O_ASE 150 1 D 10.5.1.1 Ethernet1/0/0
33.33.33.33/32 RIP 100 1 D 10.3.1.1 Ethernet1/0/2
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
[~MCE-rip-200]
在PE上执行display ip routing-table -instance命令,可以看到去往对端Site的路由。
以PE1上的a为例:
dis ip routing-table -instance a
Route Flags: R - relay, D - download to fib, T - to -instance, B - black hole
route
------------------------------------------------------------------------------
Routing Table : a
Destinations : 9 Routes : 9
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.1.1.0/24 Direct 0 0 D 10.1.1.2 Ethernet1/0/0
10.1.1.2/32 Direct 0 0 D 127.0.0.1 Ethernet1/0/0
10.1.1.255/32 Direct 0 0 D 127.0.0.1 Ethernet1/0/0
10.3.1.0/24 IBGP 255 2 RD 2.2.2.9 Ethernet1/0/2
10.5.1.0/24 IBGP 255 2 RD 2.2.2.9 Ethernet1/0/2
11.11.11.11/32 EBGP 255 0 RD 10.1.1.1 Ethernet1/0/0
33.33.33.33/32 IBGP 255 2 RD 2.2.2.9 Ethernet1/0/2
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
CE1、DeviceA之间可以互通,CE2、DeviceB之间可以互通。
以CE1为例:
ping -a 11.11.11.11 33.33.33.33
PING 33.33.33.33: 56 data bytes, press CTRL_C to break
Reply from 33.33.33.33: bytes=56 Sequence=1 ttl=252 time=25 ms
Reply from 33.33.33.33: bytes=56 Sequence=2 ttl=252 time=15 ms
Reply from 33.33.33.33: bytes=56 Sequence=3 ttl=252 time=19 ms
Reply from 33.33.33.33: bytes=56 Sequence=4 ttl=252 time=19 ms
Reply from 33.33.33.33: bytes=56 Sequence=5 ttl=252 time=20 ms
--- 33.33.33.33 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 15/19/25 ms