2虚拟局域网VLAN.docx
《2虚拟局域网VLAN.docx》由会员分享,可在线阅读,更多相关《2虚拟局域网VLAN.docx(26页珍藏版)》请在冰豆网上搜索。
2虚拟局域网VLAN
虚拟局域网(VLAN)
毛斌
VLAN的概念及优势2
分隔广播域的方法有两种2
VLAN的优势2
VLAN的种类2
CISCO交换机VLAN的分配情况3
VLAN的基本配置4
VLAN数据库配置模式4
全局配置模式5
将端口分配到VLAN中的命令5
TRUNK概述6
VLAN的标识7
Nativenlan7
TRUNK的模式和协商8
TRUNK的配置8
其他配置9
TRUNK的排错步骤9
以太网通道的概念和作用9
PAGP和LACP10
以太网通道的配置11
以太网通道故障排除11
配置trunk,实现相同VLAN跨交换机通信实验12
本章重点:
A.VLAN和TRUNK的原理
B.配置VLAN和TRUNK
C.配置ethernetchannel
本章难点:
(一)VLAN的原理
(二)Ethernetchannel故障排查
VLAN的概念及优势
在传统的交换式以太网中,所有的用户都在同一个广播中,当网络规模较大时,广播包的数量会急剧增加,当广播包的数量占到总量的30%时,网络的传输效率将会明显下降。
分隔广播域的方法有两种
1.物理分隔,将网络从物理上划分为若干个小的虚拟网络,然后使用能隔离广播的路由设备将不同的网络连接起来实现通信。
、
物理分隔的缺点:
它会使得局域网的设计缺灵活性,例如连接在同一个交换机上的用户只能划分在一个网络中,而不能划分在多个不同的网络中。
2.逻辑分隔,将网络从逻辑上划分为若干个小的虚拟网络,即VLAN(虚拟局域网)
VLAN的优势
1.控制广播
2.增强网络的安全性
3.简化网络管理
VLAN的种类
1.静态VLAN
静态VLAN也称为基于端口的VLAN。
表态VLAN就是明确指定交换机的端口属于哪个VLAN,这就需要管理员手工配置。
当用户主机连接到交换机端口时,就被分配到了对应的VLAN中。
2.动态VLAN
动态VLAN的实现方法有多种,目前最普遍的实现方法是基于MAC地址的动态VLAN。
这种VLAN的划分方法最大优点就是当用户物理位置移动时,即从一个交换机换到其他交换机时,VLAN不用重新配置。
缺点是:
初始化时所有的用户都必须进行配置。
?
CISCO交换机VLAN的分配情况
不同的交换机支持的VLAN数目不同。
VLAN的基本配置
在交换机上基于端口的配置步骤:
(1)创建VLAN
(2)将交换机的端口加入到相应的VLAN中
(3)验证VLAN的配置
在CISCOIOS中创建VLAN有两种方法。
VLAN数据库配置模式
Switch#vlandatabase//进入VLAN配置状态
Switch(vlan)#vlanvlan-id[namevlan-name]//创建VLAN号以及VLAN名(可选)
Switch(vlan)#exit//退出
创建VLAN示例
Switch#vlandatabase
Switch(vlan)#vlan2nametest20
VLAN2added:
Name:
test20
Switch(vlan)#exit
APPLYcompleted.
Exiting....
全局配置模式
Switch(config)#vlanvlan-id//输入VLAN号,进入VLAN配置状态
Switch(config-vlan)#namevlan-name//输入一个VLAN名。
如果没有配置VLAN名,默认的名字是VLAN号前面用0填满四位数。
例如:
VLAN0004是VLAN4的默认名字。
全局配置模式创建VLAN实例
Switch(config)#vlan2
Switch(config-vlan)#nametest20
要删除VLAN,需要使用novlanvlan-id
Switch#vlandatabase
Switch(vlan)#novlan20
DeletingVLAN20...
Switch(vlan)#exit
APPLYcompleted.
Exiting....
将端口分配到VLAN中的命令
Switch(config)#interfaceinterface-id
Switch(config-if)#switchportmodeaccess
Switch(config-if)#switchportaccessvlanvlan-id
Switch(config-if)#noswitchportaccessvlanvlan-id
也可以同时将多个端口添加到某个VLAN中:
Switch(config)#interfacerangef0/1–10
Switch(config-if-range)#switchportaccessvlanvlan-id
Switch(config)#defaultinterfaceinterface-id还原接口到默认状态
验证VLAN的配置
Switch#showvlanbrief//查看VLAN信息
Switch#showvlanidvlan-id//查看某个VLAN信息
TRUNK概述
TRUNK的作用:
能够跨交换机通信能够让不同交换机上的相同VLAN进行通信.
在交换网络中,链路有两种类型:
接入链路与中继链路
1.接入链路:
通常属于一个VLAN。
主机与交换机之间连接的链路就是接入链路
2.中继链路:
可以承载多个VLAN,
3.TRUNK(干道中继)的作用:
就是使用同一个VLAN能够跨交换机通信
VLAN的标识
在以太网上实现中继,可使用如下两种封装类型。
1)ISL(交换机间链路)是CISCO私有的标记方法。
ISL报头封装26个字节,CRC(校验)尾部是4个字节,总共30字节。
2)IEEE802.1Q是公有的标记方法。
中继设备将4个字节的标记插入到数据帧内。
Nativenlan
Nativevlan是否802.1Q中的概念,ISL中没有NATIVEVLAN,也就是说ISL对TRUNK链路上的所有数据帧都进行VLAN标记
在CISCO交换机上,默认的NATIVEVLAN是VLAN1,但可以进行配置。
NATIVEVLAN的数据帧在TRUNK链路中是没有被标记的
TRUNK的模式和协商
自动协商是由DTP(动态中继协议)管理的。
DTP是CISCO专有,它同时支持ISL和802.1Q两种中继自动协商,但只能用于交换机之间的中继链路,不能用于交换机和路由器之间的中继链路。
CISCO交换机默认开启DTP协商
TRUNK的配置
配置步骤与命令
进入接口配置模式
Switch(config)#interfaceinterface-id
选择封装类型
Switch(config-if)#switchporttrunkencapsulation{isl|dot1q|negotiate}
将接口配置为Trunk
Switch(config-if)#switchportmode{dynamic{desirable|auto}|trunk|access}
指定NativeVLAN(可选)
Switch(config-if)#switchporttrunknativevlanvlan-id
其他配置
禁止Trunk传送某个VLAN的数据,删除这个VLAN:
Switch(config-if)#switchporttrunkallowedvlanremovevlan-id
允许Trunk传送某个VLAN的数据,添加这个VLAN:
Switch(config-if)#switchporttrunkallowedvlanaddvlan-id
默认允许全部VLAN的数据通过
查看接口模式、状态:
Switch#showinterfaceinterface-idswitchport
TRUNK的排错步骤
1.接口模式
2.封装类型
3.NATIVEVLAN
以太网通道
以太网通道的概念和作用
当交换机的端口速率全部一样,如果采用更换设备来增加带宽,导致成本增加。
所以一般采用第二种方法。
(交换机间增加链路)来提高链路带宽。
CISCO提供了一种增加链路带宽的方法:
捆绑(聚合)金条平行链路,即以太网通道技术。
作用是:
通过两条或多条链路相连,将这两条链路捆绑成为以太网通道,实现负载均衡,提高链路带宽,并且能够备份
以太网最大可以捆绑八条物理链路,其中物理链路可以是双绞线的,也可以是光纤连接的。
配置以太网通道的注意事项:
PAGP和LACP
CISCO交换机提供了两种进行协商以太网通道协议:
端口聚合协议(PAGP)和链路聚合控制协议(LACP)
PAgP(端口聚合协议)
Cisco私有以太网通道协议
PAgP模式
开启(On)
关闭(Off)
自动(Auto)
企望(Desirable)
LACP(链路聚合控制协议)
IEEE802.3ad标准协议
LACP模式
开启(On)
关闭(Off)
被动(Passive)
主动(Active)
以太网通道的配置
配置PAgP以太网通道
Switch(config-if)#interfaceinternet-id
Switch(config-if)#channel-protocolpagp
Switch(config-if)#channel-groupnumbermode{on|auto|desirable}
配置LACP以太网通道
Switch(config-if)#interfaceinternet-id
Switch(config-if)#channel-protocollacp
Switch(config-if)#channel-groupnumbermode{on|passive|active}
Showetherchannelsummary命令查看以太网通道的状态
以太网通道故障排除
配置以太网通道的注意事项:
1.在每个以太网通道中,Cisco交换机最多允许捆绑8个端口
2.在一个以太网通道中,两端的端口必须使用相同协议
3.所有参与捆绑的端口的物理参数设置必须相同
4.一个端口只能在一个以太网通道中
5.一个以太网通道中的端口如果是中继模式,则端口的中继模式、6。
6.中继封装以及准许VLAN的范围必须相同
7.参与捆绑的端口必须属于同一个VLAN
8.在配置以太网通道时,尽量让以太网通道中的端口配置为TRUNK模式
配置trunk,实现相同VLAN跨交换机通信实验
实验需求:
1.使用VLAN技术可以将整个网络从逻辑上划分为若干个小的虚拟局域网,并且保证不同的VLAN之间不能进行访问。
2.使用以太网通道进行带宽扩容
实验思路:
(1)在PC上配置IP
(2)在交换机上添加VLAN
(3)配置交换机的IP地址(这里是配置交换机的管理地址)
(4)配置以太网通道
(5)验证相同VLAN的主机可以通信,不同VLAN的主机不能通信,交换机的IP地址通信正常
Router1F0/0<---->Switch1F0/1
Router2F0/0<---->Switch1F0/2
Router3F0/0<---->Switch2F0/1
Router4F0/0<---->Switch2F0/2
Router5F0/0<---->Switch3F0/1
Router6F0/0<---->Switch3F0/2
Switch1F0/14<---->Switch2F0/14
Switch1F0/15<---->Switch2F0/15
Switch2F0/12<---->Switch3F0/12
Switch2F0/13<---->Switch3F0/13
网络规划:
PC1和PC3为CWB,属于VLAN2,IP地址分别为PC1:
192.168.0.2/24PC3:
192.168.0.3/24
PC2和PC5为SXB,属于VLAN3,IP地址分别为PC2:
192.168.1.2/24PC2:
192.168.1.3/24.
PC4和PC6为SCB,属于VLAN4,IP地址分别PC4:
192.168.2.2/24PC6:
192.168.2.3/24
pc1#showrun
Buildingconfiguration...
Currentconfiguration:
554bytes
!
version12.4
servicetimestampsdebugdatetimemsec
servicetimestampslogdatetimemsec
noservicepassword-encryption
!
hostnamepc1
!
boot-start-marker
boot-end-marker
!
!
noaaanew-model
memory-sizeiomem5
!
!
ipcef
noipdomainlookup
interfaceFastEthernet0/0
ipaddress192.168.0.2255.255.255.0//给接口配置IP地址
duplexauto
speedauto
!
iphttpserver
noiphttpsecure-server//禁止域名解析
!
!
control-plane
!
!
linecon0//进入con口
exec-timeout00//防止超时
loggingsynchronous//同步
lineaux0
linevty04
!
!
end
pc2#showrun
Buildingconfiguration...
Currentconfiguration:
554bytes
!
version12.4
servicetimestampsdebugdatetimemsec
servicetimestampslogdatetimemsec
noservicepassword-encryption
!
hostnamepc2
!
boot-start-marker
boot-end-marker
!
!
noaaanew-model
memory-sizeiomem5
!
!
ipcef
noipdomainlookup
interfaceFastEthernet0/0
ipaddress192.168.1.2255.255.255.0
duplexauto
speedauto
!
iphttpserver
noiphttpsecure-server
!
!
control-plane
!
!
linecon0
exec-timeout00
loggingsynchronous
lineaux0
linevty04
!
!
end
pc3#showrun
Buildingconfiguration...
Currentconfiguration:
554bytes
!
version12.4
servicetimestampsdebugdatetimemsec
servicetimestampslogdatetimemsec
noservicepassword-encryption
!
hostnamepc3
!
boot-start-marker
boot-end-marker
!
!
noaaanew-model
memory-sizeiomem5
!
!
ipcef
noipdomainlookup
!
interfaceFastEthernet0/0
ipaddress192.168.0.3255.255.255.0
duplexauto
speedauto
!
iphttpserver
noiphttpsecure-server
!
!
control-plane
!
!
linecon0
exec-timeout00
loggingsynchronous
lineaux0
linevty04
!
!
end
pc4#showrun
Buildingconfiguration...
Currentconfiguration:
554bytes
!
version12.4
servicetimestampsdebugdatetimemsec
servicetimestampslogdatetimemsec
noservicepassword-encryption
!
hostnamepc4
!
boot-start-marker
boot-end-marker
!
!
noaaanew-model
memory-sizeiomem5
!
!
ipcef
noipdomainlookup
!
interfaceFastEthernet0/0
ipaddress192.168.2.2255.255.255.0
duplexauto
speedauto
!
iphttpserver
noiphttpsecure-server
!
control-plane
!
linecon0
exec-timeout00
loggingsynchronous
lineaux0
linevty04
!
!
end
pc5#showrun
Buildingconfiguration...
Currentconfiguration:
554bytes
!
version12.4
servicetimestampsdebugdatetimemsec
servicetimestampslogdatetimemsec
noservicepassword-encryption
!
hostnamepc5
!
boot-start-marker
boot-end-marker
!
!
noaaanew-model
memory-sizeiomem5
!
!
ipcef
noipdomainlookup
!
!
interfaceFastEthernet0/0
ipaddress192.168.1.3255.255.255.0
duplexauto
speedauto
!
iphttpserver
noiphttpsecure-server
!
control-plane
!
linecon0
exec-timeout00
loggingsynchronous
lineaux0
linevty04
!
!
end
pc6#showrun
Buildingconfiguration...
Currentconfiguration:
554bytes
!
version12.4
servicetimestampsdebugdatetimemsec
servicetimestampslogdatetimemsec
noservicepassword-encryption
!
hostnamepc6
!
boot-start-marker
boot-end-marker
!
!
noaaanew-model
memory-sizeiomem5
!
!
ipcef
noipdomainlookup
!
interfaceFastEthernet0/0
ipaddress192.168.2.3255.255.255.0
duplexauto
speedauto
!
iphttpserver
noiphttpsecure-server
!
control-plane
!
linecon0
exec-timeout00
loggingsynchronous
lineaux0
linevty04
!
!
end
sw1#showrun
Buildingconfiguration...
Currentconfiguration:
1147bytes
!
version12.4
servicetimestampsdebugdatetimemsec
servicetimestampslogdatetimemsec
noservicepassword-encryption
!
hostnamesw1
!
boot-start-marker
boot-end-marker
!
!
noaaanew-model
memory-sizeiomem5
!
!
ipcef
noipdomainlookup
!
!
interfacePort-channel1
switchportmodetrunk
!
interfaceFastEthernet0/0
!
interfaceFastEthernet0/1//把接口配置为加入到VLAN
switchportaccessvlan2
!
interfaceFastEthernet0/2
switchportaccessvlan3
!
interfaceFastEthernet0/3
!
interfaceFastEthernet0/4
!
interfaceFastEthernet0/5
!
interfaceFastEthernet0/6
!
interfaceFastEthernet0/7
!
interfaceFastEthernet0/8
!
interfaceFastEthernet0/9
!
interfaceFastEthernet0/10
!
interfaceFastEthernet0/11
!
interfaceFastEthernet