13-VLAN典型配置举例
本章节下载: 13-VLAN典型配置举例 (115.86 KB)
目 录
本章介绍了基于端口的VLAN典型配置举例。
表1 配置适用的产品与软件版本关系
产品 |
软件版本 |
S5830V2&S5820V2系列以太网交换机 |
Release2208P01,Release2210 |
如图1所示:
· 为了避免广播报文泛滥和通信的安全性,某公司网络中使用VLAN技术来隔离部门间的二层流量。其中部门A使用VLAN 100,部门B使用VLAN 200。
· 部门A的终端用户使用192.168.1.0/24 IP网段,各终端用户配置的网关地址为192.168.1.1;部门B的终端用户使用192.168.2.0/24 IP网段,各终端用户配置的网关地址为192.168.2.1;
现要求通过配置基于端口的VLAN和VLAN接口实现下面应用需求:
· 同一VLAN内的主机能够二层互通,不同VLAN内的主机不能二层互通,能够三层互通。
· 通过配置使Device A作为部门A中用户的网关,Device B作为部门B中用户的网关。
# 创建VLAN 100,并将Ten-GigabitEthernet 1/0/1加入VLAN 100。
<DeviceA> system-view
[DeviceA] vlan 100
[DeviceA-vlan100] port ten-gigabitethernet 1/0/1
[DeviceA-vlan100] quit
# 创建Vlan-interface 100,并配置其IP地址为192.168.1.1/24。
[DeviceA] interface Vlan-interface 100
[DeviceA-Vlan-interface100] ip address 192.168.1.1 24
[DeviceA-Vlan-interface100] quit
# 创建VLAN 200,并将Ten-GigabitEthernet 1/0/2加入VLAN 200。
[DeviceA] vlan 200
[DeviceA-vlan200] port ten-gigabitethernet 1/0/2
[DeviceA-vlan200] quit
# 创建Vlan-interface 200,并配置其IP地址为192.168.2.2/24。
[DeviceA] interface Vlan-interface 200
[DeviceA-Vlan-interface200] ip address 192.168.2.2 24
[DeviceA-Vlan-interface200] quit
# 为了使Device A上VLAN 100和VLAN 200的报文能发送给Device B,将Ten-GigabitEthernet 1/0/3的链路类型配置为Trunk,并允许VLAN 100和VLAN 200的报文通过,取消允许VLAN 1通过。
[DeviceA] interface ten-gigabitethernet 1/0/3
[DeviceA-Ten-GigabitEthernet1/0/3] port link-type trunk
[DeviceA-Ten-GigabitEthernet1/0/3] port trunk permit vlan 100 200
[DeviceA-Ten-GigabitEthernet1/0/3] undo port trunk permit vlan 1
[DeviceA-Ten-GigabitEthernet1/0/3] quit
(2) 配置Device B
# 创建VLAN 100,并将Ten-GigabitEthernet 1/0/1加入VLAN 100。
<DeviceB> system-view
[DeviceB] vlan 100
[DeviceB-vlan100] port ten-gigabitethernet 1/0/1
[DeviceB-vlan100] quit
# 创建Vlan-interface 100,并配置其IP地址为192.168.1.2/24。
[DeviceB] interface Vlan-interface 100
[DeviceB-Vlan-interface100] ip address 192.168.1.2 24
[DeviceB-Vlan-interface100] quit
# 创建VLAN 200,并将Ten-GigabitEthernet 1/0/2加入VLAN 200。
[DeviceB] vlan 200
[DeviceB-vlan200] port ten-gigabitethernet 1/0/2
[DeviceB-vlan200] quit
# 创建Vlan-interface 200,并配置其IP地址为192.168.2.1/24。
[DeviceB] interface Vlan-interface 200
[DeviceB-Vlan-interface200] ip address 192.168.2.1 24
[DeviceB-Vlan-interface200] quit
# 为了使Device A上VLAN 100和VLAN 200的报文能发送给Device B,将Ten-GigabitEthernet 1/0/3的链路类型配置为Trunk,并允许VLAN 100和VLAN 200的报文通过,取消允许VLAN 1通过。
[DeviceB] interface ten-gigabitethernet 1/0/3
[DeviceB-Ten-GigabitEthernet1/0/3] port link-type trunk
[DeviceB-Ten-GigabitEthernet1/0/3] port trunk permit vlan 100 200
[DeviceB-Ten-GigabitEthernet1/0/3] undo port trunk permit vlan 1
[DeviceB-Ten-GigabitEthernet1/0/3] quit
(1) 通过display vlan命令查看显示信息验证配置是否成功,以查看Device A上VLAN 100和VLAN 200的配置信息为例。
[DeviceA] display vlan 100
VLAN ID: 100
VLAN Type: static
Route Interface: configured
IP Address: 192.168.1.1
Subnet Mask: 255.255.255.0
Description: VLAN 0100
Name: VLAN 0100
Tagged Ports:
Ten-GigabitEthernet1/0/3
Untagged Ports:
Ten-GigabitEthernet1/0/1
[DeviceA] display vlan 200
VLAN ID: 200
VLAN Type: static
Route Interface: configured
IP Address: 192.168.2.2
Subnet Mask: 255.255.255.0
Description: VLAN 0200
Name: VLAN 0200
Tagged Ports:
Ten-GigabitEthernet1/0/3
Untagged Ports:
Ten-GigabitEthernet1/0/2
(2) Host A和Host C能够互相ping通。查看Host A的ARP表,表中有Host C的IP地址和MAC地址对应的ARP表项。查看Host C的ARP表,表中有Host A的IP地址和MAC地址对应的ARP表项。
(3) Host A和Host D能够互相ping通。查看Host A的ARP表,表中没有Host D的ARP表项。查看Host D的ARP表,表中也没有Host A的ARP表项。
#
vlan 100
#
vlan 200
#
interface Vlan-interface100
ip address 192.168.1.1 255.255.255.0
#
interface Vlan-interface200
ip address 192.168.2.2 255.255.255.0
#
interface Ten-GigabitEthernet1/0/1
port access vlan 100
#
interface Ten-GigabitEthernet1/0/2
port access vlan 200
#
interface Ten-GigabitEthernet1/0/3
port link-type trunk
undo port trunk permit vlan 1
port trunk permit vlan 100 200
#
· Device B
#
vlan 100
#
vlan 200
#
interface Vlan-interface100
ip address 192.168.1.2 255.255.255.0
#
interface Vlan-interface200
ip address 192.168.2.1 255.255.255.0
#
interface Ten-GigabitEthernet1/0/1
port access vlan 100
#
interface Ten-GigabitEthernet1/0/2
port access vlan 200
#
interface Ten-GigabitEthernet1/0/3
port link-type trunk
undo port trunk permit vlan 1
port trunk permit vlan 100 200
#
不同款型规格的资料略有差异, 详细信息请向具体销售和400咨询。H3C保留在没有任何通知或提示的情况下对资料内容进行修改的权利!