Presentation is loading. Please wait.

Presentation is loading. Please wait.

陈开恒 khchen69@mail.ustc.edu.cn 交换机及 虚拟局域网 组网技术 陈开恒 khchen69@mail.ustc.edu.cn.

Similar presentations


Presentation on theme: "陈开恒 khchen69@mail.ustc.edu.cn 交换机及 虚拟局域网 组网技术 陈开恒 khchen69@mail.ustc.edu.cn."— Presentation transcript:

1 陈开恒 khchen69@mail.ustc.edu.cn
交换机及 虚拟局域网 组网技术 陈开恒

2 交换机简介 本质——链路的逻辑拓展 交换机是基于mac来工作,可以隔离冲突域不可以隔离广播域。 冲突域
冲突域是数据必然发送到的区域。HUB组成的网络是一个冲突域。交换机的一个接口下的网络是一个冲突域,所以交换机可以隔离冲突域。 广播域   广播数据时可以发送到的区域是一个广播域。 交换机对广播帧是透明的,由交换机组成的网络是一个广播域。路由器的一个接口下的网络是一个广播域。所以路由器可以隔离广播域。

3 交换机的工作原理 交换机的作用: 交换机对帧的处理:
维护CAM表(context address memory),该表是交换机的端口和各计算机MAC的映射表。 根据CAM表进行数据帧的转发。 交换机对帧的处理: 交换机收到帧后,查询CAM表,如果查询不到目的计算机所在的端口,交换机把帧从源端口以外的端口转发。否则转b 交换机收到帧后,查询CAM表。如果目的端口不是计算机接收帧的源端口,对帧进行转发。否则转c 如果目的端口和源端口是同一端口,丢弃该帧。

4 两层交换机和三层交换机 两层交换机运行在数据链路层,三层交换机简单来讲即是是一个带有第三层路由功能的第二层交换机 。 三层交换原理: 假设两个使用IP协议的站点A、B通过第三层交换机进行通信,发送站点A在开始发送时,把自己的IP地址与B站的IP地址比较,判断B站是否与自己在同一子网内。若目的站B与发送站A在同一子网内,则进行二层的转发。 若两个站点不在同一子网内,如发送站A要与目的站B通信,发送站A要向“缺省网关”发出ARP(地址解析)封包。如果交换机在以前的通信过程中已经知道B站的MAC地址,则向发送站A回复B的MAC。

5 否则交换机根据路由信息向B站广播一个ARP请求,B站得到此ARP请求后向回复其MAC地址,交换机保存此地址并回复给发送站A,同时将B站的MAC地址发送到二层交换MAC地址表中。从这以后,当A向B发送的数据包便全部交给二层交换处理。由于仅仅在路由过程中才需要三层处理,绝大部分数据都通过二层交换转发,因此三层交换机的速度很快,接近二层交换机的速度。 Note: 局域网必须通过路由器与公网实现跨地域互联 三层交换机不具有同时处理多个协议的能力

6 简单交换机互连 三台终端通过交换机互连 终端IP地址分别为 192.168.1.1 192.168.1.2 192.168.1.3
测试连通性 仿真软件下载地址 System experiment 实验仿真软件.exe

7 VLAN的应用背景及实现功能 VLAN——Virtual Local Area Network 【背景描述】
某企业有两个主要部门:技术部(A1、A3)和销售部(A2、B1、B2),其中销售部门的个人计算机系统分散连接,也就有一名销售部的工作人员在技术部的办公室,他的电脑连接在技术部的交换机上。技术部之间、销售部之间需要相互进行通信,但为了数据安全起见,技术部和销售部需要进行相互隔离。 【拓扑图如下:】

8 技术需求 同一个部门的主机在同一个局域网上,并且部门内的数据流量不希望其他部门收到,也不希望干扰其他部门,也就是要求同一个部门在同一个“广播域”上。 显然对于以上的物理拓扑,所有主机通过交换机相连,处在同一个广播域(没有划分VLAN的交换机上的各个端口上的设备分别属于不同的冲突域,每一交换端口构成一个冲突域,但同属于一个广播域)。如A1和A3之间的广播,A2、B1、B2也会收到,这不是我们所希望的。

