vlan划分

1.为什么要进行VLAN划分
过大的广播域,造成带宽的浪费;
mac地址表过大,造成转发效率低;
不够安全;
一个VLAN=一个网段=一个广播域
2.VLAN如何来进行划分?
(1)静态划分:基于端口
(2)动态划分:基于mac地址
3.VLAN的范围:0——4095
其中0和4095是保留vlan。
交换机的默认所有端口都属于vlan1,vlan1不能被修改或者删除。
常用的vlan:2——1001(扩展vlan 1025——4094)
4.VLAN的划分命令
(1)第一步:创建vlan
SW1(config)#vlan 10 //创建vlan10
SW1(config-vlan)#name xiaoshou //命名为xiaoshou
SW1(config-vlan)#exit
SW1(config)#vlan 20
SW1(config-vlan)#name caiwubu
SW1(config-vlan)#exit
(2)第二步:把接口加入到vlan中
SW1(config)#int range f0/3 - 4 //进入接口,多个接口同时操作可以用range
SW1(config-if-range)#switchport mode access //接口模式为access
SW1(config-if-range)#switchport access vlan 20 //把接口加入到相应的vlan20中
(3)第三步:检查vlan的命令
SW1#show vlan brief
5.Trunk链路(中继链路):在一条物理链路上,可以承载多个vlan。
应用:设备之间(交换机之间;交换机和路由器之间)
(1)trunk的原理:把原始的数据帧加入了新的标签,破坏了原来的“帧格式”。——在trunk链路上传输的不是原始的数据帧。
(2)trunk链路标记vlan的方式:ISL(Cisco的私有协议,在帧的外边插入了30Byte);
IEEE 802.1 q(在数据帧的内部插入了4Byte;工业标准)。
(3)配置:
SW1(config)#int f0/5
SW1(config-if)#switchport mode trunk #把接口加入到trunk
SW1(config-if)#switchport trunk allowed vlan all #允许所有vlan通过
(4)查询命令:
SW4#show interfaces trunk #查看trunk链路
(5)对vlan进行过滤的命令:
SW1(config)#int f0/5
SW1(config-if)#switchport trunk allowed vlan ?
WORD VLAN IDs of the allowed VLANs when this port is in trunking mode
all all VLANs //允许所有vlan通过(白名单)
remove remove VLANs from the current list //从当前列表中移除某个vlan
except all VLANs except the following //从允许的列表中排除某个vlan(不允许通过)
none no VLANs //拒绝所有vlan通过(黑名单)
add add VLANs to the current list //这个列表的vlan允许通过
6.Native Vlan(本征vlan):在交换机中默认就是vlan1.
(1)交换机收到一个来自Native vlan的数据,会不打标签发送(原始数据帧);
(2)如果交换机收到一个原始数据帧,会把数据帧广播到Native vlan 的端口;
7.DTP协议(Dynamic Trunk Protocol):动态trunk协议,用来协商链路是否要成为trunk。
DTP协议的配置;
SW1(config-if)#switchport mode dynamic ?
auto Set trunking mode dynamic negotiation parameter to AUTO //自动协商
desirable Set trunking mode dynamic negotiation parameter to DESIRABLE //期望成为trunk
在协商过程中,trunk可以和trunk/desirable/auto
desirable和desirable/auto
access和任何一种也不能协商为trunk链路;两个auto也不能协商为trunk。
8.EtherChannel (以太通道):解决交换机之间链路的冗余问题,可以提高网络的高可用性;还可以增加带宽。
  interface  range  FastEthernet0/4  - 5
  channel-group 1 mode on        //把多个链路进行捆绑,编号为1
  switchport mode trunk           //设置为trunk链路
  SW2#do show etherchannel summary     //检查以太通道的命令,SU标准二层以太通道链路正常。

你可能感兴趣的:(网络笔记)