素材来源:华为路由器配置指南
一边学习一边整理试验笔记,并与大家分享,侵权即删,谢谢支持!
附上汇总贴:玩转华为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]dis ip routing
Route Flags: R - relay, D - download to fib, T - to -instance, B - black hole
route
------------------------------------------------------------------------------
Routing Table : _public_
Destinations : 9 Routes : 9
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
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]
具体配置过程请参见后面的配置文件。
完成此步配置后,在PE上执行命令display mpls ldp session,应能看见PE之间的MPLS LDP会话状态为“Operational”。
以PE2为例:
[~PE2]dis mpls ldp sess
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:01:16 309/309
--------------------------------------------------------------------------
TOTAL: 1 Session(s) Found.
[~PE2]
配置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
interface LoopBack1
ip binding -instance a
ip address 3.3.3.9 255.255.255.255
interface LoopBack2
ip binding -instance b
ip address 4.4.4.9 255.255.255.255
具体配置过程请参见后面的配置文件。
完成此步配置后,在PE1上执行命令display bgp v4 all peer可以看见PE1与PE2的IBGP对等体关系及PE1与CE1、CE2之间建立EBGP对等体关系均为“Established”。
[~PE1]dis bgp v4 all peer
BGP local router ID : 172.1.1.1
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 100 98 0 01:19:19 Established
2
Peer of IPv4-family for instance :
VPN-Instance a, Router ID 172.1.1.1:
Peer V AS MsgRcvd MsgSent OutQ Up/Down State Pr
efRcv
10.1.1.1 4 65410 95 98 0 01:20:10 Established
1
VPN-Instance b, Router ID 172.1.1.1:
Peer V AS MsgRcvd MsgSent OutQ Up/Down State Pr
efRcv
10.2.1.1 4 65420 95 99 0 01:20:08 Established
1
[~PE1]
配置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
-instance-capability simple
area 0.0.0.0
network 3.3.3.9 0.0.0.0
ospf 200 -instance b
-instance-capability simple
area 0.0.0.0
network 4.4.4.9 0.0.0.0
未配置“-instance-capability simple”命令前,MCE可以收到外部路由,但无法形成路由表及转发表
[~MCE-ospf-200]dis ospf 100 rout
OSPF Process 100 with Router ID 10.5.1.2
Routing Tables
Routing for Network
Destination Cost Type NextHop AdvRouter Area
3.3.3.9/32 0 Direct 3.3.3.9 10.5.1.2 0.0.0.0
10.5.1.0/24 1 Direct 10.5.1.2 10.5.1.2 0.0.0.0
Total Nets: 2
Intra Area: 2 Inter Area: 0 ASE: 0 NSSA: 0
[~MCE-ospf-200]
[~MCE-ospf-100]
[~MCE-ospf-200]dis ospf 100 lsdb
OSPF Process 100 with Router ID 10.5.1.2
Link State Database
Area: 0.0.0.0
Type LinkState ID AdvRouter Age Len Sequence Metric
Router 10.5.1.1 10.5.1.1 1491 36 80000004 1
Router 10.5.1.2 10.5.1.2 33 48 80000007 1
Network 10.5.1.2 10.5.1.2 1490 32 80000003 0
AS External Database
Type LinkState ID AdvRouter Age Len Sequence Metric
External 10.1.1.0 10.5.1.1 1443 36 80000003 1
External 11.11.11.11 10.5.1.1 1443 36 80000003 1
[~MCE-ospf-200]
[~MCE-ospf-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 : 6 Routes : 6
Destination/Mask Proto Pre Cost Flags NextHop Interface
3.3.3.9/32 Direct 0 0 D 127.0.0.1 LoopBack1
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-200]
配置了“-instance-capability simple”后,可以收到外部路由
[~MCE-ospf-100]dis ospf 100 rout
OSPF Process 100 with Router ID 10.5.1.2
Routing Tables
Routing for Network
Destination Cost Type NextHop AdvRouter Area
3.3.3.9/32 0 Direct 3.3.3.9 10.5.1.2 0.0.0.0
10.5.1.0/24 1 Direct 10.5.1.2 10.5.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: 4
Intra Area: 2 Inter Area: 0 ASE: 2 NSSA: 0
[~MCE-ospf-100]
[~MCE-ospf-100]
[~MCE-ospf-100]dis ospf 100 lsdb
OSPF Process 100 with Router ID 10.5.1.2
Link State Database
Area: 0.0.0.0
Type LinkState ID AdvRouter Age Len Sequence Metric
Router 10.5.1.1 10.5.1.1 1584 36 80000004 1
Router 10.5.1.2 10.5.1.2 36 48 80000008 1
Network 10.5.1.2 10.5.1.2 1583 32 80000003 0
AS External Database
Type LinkState ID AdvRouter Age Len Sequence Metric
External 10.1.1.0 10.5.1.1 1536 36 80000003 1
External 11.11.11.11 10.5.1.1 1536 36 80000003 1
[~MCE-ospf-100]
[~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
3.3.3.9/32 Direct 0 0 D 127.0.0.1 LoopBack1
10.1.1.0/24 O_ASE 150 1 D 10.5.1.1 Ethernet1/0/0
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设备上执行命令display ip routing-table -instance命令,可以看到去往对端CE的路由。
以a为例:
[~MCE]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
3.3.3.9/32 Direct 0 0 D 127.0.0.1 LoopBack1
10.1.1.0/24 O_ASE 150 1 D 10.5.1.1 Ethernet1/0/0
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]
在PE上执行display ip routing-table -instance命令,可以看到去往对端Site的路由。
以PE1上的a为例:
[~PE1]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
3.3.3.9/32 IBGP 255 2 RD 2.2.2.9 Ethernet1/0/2
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.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
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
[~PE1]
CE1、DeviceA之间可以互通,CE2、DeviceB之间可以互通。
以CE1为例:
ping -a 11.11.11.11 3.3.3.9
PING 3.3.3.9: 56 data bytes, press CTRL_C to break
Reply from 3.3.3.9: bytes=56 Sequence=1 ttl=253 time=20 ms
Reply from 3.3.3.9: bytes=56 Sequence=2 ttl=253 time=16 ms
Reply from 3.3.3.9: bytes=56 Sequence=3 ttl=253 time=12 ms
Reply from 3.3.3.9: bytes=56 Sequence=4 ttl=253 time=10 ms
Reply from 3.3.3.9: bytes=56 Sequence=5 ttl=253 time=12 ms
--- 3.3.3.9 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 10/14/20 ms