9 不加限制,会产生广播风暴问题 …… 广播

10 需求导致了VLAN的产生 需要有一种办法,在尽量不改动网络固有配置的前提下,通过灵活的、标准的、基于软件的做法将具有相同需求的用户放到一起,使之就象在一个LAN中那样工作。 它不但能够在物理上使网络延伸,还能使对网络实施更灵活强大的控制功能成为可能。 VLAN的出现使之成为可能。

11 VLAN简介 冲突域和广播域 VLAN的主要优点
交换机能隔离冲突域,但不能隔离广播域,通过多个交换机连接在一起的所有计算机都在一个广播域中,任何一台计算机发送的广播包,其他计算机都会收到,这样大大降低了带宽的利用率。 VLAN(Virtual LAN)可以隔离广播域,VLAN工作在OSI模型的第2层,是交换机端口的逻辑组合。 VLAN的主要优点 广播风暴防范 安全 性能提高 提高管理效率

12 VLAN的划分 基于端口的VLAN 基于MAC地址的VLAN
在这种定义方法中,某个交换机上的端口(例如端口1、3、5)构成VLAN A,而该交换机上的其他端口构成VLAN B。早期基于端口的VLAN成员只能位于一个交换机中。第二代基于端口的VLAN支持多个交换机,例如交换机X上的端口1和端口2与交换机Y上的端口3和端口4构成一个VLAN。 基于MAC地址的VLAN 在这种定义方法中,若干个MAC地址构成VLAN成员。用户属于哪个VLAN由其网卡中的MAC地址决定。

13 Trunk简介 VLAN可以把在同一个交换机上端口组合成一个VLAN,也可以不同交换机上的端口组合成一个VLAN。当一个VLAN跨过不同的交换机时,在同一个VLAN上但是接在不同的交换机上的计算机如何实现通信? VLAN 2 VLAN 1 VLAN 2 VLAN 1

14 VLAN标记技术 直观的方法是为每一个VLAN增加连线,这样多个VLAN会占用太多接口。
可以采用Trunk技术实现跨交换机的VLAN内通信,Trunk技术使得在一条物理线路上可以传递多个VLAN的信息。 为了区别多个VLAN的数据帧,需要某种标记技术。有两种常见的Trunk帧标记技术:ISL和IEEE 802.1Q。 ISL技术在原有的帧上重新加了一个帧头,并重新生产了帧校验序列(FCS)。ISL是思科特有的技术。 IEEE 802.1Q技术是在原有帧的源MAC地址字段后插入4字节的标记字段,同时用新的CRC字段替代了原有的CRC字段。IEEE 802.1Q是国际标准。

15 采用ISL的Trunk 使用ASIC执行 对计算机透明,计算机看不到ISL头部 可以在交换机与交换机之间、交换机与路由器之间使用

16 ISL帧格式 封装技术(Encapsulated) 协议无关的(Protocol independent) 将原有的帧封装在新的帧中

17 采用802.1Q的Trunk

18 802.1Q帧格式 标记技术(Tagged) 协议相关的(Protocol dependent) 在原有帧中添加一个字段

19 采用Trunk技术实现了VLAN的跨计算机通信
以太网帧 带有VLAN 2标签的以太网帧 VLAN 1 VLAN 2

20 DTP(Dynamic Trunk Protocol)简介
管理员可以手动指定交换机之间的链路是否形成Trunk,也可以让交换机自动协商,这个协议称为DTP,DTP还可以协商Trunk链路的封装类型。 配置了DTP的交换机会发送DTP协商包,或者对对方发送来的DTP包进行响应,双方最终商讨他们之间的链路是否形成Trunk,以及采用什么样的Trunk封装方式。 Cisco网络设备支持动态协商端口的工作状态。 根据动态协议的实现方式,Cisco网络设备接口有多种不同的工作模式。

