VLAN间通信配置详解(三层路由实现) 很多朋友在配置交换机VLAN后,会遇到一个常见问题: 明明已经创建了VLAN并划分了端口,却无法实现不同VLAN间的通信 。这是什么原因呢? 核心关
很多朋友在配置交换机VLAN后,会遇到一个常见问题:明明已经创建了VLAN并划分了端口,却无法实现不同VLAN间的通信。这是什么原因呢?
本文将通过H3C交换机实战案例,详细讲解VLAN间通信的原理和配置方法,帮助你快速解决跨VLAN互通问题。
交换机在二层(数据链路层)基于MAC地址转发数据帧,当端口被划分到不同VLAN后:
你可以把每个VLAN想象成不同的公司,没有"网关"(路由)的情况下,两个公司无法互通:
公司A的员工(192.168.10.100)想给公司B的员工(192.168.20.100)"寄信",会在交换机(公司门口)被拦下——因为交换机没有"路由指引",不认识其他VLAN的地址。
仅仅创建VLAN并分配端口,只能实现「VLAN内部通信」和「VLAN间隔离」。要实现跨VLAN互通,必须通过以下方式:
本文重点讲解最常用、最稳定的「三层交换机VLAN接口路由」方案。
某公司通过VLAN隔离部门流量,要求实现:
以下配置基于H3C三层交换机,核心是为每个VLAN创建「VLAN接口」并配置IP(网关),同时配置Trunk链路实现交换机互联。
步骤1:创建VLAN 100,将接入端口加入VLAN
<DeviceA> system-view
[DeviceA] vlan 100
[DeviceA-vlan100] port gigabitethernet 1/0/1
[DeviceA-vlan100] quit步骤2:创建VLAN 100接口,配置IP(部门A网关)
[DeviceA] interface Vlan-interface 100
[DeviceA-Vlan-interface100] ip address 192.168.1.1 24
[DeviceA-Vlan-interface100] quit步骤3:创建VLAN 200,将接入端口加入VLAN
[DeviceA] vlan 200
[DeviceA-vlan200] port gigabitethernet 1/0/2
[DeviceA-vlan200] quit步骤4:创建VLAN 200接口,配置IP(备用网关)
[DeviceA] interface Vlan-interface 200
[DeviceA-Vlan-interface200] ip address 192.168.2.2 24
[DeviceA-Vlan-interface200] quit步骤5:配置交换机互联端口为Trunk模式(允许VLAN 100/200通行)
[DeviceA] interface gigabitethernet 1/0/3
[DeviceA-GigabitEthernet1/0/3] port link-type trunk
[DeviceA-GigabitEthernet1/0/3] port trunk permit vlan 100 200
[DeviceA-GigabitEthernet1/0/3] quit步骤1:创建VLAN 100,将接入端口加入VLAN
<DeviceB> system-view
[DeviceB] vlan 100
[DeviceB-vlan100] port gigabitethernet 1/0/1
[DeviceB-vlan100] quit步骤2:创建VLAN 100接口,配置IP(备用网关)
[DeviceB] interface Vlan-interface 100
[DeviceB-Vlan-interface100] ip address 192.168.1.2 24
[DeviceB-Vlan-interface100] quit步骤3:创建VLAN 200,将接入端口加入VLAN
[DeviceB] vlan 200
[DeviceB-vlan200] port gigabitethernet 1/0/2
[DeviceB-vlan200] quit步骤4:创建VLAN 200接口,配置IP(部门B网关)
[DeviceB] interface Vlan-interface 200
[DeviceB-Vlan-interface200] ip address 192.168.2.1 24
[DeviceB-Vlan-interface200] quit步骤5:配置交换机互联端口为Trunk模式(允许VLAN 100/200通行)
[DeviceB] interface gigabitethernet 1/0/3
[DeviceB-GigabitEthernet1/0/3] port link-type trunk
[DeviceB-GigabitEthernet1/0/3] port trunk permit vlan 100 200
[DeviceB-GigabitEthernet1/0/3] quit完成上述配置后,可通过以下方式验证:
若配置后仍无法跨VLAN通信,可检查以下几点:
port trunk permit vlan命令)?