huawei 华为 交换机 配置 Dot1q 终结子接口实现跨设备 VLAN 间通信示例

组网需求

如图7-8所示,SwitchA和SwitchB分别下挂VLAN 10和VLAN 20的二层网络,SwitchA和SwitchB之间通过三层网络互通,三层网络采用OSPF协议。要求两个二层网络的PC实现二层隔离三层互通。

图 7-8 配置 Dot1q 终结子接口实现跨设备 VLAN 间通信示例组网图

配置思路

采用如下的思路配置通过子接口跨越三层网络通信:

  1. 配置接口所属的VLAN。

  2. 配置VLANIF接口的IP地址。

  3. 配置子接口的封装方式。

  4. 配置子接口允许通过的VLAN。

  5. 配置子接口的IP地址。

  6. 配置OSPF基本功能。

说明:

  • 子接口允许通过的VLAN不能在全局创建。
  • VCMP的角色是Client时,不能配置VLAN终结子接口。

操作步骤

步骤1 配置SwitchA

创建VLAN。

<HUAWEI> system-view

HUAWEI sysname SwitchA

SwitchA vlan batch 30

配置接口加入VLAN。

SwitchA interface gigabitethernet 0/0/2

SwitchA-GigabitEthernet0/0/2 port link-type trunk

SwitchA-GigabitEthernet0/0/2 port trunk allow-pass vlan 30

SwitchA-GigabitEthernet0/0/2 quit

配置VLANIF接口的IP地址。

SwitchA interface vlanif 30

SwitchA-Vlanif30 ip address 10.10.30.1 24

SwitchA-Vlanif30 quit

创建并配置子接口GE0/0/1.1。

SwitchA vcmp role silent

SwitchA interface gigabitethernet0/0/1

SwitchA-GigabitEthernet0/0/1 port link-type hybrid

SwitchA-GigabitEthernet0/0/1 quit

SwitchA interface gigabitethernet 0/0/1.1

SwitchA-GigabitEthernet0/0/1.1 dot1q termination vid 10

SwitchA-GigabitEthernet0/0/1.1 ip address 10.10.10.1 24

SwitchA-GigabitEthernet0/0/1.1 arp broadcast enable

SwitchA-GigabitEthernet0/0/1.1 quit

配置OSPF基本功能。

SwitchA router id 1.1.1.1

SwitchA ospf

SwitchA-ospf-1 area 0

SwitchA-ospf-1-area-0.0.0.0 network 10.10.10.0 0.0.0.255

SwitchA-ospf-1-area-0.0.0.0 network 10.10.30.0 0.0.0.255

SwitchA-ospf-1-area-0.0.0.0 return

步骤2 配置SwitchB

创建VLAN。

<HUAWEI> system-view

HUAWEI sysname SwitchB

SwitchB vlan batch 30

配置接口加入VLAN。

SwitchB interface gigabitethernet 0/0/1

SwitchB-GigabitEthernet0/0/1 port link-type trunk

SwitchB-GigabitEthernet0/0/1 port trunk allow-pass vlan 30

SwitchB-GigabitEthernet0/0/1 quit

配置VLANIF接口的IP地址。

SwitchB interface vlanif 30

SwitchB-Vlanif30 ip address 10.10.30.2 24

SwitchB-Vlanif30 quit

创建并配置子接口GE0/0/2.1。

SwitchB vcmp role silent

SwitchB interface gigabitethernet0/0/2

SwitchB-GigabitEthernet0/0/2 port link-type hybrid

SwitchB-GigabitEthernet0/0/2 quit

SwitchB interface gigabitethernet 0/0/2.1

SwitchB-GigabitEthernet0/0/2.1 dot1q termination vid 20

SwitchB-GigabitEthernet0/0/2.1 ip address 10.10.20.1 24

SwitchB-GigabitEthernet0/0/2.1 arp broadcast enable

SwitchB-GigabitEthernet0/0/2.1 quit

配置OSPF基本功能。

SwitchB router id 2.2.2.2

SwitchB ospf

SwitchB-ospf-1 area 0

SwitchB-ospf-1-area-0.0.0.0 network 10.10.20.0 0.0.0.255

SwitchB-ospf-1-area-0.0.0.0 network 10.10.30.0 0.0.0.255

SwitchB-ospf-1-area-0.0.0.0 return

步骤3 检查配置结果

SwitchA下挂的二层网络中PC上配置缺省网关为GE0/0/1.1接口的IP地址

10.10.10.1/24。SwitchA下挂的交换机允许VLAN 10通过。

SwitchB下挂的二层网络中PC上配置缺省网关为GE0/0/2.1接口的IP地址

10.10.20.1/24。SwitchB下挂的交换机允许VLAN 20通过。

配置完成后,两个二层网络的PC实现二层隔离三层互通。

----结束

配置文件

SwitchA的配置文件

sysname SwitchA

router id 1.1.1.1

vlan batch 30

interface Vlanif30

ip address 10.10.30.1 255.255.255.0

interface GigabitEthernet0/0/1

port link-type hybrid

interface GigabitEthernet0/0/1.1

dot1q termination vid 10

ip address 10.10.10.1 255.255.255.0

arp broadcast enable

interface GigabitEthernet0/0/2

port link-type trunk

port trunk allow-pass vlan 30

ospf 1

area 0.0.0.0

network 10.10.10.0 0.0.0.255

network 10.10.30.0 0.0.0.255

return

SwitchB的配置文件

sysname SwitchB

router id 2.2.2.2

vlan batch 30

interface Vlanif30

ip address 10.10.30.2 255.255.255.0

interface GigabitEthernet0/0/1

port link-type trunk

port trunk allow-pass vlan 30

interface GigabitEthernet0/0/2

port link-type hybrid

interface GigabitEthernet0/0/2.1

dot1q termination vid 20

ip address 10.10.20.1 255.255.255.0

arp broadcast enable

ospf 1

area 0.0.0.0

network 10.10.20.0 0.0.0.255

network 10.10.30.0 0.0.0.255

return

相关推荐
爱吃大芒果37 分钟前
鸿蒙 ArkTS 网络工程进阶:@ohos.net.http 模块下的长连接、超时与防内存泄漏实战
华为·harmonyos
FrameNotWork1 小时前
HarmonyOS 6.0 沉浸式状态栏与安全区域适配实战
华为·harmonyos
绝世番茄1 小时前
鸿蒙原生ArkTS布局方式之Stack+Opacity叠加淡入淡出深度解析
华为·harmonyos·鸿蒙
SelectDB1 小时前
Apache Doris 在 AgentLogsBench 中领先,支撑 Agent 可观测性生产负载
运维·数据库·agent
心中有国也有家1 小时前
鸿蒙Flutter开发环境从零搭建教程(Windows/macOS双平台·避坑版)
学习·flutter·华为·harmonyos
荣-2 小时前
从两天到十几分钟:一套 YT Crash 自动化分析工具完整工程复盘
大数据·运维·自动化
国服第二切图仔2 小时前
HarmonyOS APP《画伴梦工厂》开发第43篇-多模块架构设计——模块拆分与依赖管理
华为·harmonyos
酷炫的水壶2 小时前
使用memc-nginx和srcache-nginx模块构建高效透明的缓存机制
运维·nginx·缓存
心中有国也有家4 小时前
Flutter 鸿蒙适配第一步:从 hive 迁移到 hive\_ce
hive·学习·flutter·华为·harmonyos
姚不倒4 小时前
F5 SSL Profile 证书卸载深入篇
运维·网络协议·负载均衡·ssl·f5