21 交换机接口模式 cisco网络中,交换机在局域网中最终稳定状态的接口类型主要有四种:access / trunk / multi / dot1q-tunnel。 1、access: 主要用来接入终端设备,如PC机、服务器、打印服务器等。 2、trunk: 主要用在连接其它交换机,以便在线路上承载多个VLAN。 3、multi: 在一个线路中承载多个vlan,但不像trunk,它不对承载的数据打标签。主要用于接入支持多vlan的服务器或者一些网络分析设备。现在基本不使用此类接口,在Cisco的网络设备中,也基本不支持此类接口了。 4、dot1q-tunnel: 用在Q-in-Q隧道配置中。

22 Cisco交换机接口模式的设置 1、switchport mode access:强制接口成为access接口,并且可以与对方主动进行协商,诱使对方成为access模式。 2、switchport mode trunk:强制接口成为trunk接口,并且主动诱使对方成为trunk模式,所以当邻居交换机接口为trunk/desirable/auto时会成为Trunk接口。 3、switchport mode dynamic desirable:主动协商建立trunk,发送并接收DTP信号。如果邻居交换机模式为trunk/desirable/auto之一,则接口将变成trunk接口。如果不能形成trunk模式,则工作在access模式。 4、switchport mode dynamic auto:被动协商建立trunk,只接收不发送DTP信号。当邻居接口为trunk/desirable之一时,才会成为trunk。如果不能形成trunk模式,则工作在access模式。 5、switchport nonegotiate:严格的说,这不算是种接口模式,它的作用只是阻止交换机接口发出DTP数据包,它必须与switchport mode trunk或者switchport mode access一起使用。 6、switchport mode dot1q-tunnel:配置交换机接口为隧道接口(非trunk),以便与用户交换机的trunk接口形成不对称链路。

23 VLAN实验 【实验目的】 【实验环境】:模拟软件 Cisco Packet Tracer 5.2 了解VLAN交换机的特性与应用场合
该软件支持大量的设备仿真模型:路由器、交换机、无线网络设备、服务器、各种连接电缆、终端等,还能仿真各种模块,这在实际实验设备中是无法配置齐全的。 对设备均提供图型化和终端两种配置方法,各设备模型均有可视化的外观仿真。

24 VLAN实验内容 实验器材:3560交换机2台,PC机5台,连接线若干。 网络拓扑图如下:
图中:A1、A2、A3连接在Switch1上,B1、B2连接在Switch2上。 假定应用场景是A1、A3属于技术部,B1、B2、A2属于销售部,要求同一部门的主机在同一个局域网上。

25 VLAN实验内容 交换机端口连接配置 主机IP地址配置 Switch1 Interfaces Switch2 Interfaces From
To FastEthernet 0/1 A1 B1 FastEthernet 0/2 A2 B2 FastEthernet 0/3 A3 FastEthernet 0/11 Switch1, FastEthernet 0/11 Switch2, FastEthernet 0/11 主机IP地址配置 PC主机 IP地址 子网掩码 A1 A2 A3 B1 B2

26 配置各台主机 配置主机IP地址 配置完主机IP地址,回答【问题1】:
点击 主机 图标,在弹出的窗口中,点击“Desktop”选项卡,在“IP Configuration”里直接配置IP地址和子网掩码。 或者在“Command Prompt”里,输入命令 ipconfig ip_addr net_mask 配置完主机IP地址,回答【问题1】: 每台主机相互ping,查看哪些主机可以连通,哪些不可以?为什么? 注:可以用 ping -n 发起一个受限广播,(参数 -n 1指明只发送一次,免得默认发送4次受到干扰),观察都收到了哪些主机的回复?

27 Switch1, port1; Switch2, port2, 3
在交换机上配置VLAN VLAN配置如下: VLAN num VLAN name Switch port 2 tech Switch1, port 2, 3 3 sales Switch1, port1; Switch2, port2, 3 点击 交换机 图标,在弹出的窗口中,点击“CLI”,进入交换机配置终端。

28 在Switch上创建VLAN 在Switch1上创建VLAN 进入特权模式: 进入VLAN配置模式: 进入全局设置模式
Switch>enable 进入VLAN配置模式: Switch#vlan database Switch(vlan)#vlan 2 name tech Switch(vlan)#vlan 3 name sales Switch(vlan)#exit 进入全局设置模式 Switch#configure terminal

