资源:
基于接口划分VLAN的ensp组网拓扑资源下载
基于MAC地址划分VLAN的ensp组网拓扑资源下载
逻辑上对局域网划分广播域,归属同一VLAN的PC可直接通信,归属不同VLAN的PC不能直接互通。
以太网帧格式:
IEEE 802.1Q是VLAN的正式标准,对以太网帧格式进行了修改,加入了4字节的802.1Q标记(Tag)
例:两台交换机,两台PC,交换机与PC直连接口为Access,透传VLAN10,交换机互联接口为Trunk,透传VLAN10,解析数据帧流向。
SW1配置:
vlan batch 10 20
interface Ethernet0/0/1
port link-type access
port default vlan 10
#
interface Ethernet0/0/2
port link-type trunk
port trunk allow-pass vlan 10
#
interface Ethernet0/0/3
port link-type access
port default vlan 20
SW2配置:
vlan batch 10
interface Ethernet0/0/1
port link-type access
port default vlan 10
#
interface Ethernet0/0/2
port link-type trunk
port trunk allow-pass vlan 10
假设PC1已知PC2的IP及MAC,PC1发送数据给PC2,数据帧过程如下:
注:本次组网为二层交换机组网,因此PC间互相通信需要保持VLAN一致
Ping测
PC1 Ping PC2,通;
PC1 Ping PC3 ,不通。
PC2 Ping PC3 ,不通。
资源:基于接口划分VLAN的ensp组网拓扑资源下载
例:公司A、B两部门,通过SW1接入公司网络,且接入的交换机端口不固定;
两台打印机Print1和Print2,通过SW2接入公司网络,且接入的交换机端口固定。
要求:通过设置VLAN,使Print1仅能被A部门访问,Print2仅能被B部门访问。
分析:
PC-A的MAC地址:00-00-00-00-00-A1
PC-B的MAC地址:00-00-00-00-00-B1
PC-C的MAC地址:00-00-00-00-00-C1
SW1配置:
由于PC-A及PC-B接入位置不固定,因此不做配置。
SW2配置:
vlan batch 10 20
interface Ethernet0/0/1
port link-type access
port default vlan 10
#
interface Ethernet0/0/2
port link-type access
port default vlan 20
#
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 10 20
SW3配置:
vlan batch 10 20
vlan 10
mac-vlan mac-address 0000-0000-00a1 priority 0
vlan 20
mac-vlan mac-address 0000-0000-00b1 priority 0
interface GigabitEthernet0/0/1
port hybrid untagged vlan 10 20
mac-vlan enable
#
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 10 20
gig 0/0/1
**mac-vlan enable:**
使能基于MAC地址划分VLAN功能。即:普通帧进入本接口后,会根据MAC-VLAN对应表,为该帧加上相应VLAN标记。
也就是说:
当源MAC为0000-0000-000A1的数据帧到达该接口后会为其添加VLAN10的标记;
同理,源MAC为0000-0000-000B1添加VLAN20标记;
而源MAC为0000-0000-000C1的则为其添加缺省VLAN的标记,即VLAN1。
**port hybrid untagged vlan 10 20:**
允许vlan 10 和 20的帧通过,并且将帧从该接口发出时,剥离VLAN标记。
Ping测
PC-A Ping Print1,通;
PC-A Ping Print2,不通;
PC-B Ping Print1,不通;
PC-B Ping Print2,通;
PC-C Ping Print1,不通;
PC-C Ping Print2,不通;
当PC-C的数据帧到达SW3的gig 0/0/1时,为其添加缺省VLAN的标记,即VLAN1,但是缺省VLAN不在gig 0/0/1允许通过的VLAN列表,所以该数据帧被丢弃。
资源:基于MAC地址划分VLAN的ensp组网拓扑资源下载