vlan间通信(单臂路由、多臂路由、三层交换)配置命令(思科+华为)

单臂路由

路由器单个接口配置多个子接口,打上vlan标签,模拟三层交换机的vlanif接口功能
image

描述 思科 华为
创建 VLAN vlan 10
vlan 20
vlan batch 10 20
设置 Access 接口并指定 VLAN int f0/1
no shutdown
switchport mode access
switchport access vlan 10
int f0/2
no shutdown
switchport mode access
switchport access vlan 20
int e0/1
port link-type access
port default vlan 10
int e0/2
port link-type access
port default vlan 20
设置 Trunk 接口并允许 VLAN 数据通过 int f0/3
no shutdown
switchport mode trunk
switchport trunk allow vlan all
int e0/3
port link-type trunk
port trunk allow-pass vlan all
路由器设置子接口 int g0/0/0
no shutdown
int g0/0/0.1
encapsulation dot1Q 10
ip add 192.168.10.254 255.255.255.0
encapsulation dot1Q 20
ip add 192.168.20.254 255.255.255.0
ip routing
int g0/0/0.10
dot1q termination vid 10
arp broadcast enable
ip address 192.168.10.254 24
int g0/0/0.20
dot1q termination vid 20
arp broadcast enable
ip address 192.168.20.254 24

多臂路由

路由器多个接口连接交换机,配置作为vlan网关地址,利用路由功能实现不同vlan间通信
image

描述 思科 华为
创建 VLAN vlan 10
vlan 20
vlan batch 10 20
设置 Access 接口并指定 VLAN int f0/1
no shutdown
switchport mode access
switchport access vlan 10
int f0/2
no shutdown
switchport mode access
switchport access vlan 20
int f0/3
no shutdown
switchport mode access
switchport access vlan 10
int f0/4
no shutdown
switchport mode access
switchport access vlan 20
int e0/1
port link-type access
port default vlan 10
int e0/2
port link-type access
port default vlan 20
int e0/3
port link-type access
port default vlan 10
int e0/4
port link-type access
port default vlan 20
设置路由器接口 IP int g0/0/0
no shutdown
ip add 192.168.10.254 255.255.255.0
int g0/0/1
no shutdown
ip add 192.168.20.254 255.255.255.0
int g0/0/0
ip add 192.168.10.254 24
int g0/0/1
ip add 192.168.20.254 24

三层交换机

创建vlan接口,配置接口楼地址为vlan网关地址,实现不同vlan间通信
image

描述 思科 华为
创建 VLAN vlan 10
vlan 20
vlan batch 10 20
设置 Access 接口并指定 VLAN int f0/1
no shutdown
switchport mode access
switchport access vlan 10
int f0/2
no shutdown
switchport mode access
switchport access vlan 20
int f0/3
no shutdown
switchport mode access
switchport access vlan 10
int f0/4
no shutdown
switchport mode access
switchport access vlan 20
int e0/1
port link-type access
port default vlan 10
int e0/2
port link-type access
port default vlan 20
int e0/3
port link-type access
port default vlan 10
int e0/4
port link-type access
port default vlan 20
设置 Trunk 接口并允许 VLAN 数据通过 int f0/3
no shutdown
switchport mode trunk
switchport trunk allow vlan all
int e0/3
port link-type trunk
port trunk allow-pass vlan all
设置三层交换机 VLAN 接口 vlan 10
vlan 20
int vlan 10
ip add 192.168.10.254 255.255.255.0
int vlan 20
ip add 192.168.20.254 255.255.255.0
vlan batch 10 20
int vlanif 10
ip add 192.168.10.254 24
int vlanif 20
ip add 192.168.20.254 24
启用 IP 路由 int f0/1
no shutdown
ip routing
/

vlan间通信(单臂路由、多臂路由、三层交换)配置命令(思科+华为)
https://xinhaojin.github.io/2024/11/20/vlan间通信(单臂路由、多臂路由、三层交换)配置命令(思科+华为)/
作者
xinhaojin
发布于
2024年11月20日
许可协议