29 在Switch上创建VLAN 将Switch1的各端口划分在VLAN中
Switch(config)#interface FastEthernet 0/1 Switch(config-if)#switchport mode access Switch(config-if)#switchport access vlan 2 Switch(config-if)#interface FastEthernet 0/2 Switch(config-if)#switchport access vlan 3 Switch(config-if)#interface FastEthernet 0/3

30 在Switch上创建VLAN 配置与Switch2连接的Trunk接口 在Switch2上创建VLAN
Switch(config-if)#interface FastEthernet 0/11 Switch(config-if)#switchport mode trunk 在Switch2上创建VLAN Switch>enable Switch#vlan database Switch(vlan)#vlan 3 name sales Switch(vlan)#exit Switch#configure terminal

31 在Switch上创建VLAN 将Switch2的各端口划分在VLAN中 配置与Switch1连接的Trunk接口
Switch(config)#interface FastEthernet 0/1 Switch(config-if)#switchport mode access Switch(config-if)#switchport access vlan 3 Switch(config-if)#interface FastEthernet 0/2 配置与Switch1连接的Trunk接口 Switch(config-if)#interface FastEthernet 0/11 Switch(config-if)#switchport mode trunk

32 实验结果 在Switch1上用 show vlan 查看VLAN信息 VLAN Name Status Ports
1 default active Fa0/4, Fa0/5, Fa0/6, Fa0/7 Fa0/8, Fa0/9, Fa0/10, Fa0/12 Fa0/13, Fa0/14, Fa0/15, Fa0/16 Fa0/17, Fa0/18, Fa0/19, Fa0/20 Fa0/21, Fa0/22, Fa0/23, Fa0/24 Gig0/1, Gig0/2 2 tech active Fa0/1, Fa0/3 3 sales active Fa0/2 1002 fddi-default act/unsup 1003 token-ring-default act/unsup 1004 fddinet-default act/unsup 1005 trnet-default act/unsup VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2 1 enet 2 enet 3 enet 1002 fddi 1003 tr 1004 fdnet ieee 1005 trnet ibm Remote SPAN VLANs Primary Secondary Type Ports

33 实验结果 在Switch1上用 show interfaces FastEthernet 0/1 switchport 查看端口信息
Name: Fa0/1 Switchport: Enabled Administrative Mode: static access Operational Mode: static access Administrative Trunking Encapsulation: dot1q Operational Trunking Encapsulation: native Negotiation of Trunking: Off Access Mode VLAN: 2 (tech) Trunking Native Mode VLAN: 1 (default) Voice VLAN: none Administrative private-vlan host-association: none Administrative private-vlan mapping: none Administrative private-vlan trunk native VLAN: none Administrative private-vlan trunk encapsulation: dot1q Administrative private-vlan trunk normal VLANs: none Administrative private-vlan trunk private VLANs: none Operational private-vlan: none Trunking VLANs Enabled: All Pruning VLANs Enabled: Capture Mode Disabled Capture VLANs Allowed: ALL Protected: false Unknown unicast blocked: disabled Unknown multicast blocked: disabled Appliance trust: none

34 实验结果 在Switch1上用 show interfaces FastEthernet 0/2 switchport 查看端口信息
Name: Fa0/2 Switchport: Enabled Administrative Mode: static access Operational Mode: static access Administrative Trunking Encapsulation: dot1q Operational Trunking Encapsulation: native Negotiation of Trunking: Off Access Mode VLAN: 3 (sales) Trunking Native Mode VLAN: 1 (default) Voice VLAN: none Administrative private-vlan host-association: none Administrative private-vlan mapping: none Administrative private-vlan trunk native VLAN: none Administrative private-vlan trunk encapsulation: dot1q Administrative private-vlan trunk normal VLANs: none Administrative private-vlan trunk private VLANs: none Operational private-vlan: none Trunking VLANs Enabled: All Pruning VLANs Enabled: Capture Mode Disabled Capture VLANs Allowed: ALL Protected: false Unknown unicast blocked: disabled Unknown multicast blocked: disa Appliance trust: none

