

解决方案
vlan batch 10 20 30 40 //创建相应的对接vlan
ip vpn-instance test //创建vpn实例
ipv4-family
route-distinguisher 100:1
划分vlan 10和vlan 20为主区域的vlan,并配置ip地址
interface Vlanif10
ip address 192.168.1.1 255.255.255.0
#
interface Vlanif20
ip address 192.168.10.2 255.255.255.0
#
将vlan 30和40分配给vpn实例test用,并配置ip地址
interface Vlanif30
ip binding vpn-instance test
ip address 10.1.1.1 255.255.255.0
#
interface Vlanif40
ip binding vpn-instance test
ip address 10.10.10.2 255.255.255.0
将相应物理接口划分到相应vlan
interface GigabitEthernet0/0/1
port link-type access
port default vlan 20
#
interface GigabitEthernet0/0/2
port link-type access
port default vlan 10
interface GigabitEthernet0/0/23
port link-type access
port default vlan 30
#
interface GigabitEthernet0/0/24
port link-type access
port default vlan 40
此时端口g0/0/23和24以及vlan 30和40就属于vpn实例test了,与vlan 10和20不互通,逻辑上实现了两台设备“一分为二”,相互隔离了,且有独立的路由表
发散思维:可以在交换机上创建多个vpn实例,从而实现将一台交换机逻辑上“虚拟”为多台交换机了