阅读目录
- 单交换机实现VLAN
- 跨交换机实现VLAN
- 通过VTP管理VLAN
- 三层交换实现VLAN
- 单臂路由实现VLAN
- 实战:构建小型局域网
交换机(Switch)是一种用于电信号转发的网络设备,它可以为接入交换机的任意两个网络节点提供独享的电信号通路,最常见的交换机是以太网交换机,其他常见的还有电话语音交换机、光纤交换机等,交换机是集线器的升级替代产品,理论上讲交换机就是按照通信两端传输信息的需求,将需要的信息发送到目标设备上的网络组件.
交换机是一种交换式集线器,其基于MAC地址识别,能完成封装转发数据包功能的网络设备.交换机可以学习MAC地址,并把其存放在内部地址表中,通过在数据帧的始发者和目标接收者之间建立临时的交换路径,使数据帧直接由源地址到达目的地址.
交换机内部拥有一条很高带宽的背板总线和内部交换矩阵所有的端口都挂接在这条背板总线上控制电路收到数据包以后,处理端口会查找内存中的地址对照表以确定目的MAC地址的网卡NIC挂接在哪个端口上,通过内部交换矩阵迅速将数据包传送到目的端口目的MAC若不存在才广播到所有的端口,接收端口回应后交换机会学习新的地址,并把它添加入内部MAC地址表中.
关于交换机的分类
1.根据网络覆盖范围划分交换机:广域网交换机和局域网交换机
2.根据交换机端口结构划分交换机:固定端口交换机和模块化交换机
3.根据工作协议层划分交换机:二层交换机、三层交换机、四层交换机
4.根据支持网管功能划分交换机:网管型交换机和非网管理型交换机
5.根据传输介质划分交换机:以太网交换机、快速以太网交换机、ATM交换机、FDDI交换机、令牌环交换机
6.根据应用网络层次划分交换机:企业级交换机、校园网交换机、部门级交换机、工作组交换机、桌机交换机关于二层交换机
二层交换机是对应于OSI/RM的第二协议层来定义的,因为它只能工作在OSI/RM开放体系模型的第二层,即数据链路层.二层交换机依赖于链路层中的信息(如MAC地址)完成不同端口数据间的线速交换,一般应用于小型企业或中型以上企业网络的桌面层次.关于三层交换机
三层交换机是对应于OSI/RM开放体系模型的第三层,即网络层来定义的,也就是说这类交换机可以工作在网络层,它比第二层交换机更加高档,功能更加强.当网络规模较大时,可以根据特殊应用需求划分为小面独立的VLAN网段,以减小广播所造成的影响,通常这类交换机是采用模块化结构,以适应灵活配置的需要.
交换机的初始化
下面的命令方式将对交换机的基本配置,包括配置交换机主机名,特权模式密码,管理接口,IP地址等.
1.首先登陆思科交换机,并进入特权模式,并配置好主机名称,此处交换机名称配置为lyshark.
2.开启0号模块下的1-3号接口,配置交换机端口速率并启用指定端口.
3.配置交换机虚拟管理接口的名称,IP地址和子网掩码,并开启管理接口,方便远程维护.
4.配置好虚拟终端以及密码,并允许远程Telnet登陆.
若要关闭虚拟终端登陆功能,则需要执行以下命令,取消虚拟终端的登陆.
5.在全局模式下配置特权密码,如果明文与密文密码同时配置,则默认使用密文密码为准.
6.全部配置完成以后,可以使用running-config(查看内存配置数据),也可startup-config(查看RAM存储器配置).
7.以上配置内容,当交换机断电后数据也将会清空,我们可以使用以下命令对配置数据永久存储起来.
8.通过telnet客户端,连接192.168.1.10输入密码即可登陆交换机.
交换机常用参数
常用查询命令:
端口选择命令:
配置端口描述:
开启配置端口:
配置端口模式:
启用/禁用端口:
交换机实现VLAN
VLAN(Virtual Local Area Network),中文名为虚拟局域网,是一种使用交换机将局域网内的设备在逻辑上划分成一个个网段的技术,即在物理网络上进一步划分逻辑网络,VLAN可以突破地理位置的限制,完全基于实际管理需要来划分网络,例如在单个交换机内划分为不同的区域,不同区域之间无法互相通信,来实现相互隔离.
VLAN具有与普通局域网相同的属性,第二层的单播,多播和广播帧只能在相同的VLAN内转发,扩散,而不会直接进入其他VLAN中,因此同一个VLAN内的主机即使位于不同的交换机上,也可以互相访问,而不是同一VLAN的主机,即使连接在同一交换机上,也无法通过数据链路层互相访问.如果一个VLAN内的主机想访问另一个VLAN内的主机,必须通过一个三层设备,如路由器或三层交换机实现通信.
单交换机实现VLAN
如前所述,基于端口的VLAN属于静态VLAN,它是划分网络最简单,最有效和最常用的方法,下面将在单台交换机上配置静态VLAN,来实现两个网段的数据隔离,以下实验是一种网络拓扑中最简单的拓扑结构图,适合于小型办公网络,其实验拓扑图如下.
初始化配置: 初始化交换机,开启5个交换口,其他交换口关闭保证安全性.
创建VLAN区域: 创建两个VLAN区域,分别命名为vlan10为CaiWu部和vlan20为XiaoShou部两个部门,命令如下.
添加VLAN端口: 指定端口加入到新创建的VLAN中,将fa0/1-3号端口放到CaiWu,fa0/4-5号端口放到XiaoShou里.
测试环节: 最后分别给五台设备配置好IP地址,并通过ping命令测试联通性.
跨交换机实现VLAN
在实际的工作环境中,只在一台交换机上实现VLAN是远远不够的,通常需要跨越多台交换机实现VLAN划分网段,思科交换机通过使用Trunk干道端口的方式实现多台交换机数据共享,并实现跨交换机上的同一个VLAN之间的数据通信,其拓扑结构图如下.
配置两台交换机: 分别初始化两台交换机,重命名两个交换机名字,并分别在两台交换机上开启3个端口.
配置交换机Trunk: 配置Trunk干道通信,也就是将两台交换机互相连接,此处配置fa0/1接口为干道网络接口.
配置Switch0: 配置switch0交换机,创建Vlan10和Vlan20,并分别将两个主机PC0加入Vlan10将PC1加入到Vlan20.
配置Switch1: 配置switch1交换机,创建Vlan10和Vlan20,并分别将两个主机PC2加入Vlan10将PC3加入到Vlan20.
测试环节: 最后分别给五台设备配置好IP地址,并通过ping命令测试联通性.
通过VTP管理VLAN
如果网络中有多台交换机,每台交换机上有多个VLAN,此时采用传统方法在每台交换机上一个个配置VLAN不仅效率低而且增加了管理难度,为此思科开发了VTP技术来实现交换机之间自动实现数据的同步.
VTP它是VLAN中继协议,被称为VLAN链路聚集协议,它可以实现属于同一VTP域的交换机之间自动同步和传播VLAN信息,这样只需要在Server服务端添加VLAN信息,那么客户端将会自动同步,但需要注意的是同步时只能同步VLAN分组,至于端口的添加还得需要手动在每台交换机上添加,因为每一种交换机的接口数量都不太相同,故很难实现统一.
配置两台交换机: 分别初始化两台交换机,重命名两个交换机名字,并分别在两台交换机上开启3个端口.
配置交换机Trunk: 将两台交换机的fa0/1端口,配置成Trunk通信模式,同步数据使用.
配置Switch0: 在switch0上创建VTP管理域,设置名称为manage,密码为123123配置命令如下.
配置Switch1: 在switch1上创建VTP同步域,设置模式为client,密码为123123,配置命令如下.
创建VLAN配置: 在·Server端创建一些VLAN列表,并在Client客户端执行同步命令,即可实现同步数据.
测试环节: 最后分别给五台设备配置好IP地址,并通过ping命令测试联通性.
三层交换实现VLAN
如果要在不同的VLAN之间进行数据通信,则必须利用一个具有三层(网络层)功能的设备来实现,目前常用的设备有三层交换机和路由器,在组建大型网络时出于安全考虑,必须把局域网按照功能划分为一个个小的局域网,来保证安全性,这就使得VLAN技术得以运用,但有时候我们还需要实现跨网段通信,则三层交换机可以实现我们的需求.
虽然路由器可以完成不同网段之间跨网段通信,但是由于路由器端口数量有限,且路由速度慢,因此三层交换机就诞生了,三层交换机是指具有路由功能的交换机,也就是实现了二层的转发和三层的交换,其价格便宜性价比高,目前是组网的绝佳选择,以下是一个三层交换机组网小案例,不仅实现了VLAN的隔离,还可以实现跨网段通信.
配置二层交换(两台): 首先配置2个二层交换机,将fa0/1配成trunk,fa0/2配成vlan10,fa0/3配成vlan20.
配置三层交换机: 配置三层交换机,添加vlan10,vlan20 端口,并将fa0/1-2设置为trunk,供二层交换数据.
配置三层交换网关: 在三层交换机上,分别为每个虚拟子接口vlan10,vlan20配置一个网关地址.
客户机配置网关: 给每个客户机配置好IP地址和网关参数,并测试连通性,成功后则四个IP都能PING通.
单臂路由实现VLAN
单臂路由是指在路由器的一个物理接口上通过配置子接口的方式,实现原来相互隔离的不同VLAN之间的通信,子接口是在物理接口上衍生出来的逻辑接口,一个物理接口可以衍生出许多的逻辑接口.
一般路由器的物理接口数量有限,如果每个VLAN都使用一个物理接口进行连接,在网络中VLAN数量较多的情况下需要使用多台路由器才能实现VLAN之间的通信,而通过使用子接口可以在一个物理接口上容纳更多的VLAN,从而很好的解决了此问题.
配置交换机: 在交换机上创建虚拟局域网vlan10和vlan20,并将fa0/2-3端口加入到vlan10和vlan20中.
设置Trunk模式: 将交换机与路由器相连的端口设置为Trunk模式,此处设置交换机的fa0/1口为Trunk.
配置路由器: 在路由器的Fa0/0以太网接口上创建逻辑接口,并使用IEEE802.1Q协议封装.
客户机配置网关: 给每个客户机配置好IP地址和网关参数,并测试连通性,成功后则四个IP都能PING通.
实战:构建小型局域网
接下来将通过模拟器组件一个中小型网络拓扑结构,总共划分为4个区域,分别是办公区域(Vlan10),宿舍区域(Vlan20)这两个区域分别使用一台交换机来连接,剩下的管理区域(Vlan30),客户区域(Vlan40)放在一个交换机里,通过VLAN技术将其隔离开来,最后开启三层交换的路由转发功能,并实现跨区域通信,接下来看一下实验拓扑图.
配置核心交换机: 首先配置三层核心交换机 switch,创建VTP管理域以及创建VLAN.
配置办公区: 接着配置二层交换机 switch0,配置成VTP客户端,并将fa0/1端口配置成trunk模式.
配置宿舍区: 接着配置二层交换机 switch1,配置成VTP客户端,并将fa0/1端口配置成trunk模式.
配置管理/客户区: 接着配置二层交换机 switch2,配置成VTP客户端,并将fa0/1端口配置成trunk模式.
开启三层路由: 最后配置核心交换机Switch,并开启路由功能,分别为每个网段指定一个网关.
客户机配置网段: 给每个客户机配置好IP地址和网关参数,并测试连通性,成功后则IP都能PING通.
文章出处:https://www.cnblogs.com/LyShark/p/11199499.html