35 实验结果 在Switch1上用 show interfaces FastEthernet 0/11 switchport查看端口信息
Name: Fa0/11 Switchport: Enabled Administrative Mode: trunk Operational Mode: trunk Administrative Trunking Encapsulation: dot1q Operational Trunking Encapsulation: dot1q Negotiation of Trunking: On Access Mode VLAN: 1 (default) Trunking Native Mode VLAN: 1 (default) Voice VLAN: none Administrative private-vlan host-association: none Administrative private-vlan mapping: none Administrative private-vlan trunk native VLAN: none Administrative private-vlan trunk encapsulation: dot1q Administrative private-vlan trunk normal VLANs: none Administrative private-vlan trunk private VLANs: none Operational private-vlan: none Trunking VLANs Enabled: All Pruning VLANs Enabled: Capture Mode Disabled Capture VLANs Allowed: ALL Protected: false Unknown unicast blocked: disabled Unknown multicast blocked: disabled Appliance trust: none

36 在Switch2上用 show vlan 查看VLAN信息
实验结果 在Switch2上用 show vlan 查看VLAN信息 VLAN Name Status Ports 1 default active Fa0/3, Fa0/4, Fa0/5, Fa0/6 Fa0/7, Fa0/8, Fa0/9, Fa0/10 Fa0/12, Fa0/13, Fa0/14, Fa0/15 Fa0/16, Fa0/17, Fa0/18, Fa0/19 Fa0/20, Fa0/21, Fa0/22, Fa0/23 Fa0/24, Gig0/1, Gig0/2 3 sales active Fa0/1, Fa0/2 1002 fddi-default act/unsup 1003 token-ring-default act/unsup 1004 fddinet-default act/unsup 1005 trnet-default act/unsup VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2 1 enet 3 enet 1002 fddi 1003 tr 1004 fdnet ieee 1005 trnet ibm Remote SPAN VLANs Primary Secondary Type Ports

37 实验结果 在Switch2上用 show interfaces FastEthernet 0/1 switchport 查看端口信息
Name: Fa0/1 Switchport: Enabled Administrative Mode: static access Operational Mode: static access Administrative Trunking Encapsulation: dot1q Operational Trunking Encapsulation: native Negotiation of Trunking: Off Access Mode VLAN: 3 (sales) Trunking Native Mode VLAN: 1 (default) Voice VLAN: none Administrative private-vlan host-association: none Administrative private-vlan mapping: none Administrative private-vlan trunk native VLAN: none Administrative private-vlan trunk encapsulation: dot1q Administrative private-vlan trunk normal VLANs: none Administrative private-vlan trunk private VLANs: none Operational private-vlan: none Trunking VLANs Enabled: All Pruning VLANs Enabled: Capture Mode Disabled Capture VLANs Allowed: ALL Protected: false Unknown unicast blocked: disabled Unknown multicast blocked: disabled Appliance trust: none

38 实验结果 在Switch2上用 show interfaces FastEthernet 0/11 switchport 查看端口信息
Name: Fa0/11 Switchport: Enabled Administrative Mode: trunk Operational Mode: trunk Administrative Trunking Encapsulation: dot1q Operational Trunking Encapsulation: dot1q Negotiation of Trunking: On Access Mode VLAN: 1 (default) Trunking Native Mode VLAN: 1 (default) Voice VLAN: none Administrative private-vlan host-association: none Administrative private-vlan mapping: none Administrative private-vlan trunk native VLAN: none Administrative private-vlan trunk encapsulation: dot1q Administrative private-vlan trunk normal VLANs: none Administrative private-vlan trunk private VLANs: none Operational private-vlan: none Trunking VLANs Enabled: All Pruning VLANs Enabled: Capture Mode Disabled Capture VLANs Allowed: ALL Protected: false Unknown unicast blocked: disabled Unknown multicast blocked: disabled Appliance trust: none

