技术原理
VLAN是指在一个物理网段内,进行逻辑的划分,划分成若干个虚拟局域网。VLAN最大的特性是不受物理位置的限制,可以进行灵活的划分。
    VLAN具备了一个物理网段所具备的特性。相同VLAN内的主机可以相互直接通信,不同VLAN间的主机之间互相访问必须经由路由设备进行转发。
    广播数据包只可以在本VLAN内进行广播,不能传输到其他VLAN中。
Port VLAN是实现VLAN的方式之一,它利用交换机的端口进行VLAN的划分,一个端口只能属于一个VLAN。
 
Tag VLAN是基于交换机端口的另外一种类型,主要用于使交换机的相同VLAN内的主机之间可以直接访问,同时对于不同VLAN的主机进行隔离。
    Tag VLAN遵循IEEE802.1Q协议的标准。在使用配置了Tag VLAN的端口进行数据传输时,需要在数据帧内添加4个字节的802.1Q标签信息,
    用于标示该数据帧属于哪个VLAN,便于对端交换机收到数据帧后进行准确的过滤。

 

 
背景:仅仅pc2【销售部】与pc4【财务部】能够互通,其他不能通信。pc3【技术部&都不同通信】
 
 
 
左一)交换机配置如下:
Switch>enable
Switch#config term
Switch#config terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#inter f0/1
Switch(config-if)#exit
Switch(config)#vlan 10
Switch(config-vlan)#vlan 20            #创建vlan
Switch(config-vlan)#ip addre
Switch(config-vlan)#inter f0/1            #进入指定的端口
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 10
Switch(config-if)#inter f0/2
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 20
Switch(config-if)#inter f0/3
Switch(config-if)#switchport mode trunk
Switch(config-if)#

 

 
右翼)交换机配置如下:
 
Switch>enable
Switch#config ter
Switch#config terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 10
Switch(config)#inter f0/1
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 10
Switch(config-if)#inter f0/3
Switch(config-if)#switchport mode trunk
Switch(config-if)#

 

 
结果:
 
 
posted on 2020-05-14 21:16  topass123  阅读(320)  评论(0编辑  收藏  举报