最佳答案
您好,请知:
可以使用基于子网的方式划分VLAN,以下是配置举例,请参考:
如图1-9所示,办公区的主机属于不同的网段192.168.5.0/24和192.168.50.0/24,Device C在收到来自办公区主机的报文时,根据报文的源IP地址,使来自不同网段主机的报文分别在指定的VLAN中传输。
图1-9 基于IP子网的VLAN组网图
创建VLAN100、VLAN200,配置子网与VLAN的关联关系,并配置端口与VLAN的关联关系。
<DeviceC> system-view
# 配置子网192.168.5.0/24与VLAN 100关联。
[DeviceC] vlan 100
[DeviceC-vlan100] ip-subnet-vlan ip 192.168.5.0 255.255.255.0
[DeviceC-vlan100] quit
# 配置子网192.168.50.0/24与VLAN 200关联。
[DeviceC] vlan 200
[DeviceC-vlan200] ip-subnet-vlan ip 192.168.50.0 255.255.255.0
[DeviceC-vlan200] quit
# 配置端口GigabitEthernet 1/0/11,使其允许通过VLAN 100的报文。
[DeviceC] interface gigabitethernet 1/0/11
[DeviceC-GigabitEthernet1/0/11] port link-type hybrid
[DeviceC-GigabitEthernet1/0/11] port hybrid vlan 100 tagged
Please wait... Done.
[DeviceC-GigabitEthernet1/0/11] quit
# 配置端口GigabitEthernet 1/0/12,使其允许通过VLAN 200的报文。
[DeviceC] interface gigabitethernet 1/0/12
[DeviceC-GigabitEthernet1/0/12] port link-type hybrid
[DeviceC-GigabitEthernet1/0/12] port hybrid vlan 200 tagged
Please wait... Done.
[DeviceC-GigabitEthernet1/0/12] quit
# 配置端口GigabitEthernet 1/0/1,使其和基于IP子网的VLAN 100、VLAN 200关联。
[DeviceC] interface gigabitethernet 1/0/1
[DeviceC-GigabitEthernet1/0/1] port link-type hybrid
[DeviceC-GigabitEthernet1/0/1] port hybrid vlan 100 200 untagged
Please wait... Done.
[DeviceC-GigabitEthernet1/0/1] port hybrid ip-subnet-vlan vlan 100
[DeviceC-GigabitEthernet1/0/1] port hybrid ip-subnet-vlan vlan 200
[DeviceC-GigabitEthernet1/0/1] return
# 查看所有VLAN的IP子网信息。
<Device C> display ip-subnet-vlan vlan all
VLAN ID: 100
Subnet Index IP Address Subnet Mask
====================================================
0 192.168.5.0 255.255.255.0
VLAN ID: 200
Subnet Index IP Address Subnet Mask
====================================================
0 192.168.50.0 255.255.255.0
# 查看端口GigabitEthernet 1/0/1上所配置的IP子网VLAN信息。
<DeviceC> display ip-subnet-vlan interface gigabitethernet 1/0/1
Interface: GigabitEthernet1/0/1
VLAN ID Subnet-Index IP ADDRESS NET MASK
=======================================================
100 0 192.168.5.0 255.255.255.0
200 0 192.168.50.0 255.255.255.0
基于IP子网的VLAN只对Hybrid端口配置才有效。
在完成上述配置后,在任意视图下执行display命令可以显示配置后VLAN的运行情况,通过查看显示信息验证配置的效果。
在用户视图下执行reset命令可以清除接口统计信息。
表1-13 VLAN显示和维护
操作 | 命令 |
显示VLAN相关信息 | display vlan [ vlan-id1 [ to vlan-id2 ] | all | dynamic | reserved | static ] [ | { begin | exclude | include } regular-expression ] |
显示VLAN接口相关信息 | display interface [ vlan-interface ] [ brief [ down ] ] [ | { begin | exclude | include } regular-expression ] display interface vlan-interface vlan-interface-id [ brief ] [ | { begin | exclude | include } regular-expression ] |
显示设备上当前存在的Hybrid或Trunk端口 | display port { hybrid | trunk } [ | { begin | exclude | include } regular-expression ] |
显示MAC-VLAN表项 | display mac-vlan { all | dynamic | mac-address mac-address [ mask mac-mask ] | static | vlan vlan-id } [ | { begin | exclude | include } regular-expression ] |
显示所有使能了MAC VLAN功能的接口 | display mac-vlan interface [ | { begin | exclude | include } regular-expression ] |
显示指定VLAN上配置的协议信息及协议的索引 | display protocol-vlan vlan { vlan-id [ to vlan-id ] | all } [ | { begin | exclude | include } regular-expression ] |
显示指定端口上已配置的协议VLAN的相关信息 | display protocol-vlan interface { interface-type interface-number [ to interface-type interface-number ] | all } [ | { begin | exclude | include } regular-expression ] |
显示指定VLAN上配置的IP子网VLAN信息及IP子网的索引 | display ip-subnet-vlan vlan { vlan-id1 [ to vlan-id2 ] | all } [ | { begin | exclude | include } regular-expression ] |
显示指定端口上配置的IP子网VLAN信息及IP子网的索引 | display ip-subnet-vlan interface { interface-list | all } [ | { begin | exclude | include } regular-expression ] |
清除接口的统计信息 | reset counters interface vlan-interface [ vlan-interface-id ] |
(1)
暂无评论
亲~登录后才可以操作哦!
确定你的邮箱还未认证,请认证邮箱或绑定手机后进行当前操作
举报
×
侵犯我的权益
×
侵犯了我企业的权益
×
抄袭了我的内容
×
原文链接或出处
诽谤我
×
对根叔社区有害的内容
×
不规范转载
×
举报说明
暂无评论