39 查看各台主机的连通性 在配置VLAN之后,回答【问题2】: 每台主机相互ping,查看哪些主机可以连通,哪些不可以?为什么?
注:可以用 ping -n 发起一个受限广播,(参数 -n 1指明只发送一次,免得默认发送4次受到干扰),观察都收到了哪些主机的回复?

40 DTP的配置 将Switch1的FastEthernet 0/11接口的Trunk配置为desirable模式:
Switch1(config)#interface FastEthernet 0/11 Switch1(config-if)#shutdown Switch1(config-if)#switchport mode dynamic desirable Switch1(config-if)#no shutdown 将Switch2的FastEthernet 0/11接口的Trunk配置为auto模式: Switch2(config)#interface FastEthernet 0/11 Switch2(config-if)#shutdown Switch2(config-if)#switchport mode dynamic auto Switch2(config-if)#no shutdown

41 实验结果 在Switch1上用 show interfaces FastEthernet 0/11 switchport查看端口信息
Name: Fa0/11 Switchport: Enabled Administrative Mode: dynamic desirable Operational Mode: trunk Administrative Trunking Encapsulation: dot1q Operational Trunking Encapsulation: dot1q Negotiation of Trunking: On Access Mode VLAN: 1 (default) Trunking Native Mode VLAN: 1 (default) Voice VLAN: none Administrative private-vlan host-association: none Administrative private-vlan mapping: none Administrative private-vlan trunk native VLAN: none Administrative private-vlan trunk encapsulation: dot1q Administrative private-vlan trunk normal VLANs: none Administrative private-vlan trunk private VLANs: none Operational private-vlan: none Trunking VLANs Enabled: All Pruning VLANs Enabled: Capture Mode Disabled Capture VLANs Allowed: ALL Protected: false Unknown unicast blocked: disabled Unknown multicast blocked: disabled Appliance trust: none

42 实验结果 在Switch2上用 show interfaces FastEthernet 0/11 switchport 查看端口信息
Name: Fa0/11 Switchport: Enabled Administrative Mode: dynamic auto Operational Mode: trunk Administrative Trunking Encapsulation: dot1q Operational Trunking Encapsulation: dot1q Negotiation of Trunking: On Access Mode VLAN: 1 (default) Trunking Native Mode VLAN: 1 (default) Voice VLAN: none Administrative private-vlan host-association: none Administrative private-vlan mapping: none Administrative private-vlan trunk native VLAN: none Administrative private-vlan trunk encapsulation: dot1q Administrative private-vlan trunk normal VLANs: none Administrative private-vlan trunk private VLANs: none Operational private-vlan: none Trunking VLANs Enabled: All Pruning VLANs Enabled: Capture Mode Disabled Capture VLANs Allowed: ALL Protected: false Unknown unicast blocked: disabled Unknown multicast blocked: disabled Appliance trust: none

43 课后实验(1) 按照课件中拓扑及端口配置,修改Switch1和Switch2的FastEthernet 0/11端口,考察DTP协议的运行规则,并通过实验回答以下问题: 1、将Switch1和Switch2都设置为negotiate模式,考察以下组合,哪些可以形成Trunk? Switch2 trunk dynamic desirable dynamic auto Switch1

44 课后实验(2) 2、将Switch1设置为nonegotiate模式,Switch2仍为negotiate模式,再考察以下组合,哪些可以形成Trunk?在配置时与两者都是negotiate模式时有什么区别? 注意:考虑将Switch1设置为nonegotiate模式时,Switch1还能否设置为dynamic desirable或dynamic auto模式? Switch2 trunk dynamic desirable dynamic auto Switch1

45 注意事项 每次连接好线路或在接口上执行shutdown和noshutdown后,要等到拓扑图中连接线上的“点”变成绿色。
配置完交换机后,记得输入以下命令 copy running-config startup-config 保存,这样下次重新打开程序后,配置还在。


Download ppt "陈开恒 khchen69@mail.ustc.edu.cn 交换机及 虚拟局域网 组网技术 陈开恒 khchen69@mail.ustc.edu.cn."

Similar presentations


Ads by Google