2
0
mirror of https://github.com/gnu4cn/ccna60d.git synced 2024-05-21 04:55:00 +08:00

添加很多内容

This commit is contained in:
gnu4cn 2015-04-24 17:06:49 +08:00
parent 7da46f0098
commit 989d1249f8
89 changed files with 4365 additions and 1 deletions

BIN
0209.png Normal file

Binary file not shown.

After

(image error) Size: 96 KiB

BIN
021.png Normal file

Binary file not shown.

After

(image error) Size: 144 KiB

BIN
0210.png Normal file

Binary file not shown.

After

(image error) Size: 96 KiB

BIN
0211.png Normal file

Binary file not shown.

After

(image error) Size: 152 KiB

BIN
0212.png Normal file

Binary file not shown.

After

(image error) Size: 28 KiB

BIN
0213.png Normal file

Binary file not shown.

After

(image error) Size: 303 KiB

BIN
0214.png Normal file

Binary file not shown.

After

(image error) Size: 129 KiB

BIN
0215.png Normal file

Binary file not shown.

After

(image error) Size: 121 KiB

BIN
0216.png Normal file

Binary file not shown.

After

(image error) Size: 65 KiB

BIN
0217.png Normal file

Binary file not shown.

After

(image error) Size: 103 KiB

BIN
0218.png Normal file

Binary file not shown.

After

(image error) Size: 114 KiB

BIN
0219.png Normal file

Binary file not shown.

After

(image error) Size: 72 KiB

BIN
022.png Normal file

Binary file not shown.

After

(image error) Size: 237 KiB

BIN
0220.png Normal file

Binary file not shown.

After

(image error) Size: 165 KiB

BIN
023.png Normal file

Binary file not shown.

After

(image error) Size: 253 KiB

BIN
024.png Normal file

Binary file not shown.

After

(image error) Size: 250 KiB

BIN
025.png Normal file

Binary file not shown.

After

(image error) Size: 525 KiB

BIN
026.png Normal file

Binary file not shown.

After

(image error) Size: 182 KiB

BIN
027.png Normal file

Binary file not shown.

After

(image error) Size: 226 KiB

BIN
028.png Normal file

Binary file not shown.

After

(image error) Size: 120 KiB

BIN
029.png Normal file

Binary file not shown.

After

(image error) Size: 90 KiB

BIN
0300.png Normal file

Binary file not shown.

After

(image error) Size: 74 KiB

BIN
0301.png Normal file

Binary file not shown.

After

(image error) Size: 111 KiB

BIN
0302.png Normal file

Binary file not shown.

After

(image error) Size: 81 KiB

BIN
0303.png Normal file

Binary file not shown.

After

(image error) Size: 297 KiB

BIN
0304.png Normal file

Binary file not shown.

After

(image error) Size: 294 KiB

BIN
0305.png Normal file

Binary file not shown.

After

(image error) Size: 188 KiB

BIN
0306.png Normal file

Binary file not shown.

After

(image error) Size: 125 KiB

BIN
0401.png Normal file

Binary file not shown.

After

(image error) Size: 111 KiB

BIN
0402.png Normal file

Binary file not shown.

After

(image error) Size: 282 KiB

BIN
29.png Normal file

Binary file not shown.

After

(image error) Size: 117 KiB

876
2nd_chapter.md Normal file
View File

@ -0,0 +1,876 @@
# CSMA/CD, 交换和虚拟局域网
__ CSMA/CD, Switching, and VLANs __
## 第二天的任务
* 阅读今天的课文
* 复习昨天的课文
* 阅读 ICND1 记诵指南
思科工程师混饭吃的手艺就是安装、配置和调试troubleshooting交换机。而这又恰恰是这些工程师们不那么擅长的事情这么说有些不思议吧。可能有些人靠的是交换机本身的即插即用能力或是在问题出现后直面解决。这样的“凭感觉试试看”的风格在出现交换相关的问题时就会心态事与愿违了。This "fly by the seat of your pants" mentality backfires for many enigeers when there is a switching-related issue.
__我建议你在学习本书时先粗略地过一遍然后在回头读几次每次都将那些重点做一下笔记或是划一下重点。__
今天你将学到以下内容:
* CSMA/CD
* 虚拟局域网VLANs
* 配置 VLANs
* VLANs 故障排除
此模块涵盖 CCNA 大纲要求的以下方面:
* 掌握以太网络中用到的技术及介质访问控制方法
* 理解基本的交换概念及思科交换机操作:
* 冲突域
* 广播域
* 交换的不同类型
* CAM 表
* 配置并验证初始交换机配置,含远程访问管理
* 执行基本交换机设置的那些思科 IOS 命令
* 使用如 ping、Telnet 以及 SSH 等基本工具程序来验证网络状态以及交换机的运作
* 描述 VLANs 是如何创建出逻辑独立网络,以及这些网络之间的路由需求
* 解释网络分段及基本的流量管理概念
* 配置和验证 VLANs
## 交换机基础知识
### 带有冲突检测载波侦听多路复用Carrier Sense, Multiple Access with Collision Detection
带有冲突检测载波侦听,多路复用(Carrier Sense, Multiple Access with Collision Detection, CSMA/CD) 一词可以分解为以下几个部分,“载波侦听” 的意思是线路为设备所侦听,以确定是否有信号在其上传输。如果线路正在使用中,那么以太网帧是不能发送出去的。“多路复用” 的意思是网段上有多余一台的设备在使用线缆。最后的“冲突检测” 是指协议运行着一套确定线路上的太网帧是否因为遇到另一个帧而已经损坏的算法。从下图 2.1 你可以看到交换机端口在监听着线路。
!["端口监听着线路"](021.png)
图 2.1 -- 端口监听着线路
如果线路上出现了冲突则监听设备会发出一个拥塞信号以通知其它设备发生了冲突它们就不会尝试往线路上发送数据了。此时协议算法运行起来产生一个随机数时间间隔在以此间隔后重传。在线路清空前设备不会发送以太网帧。Wikipedia 上是这样解释该过程的:
!["CSMA/CD 过程"](022.png)
图 2.2 -- CSMA/CD 过程
> Farai 指出 -- “需要注意,现代交换机使用的是全双工连接交换机,因此而不会用到 CSMA/CD。但它仍然支持该技术而这完全是为了向后兼容性。”
### 冲突域和广播域
网络集线器的一个缺点是在线路上发生冲突时,损坏的帧会发送到所有连接的设备。现代交换机的优势之一就是交换机的每个端口都是作为一个冲突域。在冲突发生时(全双工下是不可能出现的),损坏的帧不会通过接口。图 2.3 展示了一台交换机增加到使用两台集线器的小型网络上的情形。交换机将该网络分解成两个冲突域。
!["一台交换机创建出两个冲突域"](023.png)
图 2.3 -- 一台交换机创建出两个冲突域
思科通常会在考试中以提问交换机是否减少冲突域数量的方式引诱你犯错。匆忙之下,你可能受导向说交换机会减少冲突域数量,但实际情况是相反的,交换机会增加冲突域的数量,而这是好事。交换机确实增加了冲突域的数量。因为集线器受限于其所采用的技术,而只能工作于半双工下,它就显得相当无用了。图 2.4 中__4 台 PC 连接到交换机上,产生 4 个冲突域__。每台 PC 都工作在全双工下,能够完全用上 100Mbps 的带宽。
!["四个冲突域"](024.png)
图 2.4 -- 四个冲突域
__交换机这里说的是二层交换机不会隔离广播域路由器会__。如果交换机收到带有广播目的地址的以太网帧就就转发给所有端口不管该帧是从哪个端口收到的。需要一台路由器来隔离广播域。图 2.5 展示了使用交换机/网桥以及一台路由器的小型网络,用以说明冲突域是如何隔离的。
!["广播域和冲突域"](025.png)
图 2.5 -- 广播域和冲突域
### 自动协商Auto-negotiation
你已经见到在连接不同速率和双工设置时,可能会出问题。在网络的一部,你可能会经常予以升级,但因为财务预算的制约,网络的其它部分会有老旧设备。这就会导致双工和速率的不匹配,引起错误和丢帧现象的发生。后面的章节中,我们将涉及交换机故障排除的内容。
IEEE 将自动协商作为解决此问题的方案,该技术让设备在传输流量前,就双工和速率上达成一致。速率设置为低速设备的速率。在下面的输出中,速率可被手动设定为 10Mbps 或 100Mbps 或者设定为 auto-negotiation。
```
Switch(config)#int f1/0/1
Switch(config-if)#speed ?
10 Force 10 Mbps operation
100 Force 100 Mbps operation
auto Enable AUTO speed configuration
```
该设置可用命令 `show interface x` 进行查看。
```
Switch#show int f1/0/1
FastEthernet1/0/1 is down, line protocol is down (notconnect)
Hardware is FastEthernet, address is 001e.13da.c003 (bia 001e.13da.c003)
MTU 1600 bytes, BW 10000 Kbit, DLY 1000 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, Loopback not set
Keepalive set (10 sec)
Auto-duplex, Auto-speed, media type is 10/100BaseTX
```
请务必牢记尽管有如此设置__auto-negotiation 仍可能会引起问题__。这就是为何许多生产性网络仍然坚持将端口直接配置成 100/full 或者千兆以太网的 1000/full。思科这样解释的
> 不合格的应用(nonconforming implementation)、硬件不兼容或者软件缺陷(software defects)三种原因,可能会导致各种自动协商问题。在网卡或厂商交换机与 IEEE 802.3u 规范不完全一致时问题就会发生。厂商特定的一些高级特性比如自动正负极性或线缆完整性auto-polarity or cable integrity等在 IEEE 802.3u 的 10/100Mbps 自动协商标准中没有描述的那些特性,同样会导致硬件的不兼容或其它问题。([Cisco.com](http://www.Cisco.com)
### 帧交换Switching Frames
__交换机是为交换帧而生也就是说将来自某进入接口的帧传输到正确的出口接口__。广播帧被交换出所有接口除了接收到广播帧的那个接口带有不明目的地目的地址不在 MAC 表中)的那些帧也一样,交换机执行下面三个动作:
* 根据目的 MAC 地址,进行帧转发或过滤(forwarding or filtering<dropping>)
* 从进来的帧学习 MAC 地址
* 使用 STP 协议来阻止二层环回的发生STP 在 ICND2 第 31 天学习)
图 2.6 中,交换机将来自主机 A F0/1以主机 C 为目的地的帧正确转发出 F0/3 而阻止其离开接口 F0/2。
!["帧过滤"](026.png)
图 2.6 -- 帧过滤
如目的地址不在 MAC 地址表中,交换机将该帧泛洪(flooding)至除它收到该帧的那个接口外的所有接口上。__交换机也会存储那些连接在另一台交换机上的设备的 MAC 地址;不过在地址表中它们对应的接口名称会是同一个,这样下来多个 MAC 地址与一个同样的出口接口对应,列出在 MAC 地址表中。这是一种找出网络上你不熟悉设备的方法__。图 2.7 用以说明这个概念。
!["同一接口上的多 MAC 地址"](027.png)
图 2.7 -- 同一接口上的多 MAC 地址
流量传输中的任何延时(delay)都被称为传输延迟latency。__依据你所希望的在流量传输前对帧的检查程度思科交换机提供了三种流量交换的方式__。对帧的检查越多引入到交换机的延迟就越多。三种可供选择的交换模式(switching modes)为:
* 直通模式Cut-through
* 存储转发模式(交换机默认)Store-and-forward
* Fragment-free改进的直通模式
__直通模式__
直通模式交换是最快交换方式,它有最低的延迟。进入交换机的帧仅读至目的地址,便做出转发决定。在获知目的地址后,交换机马上检查 CAM 表,以找到正确的端口来转发出该帧并马上发出。因为没有错误检查,此方式才能提供最低的延迟。代价是交换机会转发任何带有错误的帧。
使用一个比方来说明交换机模式是最好不过了。你作为某夜店的保安,被要求每个进入夜店的人都要有一个带照片的出入卡 -- 却并没要求你去查看照片是否与那个人一致,只是出入卡要有就行。这种方式下,人们必定能快速进入夜店了。这就是直通模式的工作原理。
__存储转发模式__
交换机读取整个帧并将其复制到它的缓冲区。对该帧执行一次循环冗余校验cyclic redundancy check, CRC以检查其存在的任何错误。如有发现错误该帧就被丢弃。相反就检查交换表并转发该帧。存储转发模式确保帧至少有 64 字节大,且不大于 1518 字节。若小于 64 字节或大于 1518 字节,交换机就会丢弃帧。
现在请再次设想你是夜店保安,此时你务必要确保照片与那个人是相吻合的,同时你要在放进那些人之前记下他们的名字和地址。这样来查验出入卡就造成了相当大的延迟,这也是存储转发交换运行的方式。
三种交换方式中有着最高延迟的就是存储转发交换,也是 2900 系列交换机默认的交换方式。
__Fragment-free(修订的直通模/Runt-free 模式)__
因为直通交换不检查错误,而存储转发模式又耗时太长,我们需要一种又快又可靠的方式。使用夜店保安的例子,设想你被要求确保每个人都有出入卡同时照片又要吻合。此方式下,你确保每个人都是其宣称的那个人,但你不必记下他们的所有信息。在交换中,这是通过采用 fragment-free 交换方式实现的低端的lower-level思科交换机默认配置为此种模式。
Fragment-free 交换是直通交换的一个修改变种。检查帧的前 64 字节有无错误随后传输出去。此方法背后推理reasoning是帧的错误最有可能发生在前 64 字节中。
如同上面已经提到的,以太网帧的最小尺寸是 64 字节;任何小于 64 字节的帧被称为是“侏儒runt”帧。因为转发前的帧都必须至少有 64 字节,这就会消除那些侏儒帧,这也是为何此模式又被叫做 “runt-free” 交换的原因。
## 交换基本概念Switching Concept
### 交换机使用需求
在交换机发明前网络上的所有设备都会接收到来自其它设备的数据。一旦探测到线路上有一个数据帧PC 就不得不停下来查看其头部,看看自己是不是数据帧的接收者。设想一下网络上每分钟都有上千个帧吧。所有设备很快就被折腾到挂起。图 2.8 展示了网络上的所有设备;注意因为是通过仅转发的集线器连接在一起,它们都不得不共享同一带宽。
!["每台设备都听着其它设备"](028.png)
图 2.8 -- 每台设备都听着其它设备
__集线器的问题__
之前我曾提到__集线器仅是简单的多端口中继器__(见 2.9)。它们接收传入的信号,进行清理,然后在插线了的端口上发出。它们同时创建出一个巨大的冲突域。
!["集线器在每个端口上都发送帧"](029.png)
图 2.9 -- 集线器在每个端口上都发送帧
集线器是愚蠢(dumb)设备。它们没有 MAC 地址存储机制,所以在设备 A 每次往设备 B 发送一个帧时它都会往每个端口发送。交换机就不一样有一块叫做专用集成电路application-specific integrated circuit, AISC的存储芯片该芯片会建立一个设备端口表图 2.10。这个表保存在内容可寻址存储器Content Addressable Memory, CAM中。
!["交换机建立起一张 MAC 地址表"](0210.png)
图 2.10 -- 交换机建立起一张 MAC 地址表
__在首次启动时交换机并未在其 CAM 表(思科考试又此表称为 MAC 地址表中存储任何地址__。一有帧开始传输该表就建立起来。如果在指定时间过后没有帧从某个端口传送这条记录就会过期。下面的输出表明至今仍没有帧在交换机上通过。
```
Switch#show mac-address-table
Mac Address Table
-------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- -----
Switch#
```
交换机中没有记录,不过当你从一台路由器 ping 另一台时(两台都连接上交换机),表格条目建立起来。
```
Router#ping 192.168.1.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 62/62/63 ms
Switch#show mac-address-table
Mac Address Table
-------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- -----
1 0001.c74a.0a01 DYNAMIC Fa0/1
1 0060.5c55.da01 DYNAMIC Fa0/2
```
该条目的意思是,任何目的地址为连接到交换机上 FastEthernet 端口 0/1 或 0/2 的 MAC 地址的帧,都会直接发送到对应的端口。对于任何其它帧,交换机都将执行一次广播查询,看看目的设备是否插入了交换机。从上面的五次 ping 中的第一个句点可以看出。在等待交换机广播查询及收到目的路由器回应时,第一次 ping 发生了超时80% 的成功率)。
__`show mac-address-table` 命令是一个非常重要的命令__务必要记住这个命令考试和现实工作中都是需要的。
你已经注意到 MAC 地址是个什么东西了。MAC 地址指派给所有设备,以实现数据链路层的通信。在以太网卡、路由器的以太网接口及无线设备上,你都能看到各厂商分配的 MAC 地址。下面是我的笔记本的以太网卡的 MAC 地址。
![](noname-0.png)
各家厂商有各自的组织唯一识别号Organizationally Unique Identifier, OUI, 该号码构成了 MAC 地址的前半段。随后他们就可以根据其各自的编号系统来自由创建地址的后半段了。一个 MAC 地址是 48 位二进制数(后面我们会涉及二进制和十六进制的知识),所以上面我的地址构成为:
| OUI | 厂商编号 |
| -- | -- |
| 24 位二进制数 | 24 位二进制数 |
| 6 位十六进制数 | 6 位十六进制数 |
| 00 1E EC | 54 85 17 |
如交换机在某个接口上收到一个帧,它就将帧的源地址加入到表中。如它知道帧的目的地址,就将该转发出相应接口。如它不知道目的地址,它将把该帧广播到除了收到该的所有接口。如果交换机收到一个广播帧(也就是目的地址全 F 的帧),它也会将该帧广播到除接收到该帧的所有接口。后面我们会涉及十六进制编址。广播过程如图 2.11 所示。
!["广播帧在所有接口上发出"](0211.png)
图 2.11 -- 广播帧在所有接口上发出
### 以太网帧
有四种不同类型的以太网帧:
* 以太网 802.3 帧
* 以太网 II 帧
* 以太网 802.2 SAP 帧
* 以太网 802.2 SNAP 帧
前两种以太网标准用于在网卡之间通信时的组帧方式。__它们不能识别上层协议802.2 类型帧才具备此能力__。你__只需要注意 802.3 类帧__此类型的帧构成如下。
!["以太网 802.3 帧结构"](0212.png)
图 2.12 -- 以太网 802.3 帧结构
IEEE 委员确定的 IEEE 802.3 以太网帧有以下特定字段。
* 前同步信号preamble -- 为传入的数据对网卡进行信号同步及告知
* 帧开始界定符start-of-frame delimiter, SFD -- 标志着帧的开始
* 目的地址 -- 目的 MAC 地址可以是单播Unicast、广播或多播(Multicast)
* 源地址 -- 发送主机的 MAC 地址
* 长度 -- 定义帧中数据字段的长度
* 数据 -- 帧中的载荷(就是传输中的数据)
* 帧校验序列frame-check sequence, FCS -- 给出了帧中所有数据的循环冗余校验cyclic redundancy check, CRC
### 交换机初始配置Initial Switch Configuration
你需要先像连接全新的路由器那样,用通过控制台端口连接新的交换机。因为在你能够在通过 Telnet 或 SSH稍后会更多地讲到连上交换机之前交换机上至少得已经有一两条配置才行。很多交换机的初始配置和路由器的初始配置都是一样的。
在首次连接交换机时,在任何设上都很有必要执行一下 `show version` 命令(其输出见下面)。考试中也要求你明白哪个 `show` 命令提供哪些信息。大多数情况下你不能从考试模拟器访问中得到答案,你就只有靠记忆来作答了。
`show version` 命令提供了很多有用信息,包括这些。
* 交换机运行时间switch uptime
* 型号
* IOS 版本, IOS release
* 上次重启的原因
* 所有接口及其类型
* 所有安装的存储器
* 背板 MAC 地址base MAC address
```
Switch>en
Switch#show version
Cisco IOS Software, C2960 Software (C2960-LANBASE-M), Version 12.2(25)FX, RELEASE
SOFTWARE (fc1)
Copyright (c) 1986-2005 by Cisco Systems, Inc.
Compiled Wed 12-Oct-05 22:05 by pt_team
ROM: C2960 Boot Loader (C2960-HBOOT-M) Version 12.2(25r)FX, RELEASE SOFTWARE (fc4)
System returned to ROM by power-on
Cisco WS-C2960-24TT (RC32300) processor (revision C0) with 21039K bytes of memory.
24 FastEthernet/IEEE 802.3 interface(s)
2 GigabitEthernet/IEEE 802.3 interface(s)
63488K bytes of flash-simulated non-volatile configuration memory.
Base Ethernet MAC Address___________: 0090.2148.1456
Motherboard assembly number : 73-9832-06
Power supply part number : 341-0097-02
Motherboard serial number : FOC103248MJ
Power supply serial number : DCA102133JA
Model revision number : B0
Motherboard revision number : C0
Model number : WS-C2960-24TT
System serial number : FOC1033Z1EY
Top Assembly Part Number : 800-26671-02
Top Assembly Revision Number : B0
Version ID : V02
CLEI Code Number : COM3K00BRA
Hardware Board Revision Number : 0x01
Switch Ports Model SW Version SW Image
------ ----- ----- ---------- ---------------
* 1 26 WS-C2960-24TT 12.2 C2960-LANBASE-M
Configuration register is 0xF
```
我们还没有涉及 VLANs 的知识,但现在,你可以把 VLAN 看着是一个逻辑上的局域网,在 VLAN 上的设备物理上可以在不同地方但在能它们所能关注到的细节下as far as they are concerned他们都是直接连接在一台交换机下的。在下列配置中交换机所有端口都是默认在 VLAN 1 中。
```
Switch#show vlan
VLAN Name Status Ports
---- ------- ------ ------------------------------
1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4,
Fa0/5, Fa0/6, Fa0/7, Fa0/8,
Fa0/9, Fa0/10, Fa0/11, 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,
```
如你打算给交换机添加一个 IP 地址就是__管理地址__以便通过网络连上该交换机只需给某个 VLAN 配置 IP 地址即可;本例中就是 VLAN1。
```
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#interface vlan1
Switch(config-if)#ip add 192.168.1.3 255.255.255.0
Switch(config-if)# ← hold down Ctrl+Z keys now
Switch#show interface vlan1
Vlan1 is administratively down, line protocol is down
Hardware is CPU Interface, address is 0010.1127.2388 (bia 0010.1127.2388)
Internet address is 192.168.1.3/24
```
__VLAN1 默认是关闭的__,你需要执行一个 `no shutdown` 命令来开启它。你__还需告诉交换机往哪里发送所有 IP 流量,因为 2 层交换机没有建立路由表的能力__该操作如下面的输出所示。
```
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#ip default-gateway 192.168.1.1
Switch(config)#
```
在网络上有多台交换机时,你会想着去修改交换机默的主机名,这样在远程连接它们时才更容易区分(见下面的配置命令行)。设想一下通过远程 Telnet 对五台同样叫做 “Switch” 的交换机进行故障排除时的情形吧。
```
Switch(config)#hostname Switch1
```
如你要经由网络 Telnet (或 SSH) 到某台交换机,你还需开启该协议。交换机远程访问默认是关闭的。
```
Switch1#conf t
Enter configuration commands, one per line.
Switch1(config)#line vty 0 15
Switch1(config-line)#password cisco
Switch1(config-line)#login
```
__请完成上述操作然后从另一设备同一子网连上交换机来测试你的配置__。这是一道 CCNA 基础题目。
__VTYsVirtual TeletYpe terminal 是路由器或交换机用于对其进行 Telnet 或安全 Telnet ( SSH ) 访问的虚拟端口__。在你为其配置上一种认证方式之前它们都是关闭的最简单的方法是给它们加上一个口令然后执行 `login` 命令)。你可以见到 0 到 4 端口、inclusive (包含)或 0 到 15 端口。要得知你有多少个可用的端口的一种方法是在编号 0 后面输入一个问号, 或者使用 `show line` 命令,如下面的输出所示。
```
Router(config)#line vty 0 ?
<1-15> Last Line number
Router#show line
Tty Typ Tx/Rx A Modem Roty AccO AccI Uses Noise Overruns Int
* 0 CTY - - - - - 0 0 0/0
1 AUX 9600/9600 - - - - - 0 0 0/0 *
2 VTY - - - - - 2 0 0/0
3 VTY - - - - - 0 0 0/0
4 VTY - - - - - 0 0 0/0
5 VTY - - - - - 0 0 0/0
6 VTY - - - - - 0 0 0/0
```
CTY 就是控制台线路,同时 VTY 线路用于 Telnet 连接AUX 是指辅助端口。
为了获得更为安全的访问方式,你可以仅允许 SSH 连接进入交换机,这就是说流量会被加密。而要让 SSH 工作,你需要在交换机上允许安全性 IOS 镜像,如下面的输出那样。
```
Switch1(config-line)#transport input ssh
```
现在Telnet 流量就不再被允许传入到 VTY 端口了。
请在交换机上配置一下这所有的命令。仅仅阅读它们无助于你在考试当天记起它们。
## 虚拟局域网Virtual Local Area Networks, VLANs
就如同你已经看到的那样,交换机打破冲突域。更进一步,路由器打破广播域,这就是说现在的网络看起来像下面这样。
!["路由器隔离广播域"](0213.png)
图 2.13 -- 路由器隔离广播域
在继续之前,让我们讨论一下局域网到底是什么。一个局域网本质上是一个广播域。图 2.13 中的网络上,如果 PC-A 发出一个广播包PC-B 会接收到这个包PC-C 和 PC-D 却不能。这是因为那台路由器打破了该广播域。现在你可以__使用虚拟局域网将交换机的那些端口放入不的广播域__如下图所示。
!["VLAN 下的广播域"](0214.png)
图 2.14 -- VLAN 下的广播域
图 2.14 中,该 2 层网络经由 VLANs 被划分为两个广播域。PC-A 发出的广播包为 PC-B 接收到PC-C 和 PC-D 接收不到。如没有 VLANsPC-C 和 PC-D 仍会收到 PC-A 发出的广播包。VLANs 的一些优点如下。
* 更小规模的设备组中的较少广播包令到网络更快
* 设备资源得以节省,因为它们只需处理少量的广播包
* 通过将设备保留在特定组别(或按特定功能分组)的一个广播域中,而提升安全性。这里的组别,可以是公司/机构的部门,或是某个安全级别等。比如开发部门或者测试室就应该与生产部门的设备分开。
* 带来在跨越任何尺度的地理位置上网络扩展的灵活性。比如,同一 VLAN 中某台 PC 在楼宇中的什么位置并不重要。它会以为自己与其它配置在同一 VLAN 中的机器在同样的网段上。图 2.15 中VLAN 1 中的所有主机都能与其它主机通信尽管它们不在同一楼层。对它们来说VLAN 是透明的或不可见的。
!["VLANs 消除局域网的物理边界"](0215.png)
图 2.15 -- VLANs 消除局域网的物理边界
### VLAN 标记VLAN Marking
虽然厂商在创建 VLANs 中采用其各自的方法,我们务必要小心处理一个涉及多厂商的 VLAN以解决互操作性问题。比如思科开发的 __ISL 标准,是通过增加一个 26 字节的头部,以及一个新的 4 字节尾部trailer, 的方式来封装原始帧__。为解决兼容性问题IEEE 开发了 802.1Q 标准,这是一个独立于厂商的方式,用以创建可互操作 VLANs。
!["ISL 的标记方式"](0216.png)
图 2.16 -- ISL 的标记方式
802.1Q 通常被称为“帧标记frame tagging”, 因为它将一个叫做标签的 32 位头部a 32-bit header, called a "tag"),插入到原始帧源地址后面,而不会对其它字段进行修改。紧邻源地址后两个字节,占据着一个注册以太网类型值 -- 0x8100, 它表明该帧包含了一个 802.1Q 头部。接着的 3 位表示 802.1P 用户优先级User Priority, UP字段, 在服务质量Quality of Service, QoS技术中用作服务类别Class of Service, CoS位。下一个字段是 1 位规范格式标识Canonical Format Indicator, CFI最后 12 位是 VLAN ID。所以在采行 802.1Q 标准时,我们总共能有 4096 个 VLANs。
!["802.1Q 的标记方式"](0217.png)
图 2.17 -- 802.1Q 的标记方式
传送来自多个 VLANs 数据的那个端口叫做干线trunk端口。trunk 端口可以使用 ISL 协议,也可以使用 802.1Q 协议。802.1Q 中的一个特别概念是"原生 VLANnative VLAN"。这是一种特别的 VLAN 类型,它上面的帧是没有打标签的。原生 VLAN 的目的是让交换机在某个接口上运行 802.1Q 中继(单一链上的多 VLANs即便另一设备无法支持中继的情况下原生 VLAN 上的流量仍能通过该链路。如交换机在一条中继链路上收到未打标签的流量,就会假定这些流量是属于原生 VLAN 上的。__思科将 VLAN 1 作为_默认_的原生 VLAN__。
### 加入虚拟局域网, VLAN Membership
有两种常用的将端口加入到 VLANs 的方式 -- 静态方式或动态方式。
通过静态 VLAN 指派或配置,交换机上的那些端口为管理员所配置在不同 VLANs 中,有关设备再连接到端口上。在某用需要搬往楼宇的其它部位时,就要求管理员改变交换机上的配置。默认情形下,所有交换机端口属于 VLAN 1。
动态指派方式令到设备可根据其 MAC 地址而加入到特定的 VLAN。该特性给予管理员在无需改变交换机配置的情况下允许用户接入任何交换机或是在楼栋内搬动的灵活性。__通过运用一台虚拟局域网管理策略服务器a VlAN Management Policy Server, VMPS实现动态特性__。
> Farai 指出 “先是端口指派到 VLANs 中,随后设备插入到端口上”。
请注意,由于各个 VLAN 都是不同的广播域,这就带来以下问题。
* 默认情形下,一个 VLAN 中的主机是不能到达其它 VLAN 的
* VLAN 间通信需要一台三层设备(后面会讲到)
* 每个 VLAN 都需要它们自己的子网,比如, VLAN 1 -- 192.168.1.0/24, VLAN 2 -- 192.168.2.0/24
* 某 VLAN 中的所有主机应属于同一 VLAN
### VLAN 链路, VLAN Links
我们知道在一台交换机上可以有连接到多个 VLANs 的主机。那么在流量从一台主机前往另一主机时,发生了些什么呢?比如说,在图 2.15 中,当 VLAN 1 位于一楼的主机尝试与 VLAN 1 位于二楼的主机通信时,二层的那台主机是怎样知道该流量是属于哪个 VLAN 的呢?
我们知道交换机采用了一种叫做“帧标记frame tagging” 的方式,来将流量在不同 VLANs 上保持隔离。交换机把包含了 VLAN ID 的一个头部添加进帧中。在图 2.15 中,一楼交换机将会给来自 VLAN 2 的流量打上标记后,传给交换机 2, 交换机 2 将会看到这个标记,从而得知该流量需要呆在 VLAN 2 中。__这样的流量只能在叫做_中继链路_的链路上通过。VLAN 1 通常被指定为原生 VLAN而_原生 VLAN 上的流量不被标记___。关于原生 VLAN 的内容,后面会提到。
交换机端(在 CCNA 考试范围内)可一分为以下三种。
* 接入端口或接入链路access links or ports
* 中继端口或中链路trunk links or ports
* 动态端口(很快就会学到这个)
### 接入链路Access Links
被定义了作为接入链路的交换机端口,只能是唯一 VLAN 的一个成员。连接该接入链路的设备并不知晓任何其它 VLANs 的存在。在来自主机的帧进入到一个接入链路时,交换机就将一个标签加入到该帧中,在前往主机的帧从交换机接入链路出去时,交换将该标记从帧中移除。接入链路用于连接主机,也可以用于连接路由器。
### 中继Trunking
某个交换机端口通常既会连接网络上的某台主机,也会连接其它网络交换机、路由器或服务器。那么该链路就有可能需要传输多个 VLANs 上的流量。为实现这个目的,就需要区分每个帧都是来自于哪个 VLAN。这种区分方式就叫做 “帧标记frame tagging”, 在经中继链路传输前,出原生 VLAN 的帧外,所有帧都已打过标签。帧中的标记包含了 VLAN ID 信息。在帧到达目的主机所在的那台交换机后,该标记被移除。
!["VLAN 标记法"](0218.png)
图 2.18 -- VLAN 标记法
VLAN 中继用于传输多个 VLAN 的数据。为将属于某个 VLAN 的帧与其它 VLANs 的帧有所区别,在中继链路上传输的所有帧都经特别标记过,这样目的交换机就知道该帧属于那个 VLAN。ISL 和 802.1Q 是用于确保这些 VLANs 在穿过交换机中继链路后,仍能完全分辨出来的两种主要方式。
交换机间链路Inter-Switch Link, ISL) 是思科专有的。尽管如此CCNA 考试用用到的型号是 2960 交换机,它只能识别 802.1Q。我们在这里提到 ISL 只是为了知识体系的完整性,以防你不得不配置老旧型号的交换机的情形。
> Farai 指出 -- “所有新型号交换机默认都是采用 802.1Q ISL 已被弃用。”
802.1Q 与 ISL 有很多的不同最大区别是802.1Q 可以支持最多 4096 个 VLANs, ISL 只能支持最多 1000 个。另一个大的区别是 802.1Q 中的原生 VLAN 概念。默认情形下802.1Q 中来自所有 VLANs 的帧都被打上标签。此规则的唯一例外就是属于原生 VLAN 的帧,这些帧未被标记。
尽管如此你要记住__在某个特定中继链路上可以通过将某 VLAN 设为原生 VLAN来指定其上面的帧不打标签__。比如在采用 802.1Q 时,为阻止对 VLAN 400 上的帧打标签,你需要将 VLAN 400 配置为某特定中继上的原生 VLAN。IEEE 802.1Q 原生 VLAN 配置在后面会详细介绍。
以下是有关 802.1Q 特性的小结。
* 支持最多 4096 个 VLANs
* 采用帧内标记机制,修改原始帧
* 是由 IEEE 开发的开发标准协议
* 不对原生 VLAN 上的帧打标签;除此之外的所有帧都被标记
下面是一台交换机上的简短示例配置。我将 `switchport` 命令包括了进去,该命令告诉交换机将其某个端口作为二层端口,而不是三层。
```
Sw(config)#interface FastEthernet 0/1
Sw(config-if)#switchport
Sw(config-if)#switchport mode trunk
Sw(config-if)#switchport trunk encapsulation dot1q
Sw(config-if)#exit
```
当然,在 2960 系列交换机上,`encapsulation` 不被识别因为它只有一种类型。__在将一台交换机与其它交换机连接时你需要将其接口设置为中继接口以令到 VLANs 都被标记上__。`switchport` 命令的作用同样如此。再次说明,我在这里提到这个,是因为在现实中,你可能要配置一台三层交换机,如我们死盯 2960 型号,你可能会感到迷惑,我们不要这个!
交换机上的某中继链路可以是下列五种模式之一。
* 开启On模式 -- 强制该端口进入永久中继模式。不管插入设备是否同意将它们之间的链路转换成中继链路,该端口都会成为一个中继端口。
* 关闭Off模式 -- 该链路不被作为中继链路使用,就算插入设备被设置成“中继”模式。
* 自动Auto模式 -- 该端口不情愿成为一条中继链路。在插入设备被设置为“开启”或“我要desirable)”模式时,链路就成为中继链路。当两端都被设置为“自动”模式时,链路就绝不会变成中继链路了,因为没有一方有转换成中继的意愿。
* 我要Desirable模式 -- 该端口积极尝试转换成中继链路。如另一设备被设置为 “开启”、“自动” 或 “我要” 模式,链路就会成为中继链路
* 没商量No-negotiate模式 -- 阻止端口经由协商成为中继连接。配置上此模式后,端口会强制进入接入模式或中继模式。
### 配置 VLANs Configuring VLANs
现在你已对 VLANs 和中继链路有了了解,就让我们来配置一下图 2.19 中的网络吧。你需要将交换机配置为两个分别在 fa0/1 端口上的主机位于 VLAN 5 中,以及端口 fa0/15 之间的链路为中继链路。
![“测试网络”](0219.png)
图 2.19 -- 测试网络
在将端口指派到 VLANs 之前,务必先要全局配置命令 `vlan <vlan#>` 创建出那个 VLAN。而此命令又会将你带入 VLAN 配置模式,在那里又可以为 VLANs 赋予一个描述性的名称。这里有一个示例。
```
Switch1(config)#vlan 5
Switch1(config-vlan)#name RnD
Switch2(config)vlan 5
Switch2(config-vlan)#name RnD
```
使用命令 `show vlan` 命令来查看交换上存在着哪些 VLANs。其输出与下面的相似。
```
Switch1#show vlan
VLAN Name Status Ports
---- -------- ------- --------------------------------------------
1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4 Fa0/5, Fa0/6, Fa0/7, Fa0/8 Fa0/9,
Fa0/10, Fa0/11, Fa0/12, Fa0/13 Fa0/14, Fa/15, Fa0/16, Fa0/17, Fa0/18
...
[Truncated Output]
...
5 RnD active
...
[Truncated Output]
```
我们在通过使用接口配置命令 `switchport access vlan [vlan#]`, 将端口 fa0/1 加入到 VLAN 5 中去。
```
Switch1(config)#int fa0/1
Switch1(config-if)#switchport access vlan 5
Switch2(config)#int fa0/1
Switch2(config-if)#switchport access vlan 5
```
在形如 3560 这样的三层交换机上,在将某个端口加入到一个 VLAN 前,你务必要使用命令 `switchport mode access` 将端口手动设置为接入模式。现在我们来看看 `show vlan` 命令的输出。
```
Switch1#show vlan
VLAN Name Status Ports
---- ---- ----- --------------------------------------------
1 default active Fa0/2, Fa0/3, Fa0/4, Fa0/5, Fa0/6, Fa0/7,
Fa0/8, Fa0/9, Fa0/10, Fa0/11, Fa0/12, Fa0/13,
Fa0/14, Fa/15, Fa0/16, Fa0/17, Fa0/18
...
[Truncated Output]
...
5 RnD active Fa0/1
...
[Truncated Output]
```
注意 fa0/1 现在被指派给了 VLAN 5。让我们来将两台交换机的 fa0/15 接口配置为中继链路。这里要注意的是 3550 型号交换机端口的默认模式是我要模式desirable 3560 型号的是自动模式)。 动态中继协议Dynamic Trunk Protocol, DTP会导致两台交换机上的 fa0/15 接口成为 ISL 中继链路。下一节课会学 DTP 的内容,但这里会简要提到 DTP 的一些东西。这种情况可用 `show interface trunk` 命令看到。
```
Switch1#show interface trunk
Port Mode Encapsulation Status Native vlan
Fa0/15 desirable n-isl trunking 1
```
请注意其模式为我要desirable, 封装方式是 ISL “n” 代表 negotiated, 协商出的)。以下输出演示了配置中继为 ISL 方式的做法。
```
Switch1(config)#interface fa0/15
Switch1(config-if)#switchport trunk encapsulation isl
Switch1(config-if)#switchport mode trunk
Switch2(config)#interface fa0/15
Switch2(config-if)#switchport trunk encapsulation isl
Switch2(config-if)#switchport mode trunk
```
`switchport trunk encapsulation` 命令设置端口的中继协议,而命令 `switchport mode trunk` 命令则是将端口设置为中继工作方式。现在的 `show interface trunk` 命令输出会是下面这样。
```
Switch2#show interface trunk
Port Mode Encapsulation Status Native vlan
Fa0/15 on isl trunking 1
```
取代 N-ISL 的是 ISL。这是因为此次的协议是在接口上配置的而不是协商出的。
> __重要提示__ 在将交换机某端口设置为中继模式前,要先设置其中继封装方式。而这个规则又不适用于 2960 交换机(当前 CCNA 大纲中用到的型号2960 交换机只使用 dot1q 802.1Q 的另一种叫法封装。因此2960 交换机上的 `switchport trunk encapsulation` 命令不工作。
与此类似,你可将交换机端口配置为 802.1Q 而不是 ISL如下面的输出那样。
```
Switch1(config)#interface fa0/15
Switch1(config-if)#switchport trunk encapsulation dot1q
Switch1(config-if)#switchport mode trunk
Switch2(config)#interface fa0/15
Switch2(config-if)#switchport trunk encapsulation dot1q
Switch2(config-if)#switchport mode trunk
```
命令 `show interface trunk` 命令的输出又成了这样。
```
Switch2#show interface trunk
Port Mode Encapsulation Status Native vlan
Fa0/15 on 802.1q trunking 1
```
请注意,原生 VLAN 是 1。这正是一个 802.1Q 中继上的默认原生 VLAN同时可使用 `switchport trunk native vlan <vlan#>` 命令进行修改。__中继链路上的两个接口原生 VLAN 必须匹配__。这条命令是 CCNA 大纲的一部分__也被作为一中安全手段__。
> __重要提示:__ 交换机能存储所有 VLAN 的信息,在重启后也还在。如你打算交换机以空白配置启动,就需要在交换机上运行 `delete vlan.dat` 命令,如下面的输出所示。这只适用于真实交换机,在诸如 Packet Tracer 等交换机模拟器是做不到的。
```
SwitchA#dir flash:
Directory of flash:/
1 -rw- 3058048 <no date> c2960-i6q4l2-mz.121-22.EA4.bin
2 -rw- 676 <no date> vlan.dat
64016384 bytes total (60957660 bytes free)
SwitchA#
SwitchA#delete vlan.dat
Delete filename [vlan.dat]?
Delete flash:/vlan.dat? [confirm]
SwitchA#dir flash:
Directory of flash:/
1 -rw- 3058048 <no date> c2960-i6q4l2-mz.121-22.EA4.bin
64016384 bytes total (60958336 bytes free)
SwitchA#
```
## 交换故障排除基础Basic Switching Troubleshooting
理论上,一旦设备配置好并运行起来后,它就会一直运行下去,不过下面这些情况是常有的事,比如你要在某个不是你亲自配置的网络上做事,或者你会在轮班制工当中支持许多并不熟悉的网络,这些网络又在你不当班的时候被其他人改动过,这些状况都会导致出现多多少少的问题。我建议你在完成一些实验后,在回头看看这部分内容。
### 常见的交换机问题Common Switch Issues
__无法远程登录到交换机Can't Telnet to Switch__
首先要问的是 Telnet 曾正常运行过吗?如曾正常运行过,现在却不行了,那就是有人对交换机进行了改动、重启过交换机,从而导致配置丢失,或者是网络上的某台设备阻止了 Telnet 流量。
```
Switch#telnet 192.168.1.1
Trying 192.168.1.1 ...Open
[Connection to 192.168.1.1 closed by foreign host]
```
要检查的头一件事就是交换机上的 Telnet 是否已被确实开启(见下面的输出)。网络的 80% 错误都是由于唐突或疏忽造成的,所以请不要信誓旦旦,要亲历亲为,别去相信其他人的言词。
一个简单的 `show running-config` 命令就可以将交换机的配置列出。在 `vty` 线路下,你将看到 Telnet 是否有被打开。注意你需要在 vty 线路下有 `login` 或者 `login local` (或者配置了 AAA 而 AAA 配置超出了 CCNA 考试范围) 命令,以及 `password` 命令。如下面所示。
```
line vty 0 4
password cisco
login
line vty 5 15
password cisco
login
```
`login local` 命令告诉交换机或路由器去查找配置在其上的用户名和口令,如下面输出的那样。
```
Switch1#sh run
Building configuration...
Current configuration : 1091 bytes!
version 12.1
hostname Switch1
username david privilege 1 password 0 football
line vty 0 4
password cisco
login local
line vty 5 15
password cisco
login local
...
[Truncated Output]
```
__Ping 不通交换机, Can't Ping the Switch__
首先要弄清楚那人要 ping 交换机的原因。如你真要 ping 交换机,那么得要给交换机配置上一个 IP 地址;此外,交换机也要知道如何将流量送出(要有默认网关)。
__不能经由交换机 ping 通其它设备, Can't Ping through the Switch__
如出现经由交换机 ping 不通的情况,那就要确保那两台终端设备位于同一 VLAN 中。每个 VLAN 被看成一个网络,因此各个 VLAN 都要有与其它 VLAN 所不同的地址范围。必须要有一台路由器,以实现一个 VLAN 与其它 VLAN 之间连通。
__接口故障Interface Issues__
默认情况下,所有路由器接口都是对流量关闭的,而交换机接口是开启的。如你发现交换机接口处于管理性关闭状态,可以通过执行接口级命令 `no shutdown` 来开启它。
```
Switch1(config)#int FastEthernet0/3
Switch1(config-if)#no shut
```
__二层接口可被设置成三种模式中继、接入或动态模式__。__中继模式下交换机可与其它交换机或服务器连接__。而接入模式用于连接终端设备比如一台 PC 或笔记本计算机。动态模式令到交换机去探测采用何种设置。
在形如 3550 型号交换机平台上默认设置通是动态我要模式dynamic desirable你需要在 [Cisco.com](http://cisco.com) 上去查看你的交换机型号的设置以及发行注记。__CCNA 考试中,你将被要求配置一台 2960 型号交换机__。此型号的交换机在除非你硬性设置接口为中继或接入模式的情况下会动态选择工作模式。
```
Switch1#show interfaces switchport
Name: Fa0/1
Switchport: Enabled
Administrative Mode: dynamic auto
```
默认设置可以方便地进行更改,如下面的输出这样。
```
Switch1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch1(config)#int FastEthernet0/1
Switch1(config-if)#switchport mode ?
access Set trunking mode to ACCESS unconditionally
dynamic Set trunking mode to dynamically negotiate access or trunk mode
trunk Set trunking mode to TRUNK unconditionally
Switch1(config-if)#switchport mode trunk
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down
Switch1(config-if)#^Z
Switch1#
%SYS-5-CONFIG_I: Configured from console by console
Switch1#show interfaces switchport
Name: Fa0/1
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: trunk
```
__更多有关接口的故障 More Interface Issues__
交换机端口的默认设置是双工自动侦测auto-detect duplex以及速率自动侦测auto-detect speed。如你将一台 10Mbps 的设备插入到以半双工方式运行的交换机(现在已经很难找到这样的交换机了)上,该端口就会探测到插入的设备并运作起来。然而并不是任何时候都这样的,所以一般建议将交换机端口的双工方式及速率硬性设置,如下面的输出那样。
```
Switch1#show interfaces switchport
Name: Fa0/1
Switchport: Enabled
Administrative Mode: dynamic auto
Switch1#show interface FastEthernet0/2
FastEthernet0/2 is up, line protocol is up (connected)
Hardware is Lance, address is 0030.f252.3402 (bia 0030.f252.3402)
BW 100000 Kbit, DLY 1000 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, loopback not set
Keepalive set (10 sec)
Full-duplex, 100Mb/s
Switch1(config)#int fast 0/2
Switch1(config-if)#duplex ?
auto Enable AUTO duplex configuration
full Force full-duplex operation
half Force half-duplex operation
Switch1(config-if)#speed ?
10 Force 10Mbps operation
100 Force 100Mbps operation
auto Enable AUTO speed configuration
```
双工模式不匹配的一些迹象(除开错误消息外)有接口上的输入错误以及 CRC 错误,如下面的输出所示。请同时看看 ICND1 章节的第 15 天的一层和二层故障排除部分。
```
Switch#show interface f0/1
FastEthernet0/1 is down, line protocol is down (disabled)
Hardware is Lance, address is 0030.a388.8401 (bia 0030.a388.8401)
BW 100000 Kbit, DLY 1000 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, loopback not set
Keepalive set (10 sec)
Half-duplex, 100Mb/s
input flow-control is off, output flow-control is off
ARP type: ARPA, ARP Timeout 04:00:00
Last input 00:00:08, output 00:00:05, output hang never
Last clearing of “show interface” counters never
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
Queueing strategy: fifo
Output queue :0/40 (size/max)
5 minute input rate 0 bits/sec, 0 packets/sec
5 minute output rate 0 bits/sec, 0 packets/sec
956 packets input, 193351 bytes, 0 no buffer
Received 956 broadcasts, 0 runts, 0 giants, 0 throttles
755 input errors, 739 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
0 watchdog, 0 multicast, 0 pause input
0 input packets with dribble condition detected
2357 packets output, 263570 bytes, 0 underruns
0 output errors, 0 collisions, 10 interface resets
0 babbles, 0 late collision, 0 deferred
0 lost carrier, 0 no carrier
0 output buffer failures, 0 output buffers swapped out
```
__硬件故障Hardware Issues__
和其它电子设备一样交换机端口也会出现失效或不能全时正常运行现象而时而正常时而故障的情况是更难于处理的。工程师经常通过将一台已知正常的设备插入到交换机的另一端口来测试故障的接口。你也可以跳转bounce某端口就是在该端口是先用 `shutdown` 命令关闭,接着用 `no shutdown` 命令开启。更换网线也是一个常见的处理步骤。图 2.20 给出了一些其它的交换机故障和处理方法。
请查阅你的交换机的文档,因为根据系统和端口 LEDs 的不同,每个端口会有闪烁的或是常亮的红色、琥珀色或者绿色的指示灯,表示功能正常或是端口、系统故障。
!["常见交换机故障及解决方法"](0220.png)
图 2.20 -- 常见交换机故障及解决方法
### VLAN 分配故障VLAN Assignment Issues__
小环境下的网络管理起来相对容易因为只需部署少数特性就能满足业务需求。但在企业环境中你不会去使小型工作组交换机或是家庭办公设备的small workgroup switches and SOHO device。相反你会用到高端设备它们提供提供了诸多高级/复杂功能,具有流量优化能力。
此种环境下一种可能会配置到的特别特性,就是采用 VLANs 技术将不同网络区域进行逻辑隔离。在你遇到与某个 VLAN 有关的配置问题时,故障就会出现,这种故障可能会是难于处理的。一种处理方法就是去分析交换机的整个配置,并尝试找到问题所在。
VLAN 相关故障,通常是经由观察网络主机之间连通性(比如某用户不能 ping 通服务器缺失发现的就算一层运行无问题。__有关 VLAN 故障的一个重要特征就是不会对网络的性能造成影响__。如你配错了一个 VLAN连接就直接不通尤其是在考虑 VLANs 通常是用作隔离 IP 子网的情况下,只有处于同一 VLAN 的设备才能各自通信。
在排除 VLAN 故障时,首先要做的是查看设计阶段完成的网络文档和逻辑图表(网络拓扑图),如此你才能得知各个 VLAN 跨越的区域,以及相应设备和各交换机的端口情况。接着就要去检查每台交换机的配置,并通过将其与存档方案进行比较,以尝试找出问题。
你还要对 IP 地址分配方案进行查验。如你采用的是设备静态 IP 地址分配方式,你可能打算回去检查那台设备,确保其有正确的 IP 地址和子网掩码。如在 IP 分址方案上存在问题,像是将设备配置到错误的网络上,或是子网掩码错误/默认网关错误的话,即使交换机的 VLAN 配置无误,你也会遇到连通性问题。
还要确保交换机的中继配置正确。当存在多台交换机时,通常会有交换机间的上行链路,这些上行链路承载了网络上的 VLANs。这些交换机间链路常被配置为中继链路以实现穿越多个 VLANs 的通信。如某 VLAN 中的数据需要从一台交换机发往另一交换机,那么它就必须是该中继链路组的成员,因此,你还要确保中继链路两端交换机配置正确。
最后,如你要将某设备迁往另一个 VLAN你务必要同时更改交换机及客户端设备因为在迁移后客户端设备会有一个不同子网的不同 IP 地址。
如你有遵循这些 VLAN 故障排除方法,在你首次插入设备及 VLAN 间迁移时,肯定能得到预期的连通性。
## 第二天的问题
1. Switches contain a memory chip known as an `_______`, which builds a table listing which device is plugged into which port.
2. The `_______ _______`-`_______`-`_______` command displays a list of which MAC addresses are connected to which ports.
3. Which two commands add an IP address to the VLAN?
4. Which commands will enable Telnet and add a password to the switch Telnet lines?
5. How do you permit only SSH traffic into your Telnet lines?
6. What is the most likely cause of Telnet to another switch not working?
7. Switches remember all VLAN info, even when reloaded. True or False?
8. A switch interface can be in which of three modes?
9. How do you set a switch to be in a specific mode?
10. Which commands will change the switch duplex mode and speed?
## 第二天问题答案
1. ASIC.
2. `show mac-address-table`
3. The `interface vlan x` command and the `ip address x.x.x.x`command.
4.
```
Switch1(config)#line vty 0 15
Switch1(config-line)#password cisco
Switch1(config-line)#login
```
5. Use the `Switch1(config-line)#transport input ssh` command.
6. The authentication method is not defined on another switch.
7. True.
8. Trunk, access, or dynamic mode.
9. Apply the `switchport mode <mode>` command in Interface Configuration mode.
10. The `duplex` and `speed` commands.
## 第二天实验
### 交换机概念实验
请登入到一台思科交换机,并输入那些本单元课程中解释到的命令。包括:
* 在不同交换机端口上配置不同的端口速率/自动协商速率
* 使用 `show running-config``show interface` 命令,验证这些端口参数
* 执行一下 `show version` 命令,来查看硬件信息以及 IOS 版本
* 查看交换机 MAC 地址表
* 给 VTY 线路配置一个口令
* 定义出一些 VLANs 并为其指派名称
* 将一个 VLAN 指派到一个配置为接入模式的端口上
* 将某个端口配置为中继端口ISL 以及 802.1Q),并将一些 VLANs 指派到该中继链路
* 使用 `show vlan` 命令验证 VLAN 配置
* 使用 `show interface switchport` 命令和 `show interface trunk` 命令,验证接口中继工作状态及 VLAN 配置
* 删除 `vlan.dat` 文件

BIN
30.png Normal file

Binary file not shown.

After

(image error) Size: 162 KiB

BIN
31.png Normal file

Binary file not shown.

After

(image error) Size: 191 KiB

BIN
38.png Normal file

Binary file not shown.

After

(image error) Size: 176 KiB

BIN
39.png Normal file

Binary file not shown.

After

(image error) Size: 94 KiB

790
3rd_day.md Normal file
View File

@ -0,0 +1,790 @@
# 中继、DTP 及 VLAN 间路由
## 第三天的任务
* 阅读今天的课文
* 回顾昨天的课程
* 完成今天的实验
* 阅读 ICND1 记诵指南
在最小规模的那些办公室里,你才会遇到仅使用一台交换机的情况,但是网络基础设施通常是由多台交换机构成的。多台交换机带来了其配置上的挑战,要求你对中继及其有关的问题有深入理解。思科将多台交换机的安装和故障排除,视为一个 CCNA 级别的基础主题。
今天你将学到。
* 中继工作方式trunking
* 动态中继协议Dynamic Trunking Protocol, DTP
* VLAN 间路由
本单元覆盖 ICND1 考试大纲的以下要求。
* 在思科交换机上配置并验证中继
* DTP
* 自动协商
* VLAN 间路由的配置和验证单臂路由router-on-a-stick
* 子接口subinterfaces
* 上行路由upstream routing
* 封装encapsulation
* 配置交换机虚拟接口configure SVI(Switch Virtual Interface) Interfaces
## 配置并验中继链路
中继是一个可以承载多种流量类型,每种流量类型都用一个独特的 VLAN ID 做了标记的交换机端口。在数据经由中继端口或者说中继链路得以交换时就被那个外出交换机中继端口the egress switch trunk port打上了标签或者叫进行了着色, 这样做了过后,接收交换机就能够分辨出数据是属于哪个特定的 VLAN 了。在接收交换机的进入端口the receiving switch ingress port上, 标签会被移除,然后数据就被转发给相应的目的设备。
在思科 IOS Catalyst 交换机上部署 VLAN 中继的头一项配置任务,就是把需要的接口配置为一个二层交换端口。这是通过执行 `switchport` 接口配置命令完成的。
> **注意:** 该命令只在兼容三层或多层交换机上需要。在诸如 Catalyst 2960 系列这样的二层交换机上并不适用。那些支持命令 `ip routing` 的交换机才被认为是兼容三层的交换机。
接着就是要中继链路所要使用的封装协议。这是通过执行 `switchport trunk encapsulation [option]` 命令完成的。此命令可用的选项有下面这些。
```
Switch(config)#interface FastEthernet1/1
Switch (config-if)#switchport trunk encapsulation ?
dot1q - Interface uses only 802.1q trunking encapsulation when trunking
isl - Interface uses only ISL trunking encapsulation when trunking
negotiate - Device will negotiate trunking encapsulation with peer on interface
```
关键字 `[dot1q]` 强制该交换机端口使用 IEEE 802.1Q 封装方式。关键字 `[isl]` 强制该交换机端口使用思科 ISL 封装方式。
`[negotiate]` 关键字则指明说在动态交换机间链路协议Dynamic Inter-Switch Link Protocol, DISL及动态中继协议Dynamic Trunking Protocol, DTP无法就封装格式达成一致时ISL 作为备选格式。DISL 简化了两台互联的快速以太网设备间 ISL 中继链路的建立。在 DISL 协议下,只需链路的一端需要配置为中继端口,因此而将 VLAN 中继配置过程大大简化。
DTP 是一个***思科专有的***点对点协议point-to-protocol, 它在两台交换机间协商建立起某种常见中继模式。DTP 会在稍后专门讲到。下面的输出演示了如何将某交换机端口配置为在建立起一条中继链路是采用 IEEE 802.1Q 封装方式。
```
Switch (config)#interface FastEthernet1/1
Switch (config-if)#switchport
Switch (config-if)#switchport trunk encapsulation dot1q
```
此配置可通过命令 `show interfaces [name] switchport` 进行验证,如下列输出所示。
<pre>
Switch#show interfaces FastEthernet1/1 switchport
Name: Fa0/2
Switchport: Enabled
Administrative Mode: dynamic desirable
Operational Mode: trunk
<b>Administrative Trunking Encapsulation: dot1q</b>
<b>Operational Trunking Encapsulation: dot1q</b>
Negotiation of Trunking: On
Access Mode VLAN: 1 (default)
Trunking Native Mode VLAN: 1 (default)
...
[Truncated Output]
</pre>
中继端口配置的第三步,就是部署配置,以确保该端口已被指定为中继端口。可以通过两种方式完成。
* 手动(静态)地完成中继配置
* 使用动态中继协议Dynamic Trunking Protocol, DTP
### 手动(静态)中继配置
手动配置一个中继,是通过在所需要的交换机上,执行接口配置命令 `switchport mode trunk` 完成的。此命令将该端口强制变成永久(静态)中继模式。下面的配置输出演示了如何将一个端口静态地配为中继端口。
```
VTP-Server(config)#interface FastEthernet0/1
VTP-Server(config-if)#switchport
VTP-Server(config-if)#switchport trunk encapsulation dot1q
VTP-Server(config-if)#switchport mode trunk
VTP-Server(config-if)#exit
VTP-Server(config)#
```
如你使用的是一台低端交换机,就大可以忽略 `switchport` 命令,上面的输出是来自一台 Catalyst 6000 系列交换机。此配置可通过 `show interfaces [name] switchport` 命令予以验,如下面的输出所示。
```
VTP-Server#show interfaces FastEthernet0/1 switchport
Name: Fa0/1
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)
...
[Truncated Output]
```
尽管中继链路的静态配置强制交换机建立一条中继,动态 ISL 和动态中继协议DTP数据包仍能从该接口发出。这样做了后一条静态配置的中继链路就可以与相邻的使用了 DTP 的交换机,建立起中继关系,接着的小节将会讲到。经由 `show interfaces [name] switchport` 命令的输出,便可验证这点。如下面的输出所示。
<pre>
VTP-Server#show interfaces FastEthernet0/1 switchport
Name: Fa0/1
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: trunkAdministrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: dot1q
<b>Negotiation of Trunking: On</b>
Access Mode VLAN: 1 (default)
Trunking Native Mode VLAN: 1 (default)
...
[Truncated Output]
</pre>
在上面的输出中,粗体文字表明尽管中继链路是静态配置的,端口仍然在发出 DTP 和 DISL 数据包。在一些场合,此特性被看成是不受欢迎的。因此,通过执行接口配置命令 `switchport nonegotiate`,在静态配置作为中继链路的端口上关闭 DISL 及 DTP 数据包发送,被认为是一种良好实践,具体操作如以下的输出。
```
VTP-Server(config)#interface FastEthernet0/1
VTP-Server(config-if)#switchport
VTP-Server(config-if)#switchport trunk encapsulation dot1q
VTP-Server(config-if)#switchport mode trunk
VTP-Server(config-if)#switchport nonegotiate
VTP-Server(config-if)#exit
VTP-Server(config)#
```
再一次,`show interfaces [name] switchport` 命令可被用作验证配置,像下面这样。
<pre>
VTP-Server#<b>show interfaces FastEthernet0/1 switchport</b>
Name: Fa0/1
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: trunk
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: dot1q
<b>Negotiation of Trunking: Off</b>
Access Mode VLAN: 1 (default)
Trunking Native Mode VLAN: 1 (default)
...
[Truncated Output]
</pre>
### 动态中继协议Dynamic Trunking Protocol, DTP
DTP 是一个在两台交换机之间协商出一种常见中继模式的思科专有的点对点协议a Cisco proprietary point-to-protocol。这种动态协商不止于何种中继模式还包括中继的封装方式。根据其平台的不同两种交换机端口所能使用的 DTP 模式如下。
* 动态我要模式dynamic desirable
* 动态自动模式dynamic auto
在两台相交换机上使用 DTP 时,如交换机端口默认为动态我要状态,端口就会积极尝试变为中继端口。而如果交换机端口默认为动态自动状态,端口仅会在相邻交换机被设置为动态我要模式时,才反转为中继端口。
图 3.1 演示所有 DTP 模式组合,在两台思科 atalyst 交换机间,这些组合有的能建立起中继链路,也有的不能建立(在这里的组合都能建立中继链路;请查看图 3.2 之后的说明)。
!["DTP 模式组合"](0301.png)
图 3.1 -- DTP 模式组合
图 3.2 示出了将会在两台相邻交换机间成功建立中继链路的有效组合 -- 一端是 DTP 另一端静态配置为中继端口。
!["DTP 模式组合,第二部分"](0302.png)
图 3.2 -- DTP 模式组合,第二部分
> __注意__ 如果两台交换机都设置为动态自动模式,它们是无法建立起中继链路的,知道这一点很重要。这因为,不同于动态我要模式,动态自动模式是一种消极模式,它等待另一端发起中继建立。因此,在两个消极端口连接时,既不会发起中继建立,同时中继链路也绝不会形成。与此类,一个静态配置的交换机端口同时配置了 `switchport nonegotiate` 命令的话,它绝不会与相邻的使用 DTP 的交换机形成中继,因为这会阻止 DISL 及 DTP 数据包从那个端口发出。
在交换的局域网中应用 DTP 时,`show dtp [interface <name>]` 命令就可用来显示交换机的全局 DTP 信息以及特定接口的 DTP 信息。下面的输出给出了 `show dtp` 命令打印出的信息。
```
VTP-Server#show dtp
Global DTP information
Sending DTP Hello packets every 30 seconds
Dynamic Trunk timeout is 300 seconds
4 interfaces using DTP
```
从上面的输出可以看出,交换机每 30 秒就发出一个 DTP 数据包。而 DTP 超时被设置为 300 秒5 分钟),当前有 4 个接口正使用着 DTP。命令 `show dtp intferface [name]` 会打印出特定接口的 DTP 信息,这些信息中包括了接口的类型(中继或接入)、端口当前的 DTP 配置情况、中继的封装方式,以及 DTP 数据包统计信息,如下面的输出所示。
```
VTP-Server#show dtp interface FastEthernet0/1
DTP information for FastEthernet0/1:
TOS/TAS/TNS: TRUNK/ON/TRUNK
TOT/TAT/TNT: 802.1Q/802.1Q/802.1Q
Neighbor address 1: 000000000000
Neighbor address 2: 000000000000
Hello timer expiration (sec/state): 7/RUNNING
Access timer expiration (sec/state): never/STOPPED
Negotiation timer expiration (sec/state): never/STOPPED
Multidrop timer expiration (sec/state): never/STOPPED
FSM state: S6:TRUNK
# times multi & trunk 0
Enabled: yes
In STP: no
Statistics
----------
0 packets received (0 good)
0 packets dropped
0 nonegotiate, 0 bad version, 0 domain mismatches, 0 bad TLVs, 0 other
764 packets output (764 good)
764 native, 0 software encap isl, 0 isl hardware native
0 output errors
0 trunk timeouts
2 link ups, last link up on Mon Mar 01 1993, 00:00:22
1 link downs, last link down on Mon Mar 01 1993, 00:00:20
```
### IEEE 802.1Q 原生 VLAN
昨天的课程中,你学到了 802.1Q 或是 VLAN 标记法,在除了原生 VLAN 的帧外的所有帧中插入一个标签。IEEE 定义了原生 VLAN, 以提供给不能明白 VLAN 标签的,原有的 802.3 端口以连通性。
默认情况下802.1Q 中继将 VLAN 1 作为原生 VLAN。执行命令 `show interfaces [name] switchport` 或命令 `show interfaces trunk`,就可查看到默认原生 VLAN 是哪一个,如下面的输出所示。
<pre>
VTP-Server#show interfaces FastEthernet0/1 switchport
Name: Fa0/1
Switchport: EnabledAdministrative Mode: trunk
Operational Mode: trunk
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: dot1q
Negotiation of Trunking: On
Access Mode VLAN: 1 (default)
<b>Trunking Native Mode VLAN: 1 (default)</b>
Voice VLAN: none
...
[Truncated Output]
</pre>
交换机使用 VLAN 1 来承载一些特定的协议流量比如思科发现协议Cisco Discovery Protocol, CDP、VLAN 中继协议VLAN Trunking Protocol, VTP、端口聚合协议Port Aggregation Protocol, PAgP, 以及动态中继协议Dynamic Trunking Protocol, DTP 等的协议信息。CDP 和 PAgP 将在今天的课程后面部分详细讨论。尽管默认原生 VLAN 总是 VLAN 1, 它是可以手动修改为任何不在__保留 VLANs__ 中的任何有效 VLAN 编号的。
但是__中继链路两端上的原生 VLAN 必须一致__记住这点是很重要。如出现了原生 VLAN 不匹配生成树协议Spanning Tree Protocol, STP就把该端口置为端口 VLAN ID (port VLAN ID, PVID) 不一致状态且不会转发该链路。此外CDPv2 也会在交换机间传送原生 VLAN 信息,而在出现原生 VLAN 不匹配后,将会在交换机控制台上打印错误消息。通过对所需的 802.1Q 中继链路,执行接口配置命令 `switchport trunk native vlan [number]` 可以修改其默认原生 VLAN。如下面的输出所示。
```
VTP-Server(config)#interface FastEthernet0/1
VTP-Server(config-if)#switchport trunk native vlan ?
<1-4094> VLAN ID of the native VLAN when this port is in trunking mode
```
### VLAN 间路由Inter-VLAN Routing
默认情况下,尽管 VLANs 能够跨越整个的二层交换网络,一个 VLAN 中的主机却是不能直接和其它 VLAN 中的主机直接通信的。为实现这个目的,必须对不同 VLANs 间的流量进行路由。这就叫做 VLAN 间路由。交换局域网switched LANs 中的 VLAN 间路由有三种实现方式,下面有分别列出,这三种方式及其各自的优势和劣势,接下来的部分会详细介绍。
* 采用物理的路由器接口的 VLAN 间路由, Inter-VLAN routing using physical router interfaces
* 采用路由器子接口的 VLAN 间路由, Inter-VLAN routing using router subinterfaces
* 采用交换机虚拟接口的 VLAN 间路由, Inter-VLAN routing using switched virtual interfaces
__采用物理的路由器接口的 VLAN 间路由__
为实现 VLAN 间路由通信的第一种方式,需要用到带有多个接口的路由器,来作为每个单独配置 VLAN 的网关。此时路由器就能够使用这些物理的 LAN 接口,将接收自一个 VLAN 的数据包,路由到其它 VLAN 上。此种方式如图 3.3 所示。
!["采用多个物理路由器接口的 VLAN 间路由"](0303.png)
图 3.3 -- 采用多个物理路由器接口的 VLAN 间路由
图 3.3 演示了用到两个不同 VLANs 的单一 LAN这两个 VLANs 都有分配给各自的 IP 子网。尽管图中画出的网络主机都是连接在同一物理交换机上,但因为它们处于不同的 VLANs 中, VLAN 10 中的主机与 VLAN 20 中的主机之间的数据包必须要经过路由才行,而在同样 VLAN 中的数据包只需要简单的交换即可。
这种方案的最主要优势在于,它是简单的,且易于部署。而最主要的劣势在于,它不具有可扩展性。比如说,,当交换机上配置了有 5 个、10 个,甚至 20 个额外的 VLANs 时,路由器上就要有相应数量的物理接口才行。在大多数情况下,这在技术上是不可行的。
在采用多物理路由器接口时,各需要的 VLAN 中到路由器的交换机链路,被配置为接入链路。然后路由器上的物理接口都配置上相应的 IP 地址,而 VLAN 上的网络主机,要么以静态方式配置上相应 VLAN 的 IP 地址,将该路由器物理接口作为默认网关,要么通过 DHCP 完成配置。图 3.3 中交换机的配置,在下面的输出中有演示。
```
VTP-Server-1(config)#vlan 10
VTP-Server-1(config-vlan)#name Example-VLAN-10
VTP-Server-1(config-vlan)#exit
VTP-Server-1(config)#vlan 20
VTP-Server-1(config-vlan)#name Example-VLAN-20
VTP-Server-1(config-vlan)#exit
VTP-Server-1(config)#interface range FastEthernet0/1 2, 23
VTP-Server-1(config-if-range)#switchport
VTP-Server-1(config-if-range)#switchport access vlan 10
VTP-Server-1(config-if-range)#switchport mode access
VTP-Server-1(config-if-range)#exit
VTP-Server-1(config)#interface range FastEthernet0/3 4, 24
VTP-Server-1(config-if-range)#switchport
VTP-Server-1(config-if-range)#switchport access vlan 20
VTP-Server-1(config-if-range)#switchport mode access
VTP-Server-1(config-if-range)#exit
```
2960 交换机上无需 `switchport` 命令,因为其接口已经运行于二层模式。
下面的输出又演示了图 3.3 中的路由器的配置。
```
R1(config)#interface FastEthernet0/0
R1(config-if)#ip add 10.10.10.1 255.255.255.0
R1(config-if)#exit
R1(config)#interface FastEthernet0/1
R1(config-if)#ip add 10.20.20.1 255.255.255.0
R1(config-if)#exit
```
__使用路由器子接口的 VLAN 间路由__
采用路由器子接口实现 VLAN 间路由的方法,解决了使用多路由器物理接口方法所可能存在的伸缩性问题![](0304.png)。有了路由器子接口,就只需要路由器有一个物理接口就行,接下来的子接口是经由在那个物理接口上的配置获得。图 3.4 演示了这种方法。
!["采用路由器子接口的 VLAN 间路由"](0304.png)
图 3.4 -- 采用路由器子接口的 VLAN 间路由
图 3.4 描绘了图 3.3 中同样的 LAN。但在图 3.4 中,仅使用了一个物理路由器接口。而为了实现一种 VLAN 间路由解决方案,使用 `interface [name].[subinterface number]` 全局配置命令,在该主要路由器接口上配置出了子接口。而通过命令 `encapsulation [isl|dot1q] [vlan]` 子接口配置命令,又将各子接口与某个特定 VLAN 关联了起来。最后一步就是给子接口配置上需要的 IP 地址。
在交换机上那条连接路由器的单一链路必须要配置为中继链路这是因为__路由器不支持 DTP__。假如中继配置成 802.1Q 中继,那么在原生 VLAN 不是默认原生 VLAN 时,此中继的原生 VLAN 一定要定义。而该__原生 VLAN 也要在相应的路由器子接口上予以配置,配置命令为 `encapsulation dot1q [vlan] native` 子接口配置命令__。下面的输出演示了使用单一物理接口的 VLAN 间路由配置(又称作 “单臂路由router-on-a-stick”。图 3.4 中绘出的两个 VLANs 在下面的输出中也有显示,同时还有一个额外的 VLAN 用于管理用;该管理 VLAN 将被配置为原生 VLAN。
```
VTP-Server-1(config)#vlan 10
VTP-Server-1(config-vlan)#name Example-VLAN-10
VTP-Server-1(config-vlan)#exit
VTP-Server-1(config)#vlan 20
VTP-Server-1(config-vlan)#name Example-VLAN-20
VTP-Server-1(config-vlan)#exit
VTP-Server-1(config)#vlan 30
VTP-Server-1(config-vlan)#name Management-VLAN
VTP-Server-1(config-vlan)#exit
VTP-Server-1(config)#interface range FastEthernet0/1 2
VTP-Server-1(config-if-range)#switchport
VTP-Server-1(config-if-range)#switchport access vlan 10
VTP-Server-1(config-if-range)#switchport mode access
VTP-Server-1(config-if-range)#exit
VTP-Server-1(config)#interface range FastEthernet0/3 4
VTP-Server-1(config-if-range)#switchport
VTP-Server-1(config-if-range)#switchport access vlan 20
VTP-Server-1(config-if-range)#switchport mode access
VTP-Server-1(config-if-range)#exit
VTP-Server-1(config)#interface FastEthernet0/24
VTP-Server-1(config-if)#switchport
VTP-Server-1(config-if)#switchport trunk encapsulation dot1q
VTP-Server-1(config-if)#switchport mode trunk
VTP-Server-1(config-if)#switchport trunk native vlan 30
VTP-Server-1(config-if)#exit
VTP-Server-1(config)#interface vlan 30
VTP-Server-1(config-if)#description This is the Management Subnet
VTP-Server-1(config-if)#ip address 10.30.30.2 255.255.255.0
VTP-Server-1(config-if)#no shutdown
VTP-Server-1(config-if)#exit
VTP-Server-1(config)#ip default-gateway 10.30.30.1
```
图 3.4 中的路由器之配置如下面的输出所示。
```
R1(config)#interface FastEthernet0/0
R1(config-if)#no ip address
R1(config-if)#exit
R1(config)#interface FastEthernet0/0.10
R1(config-subitf)#description Subinterface For VLAN 10
R1(config-subif)#encapsulation dot1Q 10
R1(config-subif)#ip add 10.10.10.1 255.255.255.0
R1(config-subif)#exit
R1(config)#interface FastEthernet0/0.20
R1(config-subitf)#description Subinterface For VLAN 20
R1(config-subif)#encapsulation dot1Q 20
R1(config-subif)#ip add 10.20.20.1 255.255.255.0
R1(config-subif)#exit
R1(config)#interface FastEthernet0/0.30
R1(config-subitf)#description Subinterface For Management
R1(config-subif)#encapsulation dot1Q 30 native
R1(config-subif)#ip add 10.30.30.1 255.255.255.0
R1(config-subif)#exit
```
此方案的主要优在于,路由器上仅需一个物理接口。主要的劣势在于,该物理端口的带宽,是为所配置的多个子接口所公用的。因此,如果存在很多 VLAN 间流量时,路由器就很快会成为网络的性能瓶颈。
__采用交换机虚拟接口的 VLAN 间路由__
__多层交换机支持在物理接口上配置 IP 地址__。但要先用__接口配置命令 `no switchport`__ 对这些接口进行配置,以允许管理员在其上配置 IP 地址。除开使用物理接口外多层交换机还支持交换机虚拟接口Switch Virtual Interfaces, SVIs
)技术。
SVIs 是一系列代表了 VLAN 的逻辑接口。尽管某个交换机虚拟接口代表了一个 VLAN它也不是在某个 VLAN 在交换机上配置出来时,就自动配置出来的;它必须要管理员通过执行 __`interface vlan [number]` 全局配置命令__手动加以配置。而那些诸如 IP 分址等的三层配置参数,也要与在物理接口上一样,在交换机虚拟接口予以配置。
以下输出演示了在单一交换机上实现 VLAN 间路由,做出的交换机虚拟接口配置。此输出引用了本小节前面的配置输出所用到的 VLANs。
```
VTP-Server-1(config)#vlan 10
VTP-Server-1(config-vlan)#name Example-VLAN-10
VTP-Server-1(config-vlan)#exit
VTP-Server-1(config)#vlan 20
VTP-Server-1(config-vlan)#name Example-VLAN-20
VTP-Server-1(config-vlan)#exit
VTP-Server-1(config)#interface range FastEthernet0/1 2
VTP-Server-1(config-if-range)#switchport
VTP-Server-1(config-if-range)#switchport mode access
VTP-Server-1(config-if-range)#switchport access vlan 10
VTP-Server-1(config-if-range)#exit
VTP-Server-1(config)#interface range FastEthernet0/3 4
VTP-Server-1(config-if-range)#switchport
VTP-Server-1(config-if-range)#switchport mode access
VTP-Server-1(config-if-range)#switchport access vlan 20
VTP-Server-1(config-if-range)#exit
VTP-Server-1(config)#interface vlan 10
VTP-Server-1(config-if)#description “SVI for VLAN 10”
VTP-Server-1(config-if)#ip address 10.10.10.1 255.255.255.0
VTP-Server-1(config-if)#no shutdown
VTP-Server-1(config-if)#exit
VTP-Server-1(config)#interface vlan 20
VTP-Server-1(config-if)#description SVI for VLAN 10
VTP-Server-1(config-if)#ip address 10.20.20.1 255.255.255.0
VTP-Server-1(config-if)#no shutdown
VTP-Server-1(config-if)#exit
```
__在用到多层交换机时交换机虚拟端口是推荐的配置方法和实现 VLAN 间路由的首选方案__。
你可通过使用 `show interface vlan x` 命令来验证某个交换机虚拟接口是配置恰当的IP 分址等)。下面的输出与 `show interface x` 命令等同。
```
Switch#show interfaces vlan 100
Vlan100 is up, line protocol is down
Hardware is EtherSVI, address is c200.06c8.0000 (bia c200.06c8.0000)
Internet address is 10.10.10.1/24
MTU 1500 bytes, BW 100000 Kbit/sec, DLY 100 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, loopback not set
ARP type: ARPA, ARP Timeout 04:00:00
```
如你希望使用一台 2960 交换机来路由 IP 数据包,那么就需要对配置进行修改,然后进行重启。这是因为 2960 和更新型号的一些交换机进行了性能调优实现一种明确的交换机资源分配方式。该资源管理方式叫做交换机数据库管理Switch Database Managent, SDM模板。你可以在以下几种 SDM 模板中进行选择。
* 默认default -- 各项功能的平衡
* IPv4/IPv4 双协议支持dual IPv4/IPv6 -- 用于双栈环境(dual-stack environments)
* Lanbase-routing -- 支持各种单播路由Unicast routes
* 服务质量Quality of Service, QoS -- 提供对各种服务质量特性的支持
下面是在我的 3750 交换机上的输出。这些输出与 2960 上的选项不完全一致但你明白了这个意思。同时请记住__交换机型号及 IOS 对 SDM 配置选项有影响因此你要查看你的型号的配置手册__。
```
Switch(config)#sdm prefer ?
access Access bias
default Default bias
dual-ipv4-and-ipv6 Support both IPv4 and IPv6
ipe IPe bias
lanbase-routing Unicast bias
vlan VLAN bias
```
在你期望在 2960 交换机上配置 VLAN 间路由时,就需要开启 Lanbase-routing SDM 选项。同时在此变更生效前,需要重启交换机。下面是 `show sdm prefer` 命令的输出,该输出告诉你当前的 SDM 配置以及资源分配情况。
```
Switch#show sdm prefer
The current template is “desktop default” template.
The selected template optimizes the resources in
the switch to support this level of features for
8 routed interfaces and 1024 VLANs.
number of unicast mac addresses: 6K
number of IPv4 IGMP groups + multicast routes: 1K
number of IPv4 unicast routes: 8K
number of directly-connected IPv4 hosts: 6K
number of indirect IPv4 routes: 2K
number of IPv4 policy based routing aces: 0
number of IPv4/MAC qos aces: 0.5K
number of IPv4/MAC security aces: 1K
Switch#
```
## 虚拟局域网中继协议VTP
虚拟局域网中继协议VLAN Trunking Protocol, VTP是一个思科专有的二层消息协议a Cisco proprietary Layer 2 messaging protocol 用于管理同一个 VTP 域中交换机上 VLANs 增加、删除及重命名。VTP 允许 VLAN 信息在交换网络the switched network上宣告/扩散propagate这将减轻交换网络中的管理开销, 同时使得众多的交换机能够交换exchange并维护一致的 VLAN 信息。此概念在图 3.5 中进行了演示。
!["VTP 更新"](0305.png)
图 3.5 -- VTP 更新
采用 VTP 能够得到以下好处。
* VLANs 信息的精确监控和汇报
* 整个网络上 VLANs 的一致性
* 易于添加和移除 VLANs
### 配置 VTP, configuring VTP
要让交换机进行 VLAN 信息交换,这些交换机就务必要配置在同一个 VTP 域中,如下面的输出这样。
<pre>
Switch(config)#vtp mode server ←this is on by default
Switch(config)#vtp domain in60days
Changing VTP domain name from NULL to in60days
Switch#show vtp status
VTP Version : 2
Configuration Revision : 0
Maximum VLANs Supported Locally : 255
Number of Existing VLANs : 5
VTP Operating Mode : Server
VTP Domain Name : <b>in60days</b>
</pre>
如要安全的传输 VTP 更新数据,可以为其加上一个口令,但要求 VTP 域中的每台交换机的口令都要匹配。
```
Switch(config)#vtp password Cisco321
Setting device VLAN database password to Cisco321
```
### VTP 模式, VTP Modes
VTP 以下列三种模式允许。
* 服务器模式(默认模式), server(default)
* 客户端模式, client
* 透明模式, transparent
上面的输出中,你可以看到配置中有个服务器模式。
__服务器模式 Server Mode__
在服务器模式时该交换机被授权去__建立、修改及删除整个 VTP 域上的 VLAN 信息__。你对服务器所做的任何修改都会扩散到整个域中。而 __VLAN 配置是保存在位于闪存中的 VLAN 数据库文件 “vlan.dat” 中的__
__客户端模式Client Mode__
处于客户端模式下的交换机,将会接收 VTP 信息,并根据收到的通告信息做出配置上的改变,而不能增加、移除或是改变它们的 VLAN 信息了。客户端交换机也会在它们的中继端口上,发出接收到的 VTP 数据包。记住,你是不能将客户端交换机的某个端口,添加到 VTP 服务器上不存在的 VLAN 中去的。__VLAN 配置也是保存在位于闪存中的 VLAN 数据库文件 “vlan.dat” 中的__。
__透明模式Transparent Mode__
透明模式下的交换机,将在它们的中继端口上转发接收到的 VTP 信息,却不会应用通告的更新。一台 VTP 透明模式交换机a VTP Transparent-mode switch 是可以创建、修改并移除 VLANs 的, 但其 VLAN 配置变动不会通告给其它交换机。__VTP 透明模式仍然需要域信息配置项__。当处于 VTP 服务器与客户端之间的某台交换机,需要有不同的 VLAN 数据库时,它就需要是一台 VTP 透明交换机。__而要配置上扩展的 VLAN 编号范围the extended VLAN range也要用到透明模式__。
### VTP 修剪, VTP Pruning
时常会出现这样的情形,比如说,在网络的一边有 VLANs 20 到 50, 另一边有 VLANs 60 到 80。而一边的那些交换机上的 VLAN 信息却又无需传送到另一边的那些交换机上。为此,交换机能够将它们的 VLAN 信息进行修剪,因此而减少广播流量,如图 3.6 所示。
!["运行中的 VTP 修剪"](0306.png)
图 3.6 -- 运行中的 VTP 修剪
下面这行配置将 VTP 修剪功能加入到你的交换机。
`Switch(config)#vtp prunning`
而当你将一台处于其它两台交换机之间的交换机设置为透明模式时,该配置就没有任何意义了,透明模式交换机上的 VTP 修剪不会运行。
### 配置修订号Configuration Revision Number
配置修订号the configuration revision number是一个 32 位整数,用以表明一个 VTP 数据包的修订级别(在上面的 `show vtp status` 输出中可以看到)。此信息用于判断收到的信息是否与当前版本要新。你每次此处于 VTP 服务器模式的交换机上做出 VLAN 变动时,配置修订号就会加 1, 同时变动会通告给 VTP 客户端(处于 VTP 透明模式的交换机,其修订号会是 0, 且不会随 VLAN 数据库的变动而增大。__修改 VTP 域名称然后又改回早前的名称可以实现交换机配置修订号重置__。
> __重要提示__ 当以匹配的 VTP 域名,同时有着较高修订号的一台交换机被配置为 VTP 服务器,或者 VTP 客户端而接入到网络中时,它的数据库将会被通告给其它交换机,进而潜在地将它们各自现有的 VTP 数据库进行替换。这有可能会将整个局域网拖垮,所以在将一台新交换机连入到局域网时,一定要小心谨慎(总是要检查检查当前的 VTP 状态)。
## VLAN 故障排除基础, Basic VLAN Troubleshooting
VLANs 是一种相当直观的交换机特性,它很少需要进行故障排除。你所发现的问题,大部分都是人为配置错误。在第 15 天的课程中,我们会详细讲到二层故障排除。而一些常见的涉及 VLAN 的问题有这些。
1. <u>VLAN 间路由无效Inter-VLAN routing not working</u>: 检查交换机之间的链路、路由器都是正确设置的,以及相关的 VLANs 允许通过且未被修剪(参照 “VTP 修剪” 部分)。`show interface trunk` 命令将提供所需信息。还要检查路由器子接口有配置了正确的封方式和 VLAN同时子接口的 IP 地址是那些主机的默认网关。
2. <u>无法创建 VLANs VLANs cannot be created</u>: 检查交换机的 VTP 模式是否被设置成了 “client”。在 VTP 模式为 “client” 时,是不能创建 VLANs 的。另一个重要原因是交换机所允许的 VLANs 编号。`show vtp status` 命令将提供所需的信息(参看下的“中继和 VTP 故障排除”部分)。
3. <u>同一 VLAN 中的主机之间不能通信Hosts within the same VLAN cannot reach each other</u>: 重要的是某 VLAN 中的主机都要有一个属于同一子网的 IP 地址。如子网不同,它们之间就无法通信。另一个需要考虑的原因是这些主机是否都是连接到同一台交换机上。如它们不是连接到同一交换机,就要确保交换机之间的中继链路工作正常,还要确保该 VLAN 未在允许清单中被排除/被修剪[ensure that the trunk links(s) between the switches is/are working correctly and that the VLAN is not excluded/not pruned from the allowed list]。`show interface trunk` 命令将给出有关该中继链路的所需信息。
## 中继和 VTP 故障排除Troubleshooting Trunking and VTP
下面是一些问题实例机器可能的解决方法。
* 中继宕掉?
* 接口务必要是 up/up
* 中继链路两端的封装方式要匹配
<pre>
SwitchA#show interface fa1/1 switchport
Name: Fa1/1
<b>Switchport: Enabled</b>
<b>Administrative Mode: trunk</b>
Operational Mode: trunk
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: dot1q
Negotiation of Trunking: Disabled
Access Mode VLAN: 0 ((Inactive))
</pre>
* VLAN 信息未有传输
* 该 VLAN 在中继链路上阻塞了吗
`Switch#show interface trunk`
* VTP 信息无法到达 VTP 客户端
* VTP 域名称密码正确吗?
`show vtp status / show vtp password`
* 在增加一台新的交换机后,所有 VTP 信息都变动了
* 总是客户端模式加入新的交换机但请查看上面的有关“配置修订号the configuration revision number”的提示
* 服务器模式将通告新信息
* VTP 修剪无效
* 中间是否有一台透明交换机?
* 该 VLAN 允许通过该中继链路?
## VLAN 间路由故障排除, Troubleshooting Inter-VLAN Routing
VLAN 间路由故障可以多种形式出现,尤其是考虑在该过程中涉及多种设备(交换机、路由器等)。通过下面给出的适当故障排除方法论,你就能够将问题孤立在某台特定设备上,接着再其对应到一个错误配置的具体特性。
从连通性立足点上看,下面这些情事都应该检查一下。
* 检查一下终端主机连接了正确的交换机端口
* 检查一下正确的交换机端口连接了正确的路由器端口(如使用了一台路由器做 VLAN 间路由)
* 检查一下在此过程中所涉及到的每个端口承载的是正确的 VLANs
* 连接终端站的那些端口,通常是被分配到一个特定 VLAN 的接入端口
* 而将交换机连接至路由器的那些端口,则通常是中继端口
在确认设备之间的连通性无误后逻辑上下一步就是检查二层配置了__以所配置的中继端口上的封装方式开始__, 这通常是作为首选的 802.1Q 封装方式。接着就要确保中继链路两端都是配置了同样的封装方式。
可用于查看封类型的一些命令有以下这些。
* `show interface trunk`
* `show interface <number> switchport`
这里有个输出示例。
<pre>
Cat-3550-1#show interfaces trunk
Port Mode Encapsulation Status Native vlan
Fa0/1 on <b>802.1q</b> trunking 1
Fa0/2 on <b>802.1q</b> trunking 1
Port Vlans allowed on trunk
Fa0/1 1,10,20,30,40,50
Fa0/2 1-99,201-4094
</pre>
命令 `show interface trunk` 提供的另一重要细节是中继状态。从中继状态可以看出中继是否形成同时在链路两端都要检查中继状态。如果接口未处于“中继”模式那么接口的运行模式on, auto, 等是最重要的检查项以弄清接口能否允许与链路另一端形成中继态a trunking state
中继端口上另外一个需要检查的重要元素便是原生 VLAN。原生 VLAN 错误配置可能带来功能缺失,抑或安全问题。中继链路的两端的原生 VLAN 需要匹配。
假如在完成二层检查任务后VLAN 间路由问题仍然存在,你就可以继续进行三层配置检查了。依据用于实现 VLAN 间路由的三层设备,可能会在下列设备上进行配置及配置检查。
* 多层交换机multilayer switch
* 路由器 -- 物理接口, router -- physical interfaces
* 路由器 -- 子接口router -- subinterfaces
三层设备上应该检查一下其各接口或者交换机虚拟接口SVI都有分配的正确的子网同时如有必要你还应检查一下路由协议。通常情况下各个 VLAN 都有分配不同的子网,所以你应确保你未曾错误配置了接口。而为检查此项,你可以对特定物理接口、子接口或是 SVI使用 `show interface` 命令。
## 第三天的问题
1. Name four advantages of using VLANs.
2. Hosts in the same VLAN can be in different subnets. True or false?
3. An access link is part of more than one VLAN. True or false?
4. Name the two trunk link encapsulation types.
5. Which commands will configure and name a VLAN?
6. A trunk link on a switch can be in which five possible modes?
7. Which command would put your interface into VLAN 5?
8. Which command will change the native VLAN?
9. VTP Client mode allows you to configure VLANs. True or false?
10. Name three benefits of using VTP.
11. Which command configures VTP pruning on your switch?
## 第三天问题的答案
1. Containing Broadcasts within a smaller group of devices will make the network faster; saves resources on devices because they process less Broadcasts; added security by keeping devices in a certain group (or function) in a separate Broadcast domain; and flexibility in expanding a network across a geographical location of any size.
2. True, but not recommended.
3. False.
4. 802.1Q and ISL.
5. The `vlan x` and `name y` commands.
6. On, off, auto, desirable, and nonegotiate.
7. The `switchport access vlan 5` command.
8. The `switchport trunk native vlan x` command.
9. False.
10. Accurate monitoring and reporting of VLANs; VLAN consistency across the network; and ease of adding and removing VLANs.
11. The `vtp pruning` command.
## 第三天的实验
### VLAN 和中继实验
__拓扑图Topology__
![](0300.png)
__实验目的Purpose__
学习如何配置 VLANs 以及中继链路。
__实验步骤Walkthrough__
1. 你需要在每台 PC 上添加 IP 地址。可自由选择,只要求它们在同一子网上。
2. 在交换机 A 上设置主机名hostname, 创建 VLAN 2, 并将连接 PC 的那个接口放到 VLAN 2 中。如你愿意,你也可以赋予 VLAN 2 一个名称。
<pre>
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname SwitchA
SwitchA(config)#vlan 2
SwitchA(config-vlan)#name 60days
SwitchA(config-vlan)#interface FastEthernet0/1
SwitchA(config-if)#switchport mode access
SwitchA(config-if)#switchport access vlan 2
SwitchA(config-if)#^Z
SwitchA#show vlan brief
VLAN Name Status Ports
---- --------- -------------------------------
1 default active Fa0/2, Fa0/3, Fa0/4, Fa0/5,
Fa0/6, Fa0/7, Fa0/8, Fa0/9,
Fa0/10, Fa0/11, 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
<b>2 60days active Fa0/1</b>
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
SwitchA#
</pre>
3. 将中继链路设置为中继模式。
<pre>
SwitchA#conf t
Enter configuration commands, one per line. End with CNTL/Z.
SwitchA(config)#int FastEthernet0/2
SwitchA(config-if)#switchport mode trunk
SwitchA#show interface trunk
Port Mode Encapsulation Status Native vlan
Fa0/2 on 802.1q trunking 1
Port Vlans allowed on trunk
<b>Fa0/2 1-1005</b>
</pre>
4. 如你愿意,设置在该中继链路上仅允许 VLAN 2。
<pre>
SwitchA(config)#int FastEthernet0/2
SwitchA(config-if)#switchport trunk allowed vlan 2
SwitchA(config-if)#^Z
SwitchA#
%SYS-5-CONFIG_I: Configured from console by console
SwitchA#show int trunk
Port Mode Encapsulation Status Native vlan
Fa0/2 on 802.1q trunking 1
Port Vlans allowed on trunk
<b>Fa0/2 2</b>
</pre>
5. 此时,如你自其中一台 PC ping 往另一台,将会失败。这是因为一边是在 VLAN 1 中,另一边在 VLAN 2 中。
```
PC>ping 192.168.1.1
Pinging 192.168.1.1 with 32 bytes of data:
Request timed out.
Ping statistics for 192.168.1.1:
Packets: Sent = 2, Received = 0, Lost = 2 (100% loss)
```
6. 此时在交换机 B 上配置同样的那些命令。创建 VLAN、将交换机 PC 端口放入 VLAN 2并将该接口设置为接入模式还要将中继链路设置为 “中继”。
7. 现在你就可以从一台 PC 实现跨越中继链路 ping 通另一 PC 了。
```
PC>ping 192.168.1.1
Pinging 192.168.1.1 with 32 bytes of data:
Reply from 192.168.1.1: bytes=32 time=188ms TTL=128
Reply from 192.168.1.1: bytes=32 time=78ms TTL=128
Reply from 192.168.1.1: bytes=32 time=94ms TTL=128
Reply from 192.168.1.1: bytes=32 time=79ms TTL=128
Ping statistics for 192.168.1.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 78ms, Maximum = 188ms, Average = 109ms
```
### VTP 实验
在一个又两台交换机组成的拓扑中,实验今天所提到的那些 VTP 配置命令。
* 将其中一台交换机配置为 VTP 服务器
* 将另一台交换机配置为 VTP 客户端
* 在两台交换机上配置同样的 VTP 域及口令the same VTP domain and password
* 在服务器交换机上创建一系列的 VLANs然后观察它们是如何彼此之间是如何通告的
* 在两台交换机上都配置 VTP 修剪VTP pruning
* 在两台交换机上检查(展示) VTP 配置
* 在两台交换机上配置不同的 VTP 域及口令,并重复上述过程;观察结果的不同

BIN
40.png Normal file

Binary file not shown.

After

(image error) Size: 290 KiB

BIN
41.png Normal file

Binary file not shown.

After

(image error) Size: 266 KiB

BIN
42.png Normal file

Binary file not shown.

After

(image error) Size: 241 KiB

BIN
43.png Normal file

Binary file not shown.

After

(image error) Size: 202 KiB

BIN
44.png Normal file

Binary file not shown.

After

(image error) Size: 300 KiB

BIN
45.png Normal file

Binary file not shown.

After

(image error) Size: 258 KiB

BIN
46.png Normal file

Binary file not shown.

After

(image error) Size: 208 KiB

BIN
47.png Normal file

Binary file not shown.

After

(image error) Size: 169 KiB

BIN
48.png Normal file

Binary file not shown.

After

(image error) Size: 121 KiB

BIN
49.png Normal file

Binary file not shown.

After

(image error) Size: 54 KiB

BIN
50.png Normal file

Binary file not shown.

After

(image error) Size: 303 KiB

BIN
60days-1.png Normal file

Binary file not shown.

After

(image error) Size: 131 KiB

BIN
60days-10.png Normal file

Binary file not shown.

After

(image error) Size: 20 KiB

BIN
60days-11.png Normal file

Binary file not shown.

After

(image error) Size: 82 KiB

BIN
60days-12.png Normal file

Binary file not shown.

After

(image error) Size: 14 KiB

BIN
60days-13.png Normal file

Binary file not shown.

After

(image error) Size: 40 KiB

BIN
60days-14.png Normal file

Binary file not shown.

After

(image error) Size: 100 KiB

BIN
60days-15.png Normal file

Binary file not shown.

After

(image error) Size: 46 KiB

BIN
60days-16.png Normal file

Binary file not shown.

After

(image error) Size: 111 KiB

BIN
60days-17.png Normal file

Binary file not shown.

After

(image error) Size: 68 KiB

BIN
60days-18.png Normal file

Binary file not shown.

After

(image error) Size: 88 KiB

BIN
60days-19.png Normal file

Binary file not shown.

After

(image error) Size: 326 KiB

BIN
60days-2.png Normal file

Binary file not shown.

After

(image error) Size: 201 KiB

BIN
60days-20.png Normal file

Binary file not shown.

After

(image error) Size: 231 KiB

BIN
60days-21.png Normal file

Binary file not shown.

After

(image error) Size: 190 KiB

BIN
60days-22.png Normal file

Binary file not shown.

After

(image error) Size: 37 KiB

BIN
60days-23.png Normal file

Binary file not shown.

After

(image error) Size: 46 KiB

BIN
60days-24.png Normal file

Binary file not shown.

After

(image error) Size: 41 KiB

BIN
60days-25.png Normal file

Binary file not shown.

After

(image error) Size: 58 KiB

BIN
60days-26.png Normal file

Binary file not shown.

After

(image error) Size: 47 KiB

BIN
60days-27.png Normal file

Binary file not shown.

After

(image error) Size: 65 KiB

BIN
60days-28.png Normal file

Binary file not shown.

After

(image error) Size: 82 KiB

BIN
60days-3.png Normal file

Binary file not shown.

After

(image error) Size: 182 KiB

BIN
60days-32.png Normal file

Binary file not shown.

After

(image error) Size: 144 KiB

BIN
60days-33.png Normal file

Binary file not shown.

After

(image error) Size: 65 KiB

BIN
60days-34.png Normal file

Binary file not shown.

After

(image error) Size: 79 KiB

BIN
60days-35.png Normal file

Binary file not shown.

After

(image error) Size: 100 KiB

BIN
60days-36.png Normal file

Binary file not shown.

After

(image error) Size: 82 KiB

BIN
60days-37.png Normal file

Binary file not shown.

After

(image error) Size: 94 KiB

BIN
60days-4.png Normal file

Binary file not shown.

After

(image error) Size: 35 KiB

BIN
60days-5.png Normal file

Binary file not shown.

After

(image error) Size: 46 KiB

BIN
60days-6.png Normal file

Binary file not shown.

After

(image error) Size: 95 KiB

BIN
60days-7.png Normal file

Binary file not shown.

After

(image error) Size: 84 KiB

BIN
60days-8.png Normal file

Binary file not shown.

After

(image error) Size: 63 KiB

BIN
60days-9.png Normal file

Binary file not shown.

After

(image error) Size: 40 KiB

View File

@ -1 +1,4 @@
# 60天通过思科认证的网络工程师考试
60 通过 CCNA
=======
本书结合了学习技巧,包括阅读、复习、背书、测试以及 hands-on 实验。

8
SUMMARY.md Normal file
View File

@ -0,0 +1,8 @@
# Summary
* [introduction](README.md)
* [第一天 -- 网络、线缆、OSI 以及 TCP 模型](chapter1.md)
* [第二天 -- CSMA/CD, 交换和虚拟局域网](2nd_chapter.md)
* [第三天 -- 中继、DTP 及 VLAN 间路由](3rd_day.md)
* [第四天--路由器和交换机安全](chapter04.md)

933
chapter04.md Normal file
View File

@ -0,0 +1,933 @@
# 路由器和交换机安全Router and Switch Security
## 第四天任务
* 阅读今天的课文(接下来的)
* 复习昨天的课文
* 完成今天的实验
* 阅读 ICND1 记诵指南
购买的交换机和路由器都是没有任何安全配置的。依据业务需求,你需要添加这些配置。令到交换机安全的那些命令和过程,与路由器的是大致一样的。现在我们就要移步到这些防止意外或是恶意登入及重新配置你的路由器,从而确保其安全的操作步骤上来。
我在思科公司的第一份工作是在核心团队。涉及在访问控制列表access control lists, ACL、IOS 升级、灾难恢复及相关任务等方面,的客户支持。最初打击到我的事情,就是有那么多的工程师没有采用口令将其路由器进行锁定。而这些人中很多就是用 “password” 或者 “cisco” -- 两个最容易猜到的,作为口令,简直不敢想象。
在本书的这一章,我们看看在所有网络上,为了保护你的路由器,你应该做的几个基本步骤。
今天你会学到以下几点。
* 物理访问的防护, Protecting physical access
* 远程登入防护Telnet access
* Enable 模式防护Protecting Enable mode
* 路由器日志记录Router logging
* 交换机安全加固Securing the switch
本章覆盖以下的 CCNA 大纲要求。
* 配置和检查网络设备的以下安全特性
* 设备口令安全device password security
* Enable 秘密与 enable, Enable secret versus enable
* 传入transport
* 关闭 Telnet, disable telnet
* 安全壳, Secure SHell, SSH
* 虚拟终端VTYs
* 物理安全Physical security
* 服务口令service password
* 描述不同的外部认证方式describe external authentication methods
* 配置并检查交换机端口安全特性,比如以下这些。
* MAC 地址绑定sticky MAC
* MAC 地址限制MAC address limitation
* 静态/动态static/dynamic
* 危害模式violation modes
* 错误关闭err disable
* 关闭端口shutdown
* 受限保护protect restrict
* 关闭未使用端口shutdown unused ports
* 错误关闭恢复err disable recovery
* 将未使用端口指派到一个未使用 VLAN 中assign unused ports to an unused VLAN
* 将原生 VLAN 设置成非 VLAN 1, set native VLAN to something other than VLAN 1
* 配置并验证 NTP 客户端
## 物理访问防护Protecting Physical Access
在某个公司因失去网络接入而出现灾难性后果时,你常发现他们的路由器竟然实在某人的办公桌下,这是多么的令人惊奇啊。
网络设备应该安放在一间有密码锁的安全房间里,最起码也应该锁起来。思考路由器可是非常贵重的设备,也是小偷炙手可热的目标。网络规模越大,设备就越值钱,同时数据保护与路由器配置文件的保护需求也越高。
## 控制台访问
控制台接口是设计用于提供到路由器的物理访问的以__完成路由器的初始设置及灾难恢复__。任何能取得控制台访问的人都能够完全擦出或是重新配置这些文件因此__控制台接口应有一个口令进行保护可以简单地添加一个口令也可以为其添加一个本地用户名和口令__如下面所示。
* 只添加一个口令即可
```
Router(config)#line console 0
Router(config-line)#password cisco
Router(config-line)#login
```
* 为控制台添加一个本地用户名和口令组合
```
Router(config)#username paul password cisco
Router(config)#line console 0
Router(config-line)#login local
```
你还可以为控制台(以及虚拟终端)线路创建一个超时值,如此就可以在确定的时间过后断开连接。默认的超时是 5 分钟。
```
Router(config)#line console 0
Router(config-line)#exec-timeout ?
<0-35791> Timeout in minutes
Router(config-line)#exec-timeout 2 ?
<0-2147483> Timeout in seconds
<cr>
Router(config-line)#exec-timeout 2 30
Router(config-line)#
```
## 远程登陆访问Telnet Access
在某人给远程登陆或者说虚拟终端线路添加了口令之前,你实际上是不能远程登陆进一台路由器的。同样,你可以给虚拟终端线路添加一个口令,或是告诉路由器去查找一个本地用户名及口令组合(该组合可以在配置文件中,或是存储在一台 RADIUS/TACACS 服务器上),如下面所示。
<pre>
Router(config-line)#line vty 0 15
Router(config-line)#password cisco
Router(config-line)#login ← or login local
</pre>
下面的输出是自某台路由器到另一台的远程登陆会话。当你获得远程登陆访问时,你可以看到主机名发生了改变。注意在你输入口令时,它看不到。
```
Router1#telnet 192.168.1.2
Trying 192.168.1.2 ...Open
User Access Verification
Username: paul
Password:
Router2>
```
而如你有一个安全版 IOS 镜像,则可以将路由器配置为仅允许安全壳访问,而不是远程登陆访问。这样做的好处在于所有数据都是加密了的。如你在启用安全壳后,再次使用远程登时,连接将被终止。
```
Router1(config)#line vty 0 15
Router1(config-line)#transport input ssh
Router2#telnet 192.168.1.2
Trying 192.168.1.2 ...Open
[Connection to 192.168.1.2 closed by foreign host]
```
## 使能模式保护Protecting Enable Mode
使能模式enable mode取得路由器的配置访问因此你会想要保护该模式。你可以配置一个__使能秘密an enable secret或使能口令an enable password__。实际上使能秘密和使能口令是可以同时有的但这是一个坏主意。
使能口令是未加密的,所以在路由器配置中可以看到。而使能秘密有 5 级加密(level 5 encryption, MD5),难于破解。自 15.0(1S 后的较新 IOS 版本中,还可以使用比 MD5 加密高级的 4 级加密level 4 encryption, SHA256, 5 级加密最终会不赞成使用。你可以给使能口令加上命令 `service password-encryption`, 但因为此方式使用 7 级加密(level 7 encryption, 比如低安全性思科称其为“背后安全性over the shoulder security”, 因其仅需某人从你背后偷看并记住一个稍难的词组,便可以用网上的 7 级口令解密工具予以破解),而很容易被破解。下面的输出中可以看到 7 级与 5 级加密文本。
<pre>
Router(config)#enable password cisco
Router(config)#exit
Router#show run
<b>enable password cisco</b>
Router(config)#enable password cisco
Router(config)#service password-encryption
Router#show run
<b>enable password 7 0822455D0A16</b>
Router(config)#enable secret cisco
Router(config)#exit
Router#show run
<b>enable secret 5 $1$mERr$hx5rVt7rPNoS4wqbXKX7m0</b>
</pre>
记住如你忘记了使能口令你将不得不对路由器或交换机进行一下__口令恢复操作__。请用 Google 搜索你所使用的型号,因为型号不同其口令恢复过程也不一样。对于路由器来说,涉及
* 设备重启,以及
* 在重启过程中按下指定的中断键盘按键
* 再设置配置寄存器the configuration register以跳过启动配置文件通常将配置寄存器设置为 0x2142
* 接着要执行一个 `copy start-config running-config` 命令
此时,就可以创建新的口令了。
而对交换机来说,口令恢复过程会有一点复杂(请再次用 Google 搜索你用到的具体交换机型号),但也可以通过一个小把戏实现口令恢复 -- 在给交换机上电时,按住 MODE 按钮 8 秒钟。交换机将以空白配置启动,而上一次的启动配置(the last startup configuration)将保存在 flash 中的 config.text.renamed 文件里头,所以该文件可复制用于运行配置(running configuration),然后用其它口令对其进行修改。
## 用户访问防护Protecting User Access
思科 IOS 提供对用户的单独用户名及口令,同时对所能够使用的命令进行清单限制的能力。这在分层次网络支持时是有用的。下列输出中给出了一个示例。
```
RouterA#config term
Enter configuration commands, one per line. End with CNTL/Z.
RouterA(config)#username paul password cisco
RouterA(config)#username stuart password hello
RouterA(config)#username davie password football
RouterA(config)#line vty 0 4
RouterA(config-line)#login local
RouterA(config-line)#exit
RouterA(config)#exit
```
你__可在路由器上指派不同用户帐号的访问级别__。比如你也许打算那些初级网络团队成员仅能使用一些基本的故障排除命。你还有必要记住思科路由器有口令安全的两种模式two modes of password security用户模式Exec mode和特权模式Enable mode
思科路由器有可供配置的 16 种0 到 15不同特权级别其中 15 级是完全的访问权限,如下所示。
<pre>
RouterA#conf t
Enter configuration commands, one per line. End with CNTL/Z.
RouterA(config)#username support privilege 4 password soccer
LINE Initial keywords of the command to modify
RouterA(config)#privilege exec level 4 ping
RouterA(config)#privilege exec level 4 traceroute
RouterA(config)#privilege exec level 4 show ip interface brief
RouterA(config)#line console 0
RouterA(config-line)#password basketball
RouterA(config-line)#login local <b>← password is needed</b>
RouterA(config-line)#^z
</pre>
支持那人在登入到路由器并尝试进入配置模式时,此命令及其它命令将不可用且无效,也不能看到。
<pre>
RouterA con0 is now available
Press RETURN to get started.
User Access Verification
Username: support
Password:
RouterA#config t <b>← not allowed to use this</b>
^
% Invalid input detected at ^ marker.
</pre>
你可在路由器提示符下查看默认的不同特权级别(the default privilege levels)。
```
Router>show privilege
Current privilege level is 1
Router>en
Router#show priv
Router#show privilege
Current privilege level is 15
Router#
```
## 更新 IOS updating the IOS
公认地,更新 IOS 有时会将漏洞或故障引入你的网络中因此如你有与思科公司有个技术支持合同a TAC contract, Technical Assistance Centre, TAC), 那么最好的做法就是依据思科公司的建议来做。一般来讲,保持 IOS 版本最新是高度推荐的做法。藉由更新 IOS 你能得到下面这些好处。
* 修正已知的软件缺陷fixed known bugs
* 解决安全隐患cloese security vulnerabilities
* 提供特性强化及 IOS 能力提升Offers enhanced features and IOS capabilities
## 路由器日志记录Router Logging
路由器提供事件记录的能力。它们可将日志消息照你的意愿发送到屏幕或某台服务器。你应该记录路由器消息而又__有 8 个可用的日志记录严重程度级别__考试要求你知道这些不同的级别如下面输出中的粗体字所示。
<pre>
logging buffered ?
`<0-7>`Logging severity level
<b>alerts</b>—Immediate action needed (severity=1)
<b>critical</b>—Critical conditions (severity=2)
<b>debugging</b>—Debugging messages (severity=7)
<b>emergencies</b>—System is unusable (severity=0)
<b>errors</b>—Error conditions (severity=3)
<b>informational</b>—Informational messages (severity=6)
<b>notifications</b>—Normal but significant conditions (severity=5)
<b>warnings</b>—Warning conditions (severity=4)
</pre>
而你有可以将这些日志消息发往几个不同的地方。
```
Router(config)#logging ?
A.B.C.D IP address of the logging host
buffered Set buffered logging parameters
console Set console logging parameters
host Set syslog server IP address and parameters
on Enable logging to all enabled destinations
trap Set syslog server logging level
userinfo Enable logging of user info on privileged mode enabling
```
日志消息通常会在你经由控制台进入到路由器时,显示在屏幕上。而这可能会在你敲入配置命令时多少有些烦人。这里就有个在我输入一个命令(加了下划线的那条)时,被一条控制台日志消息(a console logging message)给中断了的例子。
<pre>
Router(config)#int f0/1
Router(config-if)#no shut
Router(config-if)#end
Router#
*Jun 27 02:06:59.951: %SYS-5-CONFIG_I: Configured from console by console <u>show ver</u>
*Jun 27 02:07:01.151: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
</pre>
此时你既可以用命令 `no logging console` 关闭日志消息输出,也可以用 `logging synchronous` 命令将它们设置为无中断not interrupt `logging synchronous` 命令会重新输入在被日志消息中断之前,你所输入的那行命令。`logging synchronous` 命令在虚拟终端线路上也是可用的。
```
Router(config)#line con 0
Router(config-line)#logging synchronous
Router(config-line)#
Router(config-line)#exit
Router(config)#int f0/1
Router(config-if)#shut
Router(config-if)#exit
Router(config)#
*Jun 27 02:12:46.143: %LINK-5-CHANGED: Interface FastEthernet0/1, changed state to
administratively down
Router(config)#exit
```
这里值得一提的是,在你经由 Telnet (或 SSH) 进入到路由器时你是不会看到控制台输的。如你想在此时看到日志消息__执行 `terminal monitor` 命令__即可。
## 简单网络管理协议Simple Network Management Protocol, SNMP
__SNMP 是一种可用于远程管理网络的_服务___。它由一台网络管理员维护、运行了 SNMP 管理软件的中心工作站及包括路由器、交换机及服务器等的各台网络设备上的小文件代理agents构成。
包括 HP、Cisco、IBM 及 SolarWinds 等的几家厂商,都有设计 SNMP 软件。也有很多开发源代码版本的 SNMP 软件可用。这类软件允许你监测设备的带宽及活动情况,比如登陆活动以及端口状态等。
运用 SNMP 你可以远程地配置或是关闭端口和设备。你也可以将其配置在某些条件触发时,诸如出现高带宽或是端口宕掉时,发出警告消息。我们会在第 40 天来讲 SNMP 的细节,因为 SNMP 是 ICND2 大纲的部分。
## 加固交换机Securing the Switch
### 阻止远程登陆访问Prevent Telnet Access
远程登陆流量以明文方式发送口令,这就是说,可轻易地在配置中读取口令,或是有人接到你的网络上,那么就能通过网络嗅探软件查看到口令。
默认情况下,远程登陆实际上是关闭的(也就是说,你需要为其设置一个口令,也可选择设置一个用户名,来让其工作)。不过,如你仍想要有对管理端口的远程访问的话,你可使用命令 `transport input ssh`, 开启到交换机的 SSH 通信,这已在前面讨论过了。
> Farai 说 -- “所有虚拟终端线路下,命令 `transport input all` 是默认开启的,而其它线路的 `transport input none` 命令是默认开启的。”
### 开启 SSH Enable SSH
尽可能地采用 SSH 而不是 Telnet 及 SNMP 来访问你的交换机。SSH 表示安全壳(secure shell), 令到某网络上的两台设备之间信息的安全交换。SSH 采用公钥加密法pubic-key cryptography来认证连接设备。Telnet 及 SNMP 版本 1 和 2 都是未加密的易受包嗅探packet sniffing的影响 SNMP 版本 3 提供了保密性 -- 数据包有加密以防止恶意源窃取数据snooping by an unauthorised source
要开启 SSH 你需要有一个支持加密的 IOS 版本。一种快速找出 IOS 镜像是否支持加密的方法是执 `show version` 命令。查找镜像文件名中有无 `k9` 字样,或者在思科系统公司的安全性声明中查找有关字句。
<pre>
Switch#sh version
Cisco IOS Software, C3560 Software (C3560-ADVIPSERVICES K9-M), Version
12.2(35)SE1, RELEASE SOFTWARE (fc1)
Copyright (c) 1986-2006 by Cisco Systems, Inc.
Compiled Tue 19-Dec-06 10:54 by antonio
Image text-base: 0x00003000, data-base: 0x01362CA0
ROM: Bootstrap program is C3560 boot loader
BOOTLDR: C3560 Boot Loader (C3560-HBOOT-M) Version 12.2(25r)SEC, RELEASE
SOFTWARE (fc4)
Switch uptime is 1 hour, 8 minutes
System returned to ROM by power-on
System image file is “flash:/c3560-advipservices<b>k9</b>-mz.122-35.SE1.bin”
<b>This product contains cryptographic features</b> and is subject to United States and local
country laws governing import, export, transfer and use. Delivery of Cisco cryptographic
products does not imply third-party authority to import, export, distribute or use
encryption. Importers, exporters, distributors and users are responsible for compliance
with U.S. and local country laws. By using this product you agree to comply with
applicable laws and regulations. If you are unable to comply with U.S. and local laws,
return this product immediately. A summary of U.S. laws governing Cisco cryptographic
products may be found at:
http://www.cisco.com/wwl/export/crypto/tool/stqrg.html
If you require further assistance please contact us by sending email to export@cisco.com.
--More-
</pre>
> __注意:__ 如你没有带有安全特性版本的 IOS你就必须为此付费购买。
为建立加密连接你需要在交换机上创建一对公钥和私钥a private/public key, 见下面)。在连接时,你这边使用公钥加密数据,交换机将会使用它的私钥来解密数据。而在认证时,使用你所选择的用户名/口令组合。下一个问题是要设置交换机的主机名和域名hostname and domain name, 因为在创建公钥/私钥对时,会用到主机名.域名命名法hostname.domainname nomenclature。显然在命名主机名和域名时将其命名为能够代表系统的有意义名字是好的做法。
首先,你要给交换机一个与默认主机名 Switch 不一样的主机名。接着,添加其域名(该域名通常与 Windows 活动目录的 FQDN 一致。这时就可以创建用于秘密的密钥the crypto key了。系数/模量the modulus 是指你所希望使用的密钥的长度,取值范围是 360 到 2048, 后者具有最高的安全性;高于 1024 位的模量就认为是安全的了。此时,交换机上的 SSH 就已经开启了。
有一些 SSH 相关的维护命令需要输入。`ip ssh time-out 60` 命令会将任何空闲 60 秒的 SSH 连接置为超时。而命令 `ip ssh authentication-retries 2` 则会在认证失败两次的 SSH 连接重置为初始状态。此设置并不会阻止用户建立新的连接并重试认证。设置过程如下所示。
```
Switch(config)#hostname SwitchOne
SwitchOne(config)#ip domain-name mydomain.com
SwitchOne(config)#crypto key generate rsa
Enter modulus: 1024
SwitchOne(config)#ip ssh time-out 60
SwitchOne(config)#ip ssh authentication-retries 2
```
可使用命令 `ip ssh version 2` 开启 SSH 版本 2。让我们看看其中一个密钥。在这个实例中该密钥是为 HTTPS 生成的。因为其是在开启 HTTPS 时自动生成的,所以其名称也会自动产生。
```
firewall#show crypto key mypubkey rsa
Key name: HTTPS_SS_CERT_KEYPAIR.server
Temporary key
Usage: Encryption Key
Key is not exportable.
Key Data:
306C300D 06092A86 4886F70D 01010105 00035B00 30580251 00C41B63 8EF294A1
DC0F7378 7EF410F6 6254750F 475DAD71 4E1CD15E 1D9086A8 BD175433 1302F403
2FD22F82 C311769F 9C75B7D2 1E50D315 EFA0E940 DF44AD5A F717BF17 A3CEDBE1
A6A2D601 45F313B6 6B020301 0001
```
要验证交换机上的 SSH 开启,输入以下命令。
```
Switch#show ip ssh
SSH Enabled - version 1.99
Authentication timeout: 120 secs; Authentication retries: 2
Switch#
```
而用一个简单的命令,就可以关闭 HTTP 访问。
`Switch(config)#no ip http server`
查看交换机上 HTTP 服务器的状态。
<pre>
Switch#show ip http server status
HTTP server status: <b>Disabled</b>
HTTP server port: 80
HTTP server authentication method: enable
HTTP server access class: 0
HTTP server base path: flash:html
Maximum number of concurrent server connections allowed: 16
Server idle time-out: 180 secondsServer life time-out: 180 seconds
Maximum number of requests allowed on a connection: 25
HTTP server active session modules: ALL
HTTP secure server capability: Present
HTTP secure server status: Enabled
HTTP secure server port: 443
HTTP secure server ciphersuite: 3des-ede-cbc-sha des-cbc-sha rc4-128-md5 rc4-12
HTTP secure server client authentication: Disabled
HTTP secure server trustpoint:
HTTP secure server active session modules: ALL
</pre>
还可以在 VTY 线路上应用控制列表an access control list, ACL。在第 9 天的课程将会讲到。
### 设置使能秘密口令Set an Enable Secret Password
全局配置模式允许用户对交换机或路由器进行配置还可以擦除配置以及重置口令。你务必要设置一个口令或秘密口令来保护此模式而这实际上是为阻止用户闯过get past用户模式。一般口令在路由器配置文件中会显示出来`enable secret` 口令则会进行加密。
上面已经提到你实际上可以在交换机或路由器上同时设置使能口令a password和使能秘密口令enable secret password,但这会带来混乱。所以__请只设置使能秘密口令__就好。下面的配置文件演示了__通过在命令前键入 `do` 关键字而无需回到特权模式就可执行该命令__的情形。
<pre>
Switch1(config)#enable password cisco
Switch1(config)#do show run
Building configuration...
Current configuration: 1144 bytes
hostname Switch1
<b>enable password cisco</b>
</pre>
> Farai 补充道 -- “你可以使用 `service password-encryption` 命令,对使能口令 `enable password` 进行 7 级加密。”
通过在命令前加上 `no` 关键字后再次执行该命令,可以擦除配置文件中的大多数行。上面 Farai 提到的使用 `service password-encryption` 命令是毫无作用的因为这个方法仅提供了弱加密7 级), 而下面的秘密口令the secret password则有着强加密MD5
<pre>
Switch1(config)#no enable password
Switch1(config)#enable secret cisco
Switch1(config)#do show run
Building configuration...
Current configuration: 1169 bytes
hostname Switch1
<b>enable secret 5 $1$mERr$hx5rVt7rPNoS4wqbXKX7m0</b> [strong level 5 password]
</pre>
### 服务Services
你总是应该关闭那些你不会用到的服务。思科已经在关闭那些不安全和很少用到的服务和协议上做得很好了;尽管如此,你可能会要因明确这点而亲自关闭它们。同样也会有一些服务是有帮助的。多数服务可在全局配置模式中的 `service` 命令下找到。
```
Switch(config)# service ?
compress-config Compress the configuration file
config TFTP load config files
counters Control aging of interface counters
dhcp Enable DHCP server and relay agent
disable-ip-fast-frag Disable IP particle-based fast fragmentation
exec-callback Enable EXEC callback
exec-wait Delay EXEC startup on noisy lines
finger Allow responses to finger requests
hide-telnet-addresses Hide destination addresses in telnet command
linenumber enable line number banner for each exec
nagle Enable Nagles congestion control algorithm
old-slip-prompts Allow old scripts to operate with slip/ppp
pad Enable PAD commands
password-encryption Encrypt system passwords
password-recovery Disable password recovery
prompt Enable mode specific prompt
pt-vty-logging Log significant VTY-Async events
sequence-numbers Stamp logger messages with a sequence number
slave-log Enable log capability of slave IPs
tcp-keepalives-in Generate keepalives on idle incoming network
connections
tcp-keepalives-out Generate keepalives on idle outgoing network
connections
tcp-small-servers Enable small TCP servers (e.g., ECHO)
telnet-zeroidle Set TCP window 0 when connection is idle
timestamps Timestamp debug/log messages
udp-small-servers Enable small UDP servers (e.g., ECHO)
```
一般来讲,有下列的这些最常见的要开启或关闭的服务。其各自的说明在中括号里。
* `no service pad` [数据包组装程序/分拆程序,在异步组网中有使用;很少使用到]
* `no service config` [阻止交换机从网络获取其配置文件]
* `no service finger` [关闭 finger 服务器;很少用到]
* `no ip icmp redirect` [组织 ICMP 重定向,而 ICMP 重定向可被用于路由器投毒]
* `no ip finger` [关闭 finger 服务的另一种方式]
* `no ip gratuitous-arps` [关闭此服务以阻止中间人攻击man-in-the-middle attacks]
* `no ip source-route` [关闭由用户提供到目的地的逐跳路由(user-provided hop-by-hop routing to destination)]
* `service sequence-numbers` [在每条日志记录中,分配给其一个编号,同时此编号序列增加]
* `service tcp-keepalive-in` [防止路由器将挂起的管理会话一直保持开启prevents the router from keeping hung management sessions open]
* `service tcp-keepalive-out` [与 `sevice tcp-keepalive-in` 功能一样]
* `no service upp-small-servers` [关闭 `echo, chargen, discard, daytime` 等功能,这些功能很少用到]
* `no service tcp-small-servers` [关闭 `echo, chargen, discard` 等功能,这些功能很少用到]
* `service timestamps debug datetime localtime show-timezone` [在调试模式下in debug mode, 将每个记录的数据包,使用本地时间,打上日期和时间的时间戳,并显示时区]
* `service timestamps log datetime localtime show-timezone` [在非调试模式下not in debug mode, 将每个记录的数据包,使用本地时间,打上日期和时间的时间戳,并显示时区 -- 这服务在查看日志文件非常有用,尤其是在时钟设置正确的情况下]
### 修改原生 VLAN Change the Native VLAN
交换机使用原生 VLAN 来承载那些特定的协议流量诸如思科发现协议Cisco Discovery Protocol, CDP、VLAN 中继协议VLAN Trunking Protocol, VTP、端口聚合协议Port Aggregation Protocol, PAgP以及动态中继协议Dynamic Trunking Protocol, DTP等协议信息。默认原生 VLAN 总是 VLAN 1; 但原生 VLAN 是可以手动设置为任何有效 VLAN 编号(除开 0 和 4096, 因为这些 VLAN 编号处于 VLANs 的保留范围)。
你可以使用下面输出中演示的命令(在每个接口下执行的),来查看原生 VLAN。
<pre>
Switch#show interfaces FastEthernet0/1 switchport
Name: Fa0/1
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)
<b>Trunking Native Mode VLAN: 1 (default)</b>
Voice VLAN: none
</pre>
__将端口放入 VLAN 1 被认为是一种安全漏洞a security vulnerability__, 允许黑客取得网络资源的访问。为减轻此问题,避免任何主机放入 VLAN 1 是一种明智可取的做法。同时也可将所有中继接口上的原生 VLAN 修改为某个未使用的 VLAN。
`Switch(config-if)#switchport trunk native vlan 888`
> __注意__这是 CCNA 大纲中的一个关键目标one of the key objectives, 所以务必牢记。
你还可以用下面的命令,来阻止原生 VLAN 上的数据通过中继链路。
`Switch(config-if)#switchport trunk allowed vlan remove 888`
### 修改管理 VLAN, Change the Management VLAN
给交换机配置一个 IP 地址以实现为管理目的而远程登陆到其上也是可以的。这又叫做交换机虚拟接口Switch Virtual Interface, SVI。将该管理访问做到除 VLAN 1 之外的其它 VLAN 上,是一种明智的预防措施,如下面的输出所示。
```
Switch(config)#vlan 3
Switch(config-vlan)#interface vlan3
%LINK-5-CHANGED: Interface Vlan3, changed state to up
Switch(config-if)#ip address 192.168.1.1 255.255.255.0
```
### 关闭 CDP, Turn Off CDP
后面会讲到思科发现协议Cisco Discovery Protocol, CDP, 但在这里,你要知道,在大多数的路由器和交换机上的每个接口下,该协议都是打开的,这也是通行的做法,其功能是发现路由器或交换机上连接的思科设备。你可能不打算让其它思科设备看到你的网络设备的信息,那么就可以关掉这个服务,至少应该在那些你的网络边缘上的,连接其它公司或者 ISP 的那些设备上关闭 CDP。
> Farai 指出 -- “CDP 在比如 ASR 路由器的所有平台上默认都未开启。”
在下面的输出中,你能看到一台连接我的交换机的路由器,在我执行 `show cdp neighbor detail` 命令时,其能看见哪些基本信息。
```
Router#show cdp neighbor detail
Device ID: Switch1
Entry address(es):
Platform: Cisco 2960, Capabilities: Switch
Interface: FastEthernet0/0, Port ID (outgoing port): FastEthernet0/2
Holdtime: 176
Version :
Cisco Internetwork Operating System Software
IOS (tm) C2960 Software (C2960-I6Q4L2-M), Version 12.1(22)EA4, RELEASE SOFTWARE(fc1)
Copyright (c) 1986-2005 by Cisco Systems, Inc.
Compiled Wed 18-May-05 22:31 by jharirba
advertisement version: 2
Duplex: full
Router#
```
下面的命令将对整个设备关闭 CDP。
`Switch1(config)#no cdp run`
而要对某个特定接口关闭 CDP 执行以下命令。
```
Switch1(config)#int FastEthernet0/2
Switch1(config-if)#no cdp enable
```
### 添加横幅消息Add a Banner Message
横幅消息将于某用户登入路由器或交换机时显示出来。其并不会提供任何实质性的安全,但会显示你设置的警告信息。在下面的配置中,我选择的是 “Y” 字母作为界定符delimiting character, 界定符用以告诉路由器,我已输完消息文字。
```
Switch1(config)#banner motd Y
Enter TEXT message. End with the character Y.
KEEP OUT OR YOU WILL REGRET IT Y
Switch1(config)#
```
在我从交换机登入到路由器时,我能看到横幅消息。错在选择了 “Y” 作为界定符,因为它割除了我的消息文字。
```
Router#telnet 192.168.1.3
Trying 192.168.1.3 ...Open
KEEP OUT OR
```
横幅消息可以是以下这些。
* 在用户看到登陆提示符之前显示出来 -- MOTDmessage of the day
* 在用户看到登陆提示符之前显示出来 -- Login
* 在登陆提示符之后显示给用户 -- Exec (在你打算对未授权用户隐藏的信息)
在本书中,横幅消息作为一些实验的组成部分。我建议你掌握全部三种类型横幅消息,并以登入路由器的方式来测试它们。依据你所用的平台和 IOS会有不同的选择。
```
Router(config)#banner ?
LINE c banner-text c, where c is a delimiting character
exec Set EXEC process creation banner
incoming Set incoming terminal line banner
login Set login banner
motd Set Message of the Day banner
prompt-timeout Set Message for login authentication timeout
slip-ppp Set Message for SLIP/PPP
```
### 设置 VTP 口令, Set a VTP Password
VTP 确保网络上交换机之间传输的是精确的 VLAN 信息。而为了保护 VLAN 信息的更新,你应该在交换机上加入 VTP 口令(该 VTP 域中所有交换机上的 VTP 口令都应一致), 如下面输出演示的那样。
```
Switch1(config)#vtp domain 60days
Changing VTP domain name from NULL to 60days
Switch1(config)#vtp password cisco
Setting device VLAN database password to cisco
Switch1(config)#
```
### 限定 VLAN 信息, Restrict VLAN Infaomation
默认下的交换机允许所有 VLANs 通过中继链路。你将其修改为指定 VLANs 才能通过中继链路。如下面的输出所示。
<pre>
Switch1(config)#int FastEthernet0/4
Switch1(config-if)#switchport mode trunk
Switch1(config-if)#switchport trunk allowed vlan ?
WORD VLAN IDs of the allowed VLANs when this port is in trunking mode
add add VLANs to the current list
all all VLANs
except all VLANs except the following
none no VLANs
remove remove VLANs from the current list
Switch1(config-if)#switchport trunk allowed vlan 7-12
Switch1#show interface trunk
Port Mode Encapsulation Status Native vlan
Fa0/4 on 802.1q trunking 1
Port Vlans allowed on trunk
<b>Fa0/4 7-12</b>
</pre>
### 端口因出错关闭后的恢复功能Error Disable Recovery
由一系列的事件导致的思科交换机将其端口置为一种特别的关闭模式a special diabled mode, 叫做出错关闭err-disabled。此特性简单来讲由于在某个特定端口上发生某种错误后该端口就被关闭了。错误可能有多种原因之最常见的就是出现触发了某项端口安全策略a port security policy。在某个未授权用户尝试连接到某个交换机端口时这是通常的做法它阻止那些违规设备访问网络。
出错关闭端口(an err-disabled port看起来会是这样的。
<pre>
Switch# show interface f0/1
FastEthernet0/1 is down, line protocol is down <b>[err-disabled]</b>
.....
</pre>
而为了重新使用re-activate某个出错关闭接口以在该接口上执行 `shutdown``no shutdown` 命令的人工干预是必要的, 网络工程师们俗称此操作为端口弹跳(a bouncing the port)。但是某些情形要求从原端口状态自动恢复过来而不是等到管理员手动开启该端口。此出错关闭回复模式通过将交换机配置为在依引发通信失败事件的不同而不同的一段时间后自动重新打开出错关闭端口的方式来发挥作用。区分通信失败事件提供了出错关闭恢复功能所监测事件上的粒度granularity控制。
完成该功能设置的命令是 `errdisable recovery cause`, 在全局路由器配置模式下输入。
```
Switch(config)#errdisable recovery cause ?
all Enable timer to recover from all causes
bpduguard Enable timer to recover from bpdu-guard error disable state
dtp-flap Enable timer to recover from dtp-flap error disable state
link-flap Enable timer to recover from link-flap error disable state
pagp-flap Enable timer to recover from pagp-flap error disable state
rootguard Enable timer to recover from root-guard error disable state
udld Enable timer to recover from udld error disable state
......
```
`errdisable recovery cause` 命令依设备型号会有所不同,但最常见的参数有这些。
* all
* arp-inspection
* bpduguard
* dhcp-rate-limit
* link-flap
* psecure-violation
* security-violation
* storm-control
* udld
多数平台上端口自动恢复的默认时间是 300 秒,此时间可以用全局配置命令 `errdisable recovery interval` 手动修改。
```
Switch(config)#errdisable recovery interval ?
<30-86400> timer-interval(sec)
```
而命令 `show errdisable recovery` 命令则会提供有关出错关闭恢复功能the err-disable recovery function激活了的那些特性的细节信息以及受到监测的接口并包含了接口重新开启剩余时间。
<pre>
Switch#show errdisable recovery
ErrDisable Reason Timer Status
----------------- --------------
arp-inspection Disabled
bpduguard Disabled
channel-misconfig Disabled
dhcp-rate-limit Disabled
dtp-flap Disabled
gbic-invalid Disabled
inline-power Disabled
l2ptguard Disabled
link-flap Disabled
mac-limit Disabled
link-monitor-failure Disabled
loopback Disabled
oam-remote-failure Disabled
pagp-flap Disabled
port-mode-failure Disabled
psecure-violation <b>Enabled</b>
security-violation Disabled
sfp-config-mismatch Disabled
storm-control Disabled
udld Disabled
unicast-flood Disabled
vmps Disabled
Timer interval: 300 seconds
Interfaces that will be enabled at the next timeout:
Interface Errdisable reason Time left(sec)
--------- ----------------- --------------
Fa0/0 psecure-violation <b>193</b>
</pre>
### 外部认证方式External Authentication Methods
与本地存储不同,你可以采用一台通常运行了 AAA 或 TACACS+ 的服务器来存储用户名和口令。这么做的优势在于,你无需在每台路由器和交换机上都手动输入用户名和口令。而是将其存储在服务器的数据库中。
TACACS+ 表示“加强版终端访问控制器访问控制系统Terminal Access Controller Access Control System Plus, TACACS+)”。它是一个思科专有协议,使用 TCP 49 号端口。__TACACS+ 提供了经由一台或多台 TACACS+ 中心服务器对包含路由器及网络介入服务器等网络设备的访问控制__。
__拨入用户远端认证服务Remote Authentication Dial-In User Service, RADIUS__, 是一套__分布式网络安全系统__用以确保网络远程访问的安全性同时它又__是一个使用 UDP 的客户端/服务器协议a client/server protocol。RADIUS 是开放标准__。
如你拥有 TACACS+ 或者 RADIUS那么你可能希望开启认证、授权和记账Authentication, Authorization, and Accounting, AAA。AAA 是安装在一台服务器上的,它监测着网络的一个用户帐号数据库。用户访问、协议、连接,以及断开原因,及其它很多特性都能被监测到。
路由器和交换机可被设置为在某用户尝试登入时查询服务器。服务器此时来验证用户。__CCNA 考试不要求你去配置这些协议__。
### 路由器时钟及 NTP Router Clock and NTP
交换机上的时间经常被忽略但它却是重要的。在你遇到安全入侵security violations、SNMP 问题SNMP traps, 或者事件记录时,会用到时间戳。如交换机上的时间不正确,就会难于找出时间发生的时间。举个例子,让我们看看下面的交换机,并检查一下它的时间。
```
Switch#show clock
*23:09:45.773 UTC Tue Mar 2 1993
```
该时间是不准确的,所以我们要修改一下。但首先,我们要设置一些属性值。
```
clock timezone CST -6
clock summer-time CDT recurring
clock summer-time CST recurring 2 Sun Mar 2:00 1 Sun Nov 2:00
```
首先我们设置时区the time zone。我是位于中部时区the Central time zone 比 GMT 要早 6 个小时。接着告诉交换机夏令时时间变化the time change是循环的。最后设置夏令时具体是什么。此时我们就可以设置时间和日期了。
```
Switch#clock set 14:55:05 June 19 2007
Switch#
1d23h: %SYS-6-CLOCKUPDATE: System clock has been updated from 17:26:01 CST
Tue Mar 2 1993 to 14:55:05 CST Tue Jun 19 2007, configured from console by console.
Switch#show clock
14:55:13.858 CST Tue Jun 19 2007
```
请注意__时钟设置实在使能模式Enable mode而不是配置模式下__。除了手动设置时钟外你可以使用网络时间协议Network Time Protocol, NTP。它让你可将交换机的时钟与某台原子钟an atomic clock同步保证非常精确的时间。
```
Switch(config)#ntp server 134.84.84.84 prefer
Switch(config)#ntp server 209.184.112.199
```
使用下面的两个命令,你可以查看时钟是否已经和 NTP 源保持同步。
```
Switch#show ntp associations
Switch#show ntp status
```
在第 40 天中,我们会涉及更多有关 NTP 的内容。
## 关闭未用到的那些端口Shut Down Unused Ports
未使用的,或者说“空起的”那些没有任何网络设备的端口,因为某人会插入一条网线并将未授权设备连接到网络,而引发安全威胁。这会导致一些安全问题,包括。
* 网络未能如同与其的那样运作
* 网络信息暴露于外部人员
这就是为何你要关闭路由器、交换机及其它网络设备上,所有未使用端口的原因。依据具体设备,关闭状态可能是端口默认的状态,但你仍要对此进行验证。
而关闭端口是通过在__接口配置模式__下使用 `shutdown` 命令完成的。
```
Switch#conf t
Switch(config)#int fa0/0
Switch(config-if)#shutdown
```
验证某端口处于关闭状态有多种方法,其一就是使用 `show ip interface brief` 命令。
<pre>
Router(config-if)#do show ip interface brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 unassigned YES unset <b>administratively down</b> down
FastEthernet0/1 unassigned YES unset administratively down down
</pre>
请注意__管理性关闭__状态就是说该端口是手工关闭的。验证关闭状态的另一方法是使用 `show interface` 命令。
<pre>
Router#show interface fa0/0
FastEthernet0/0 is <b>administratively down</b>, line protocol is down
Hardware is Gt96k FE, address is c200.27c8.0000 (bia c200.27c8.0000)
MTU 1500 bytes, BW 10000 Kbit/sec, DLY 1000 usec,
......
</pre>
## 思科发现协议, Cisco Discovery Protocol, CDP
现在来讨论思科发现协议正是时候。
CDP 因为其在做出任何配置之前就提供了一种发现有关网络设备信息的方法而是__一个热门的考试考点__。它是一直非常有用的故障排除工具但它又带来了安全威胁。
CDP 是一个思科专有协议也就是说它只运行在思科设备上。它是__一种二层服务__, 设备用它来通告和接收那些直接连接设备的基本信息。IEEE 版本的 CDP 叫做__链路层发现协议Link Layer Discovery Protocol, LLDP__, CCNA 大纲并不包含此内容。
因为 CDP 是一种二层服务所以它__并不需要配置有 IP 地址来交换信息__。只需开启接口就行。如有配置 IP 地址,该 IP 地址也会包含进 CDP 消息中。
CDP 作为非常强大的故障排除工具,考试中要求你掌握如何来使用它。图 4.1 展示了 Router 0 的 CDP 输出。请设想一下在没有拓扑图topology diagram的情况下你要对此网络进行故障排除的情形。
!["Router 0 的 CDP 输出"](0401.png)
图 4.1 -- Router 0 的 CDP 输出
下列配置输入,正是图 4.1 中的。
```
Router0#show cdp neighbors
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge, S - Switch, H -
Host, I - IGMP, r - Repeater, P - Phone
Device ID Local Interface Holdtime Capability Platform Port
Switch Fas 0/0 165 S 2960 Fas 0/1
Router Fas 0/1 169 R C1841 Fas 0/0
Router0#
```
在上述命令的后面加上 `detail` 命令,你可以看到更多信息。
```
Router0#show cdp neighbors detail
Device ID: Switch
Entry address(es):
Platform: cisco 2960, Capabilities: Switch
Interface: FastEthernet0/0, Port ID (outgoing port): FastEthernet0/1
Holdtime: 178
Version :
Cisco IOS Software, C2960 Software (C2960-LANBASE-M), Version 12.2(25)FX, RELEASE
SOFTWARE (fc1)
Copyright (c) 1986-2005 by Cisco Systems, Inc.
Compiled Wed 12-Oct-05 22:05 by pt_team
advertisement version: 2
Duplex: full
---------------------------
Device ID: Router
Entry address(es):
IP address : 192.168.1.2
Platform: cisco C1841, Capabilities: Router
Interface: FastEthernet0/1, Port ID (outgoing port): FastEthernet0/0
Holdtime: 122
Version :
Cisco IOS Software, 1841 Software (C1841-ADVIPSERVICESK9-M), Version 12.4(15)T1, RELEASE
SOFTWARE (fc2)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2007 by Cisco Systems, Inc.
Compiled Wed 18-Jul-07 04:52 by pt_team
advertisement version: 2
Duplex: full
```
现在你可以看到 IOS 版本、型号、IP 地址以及其它信息。记住现在你仍未在 Router 0 上配置 IP 地址。
前面我们已经讲过怎样在整台设备或仅在某个接口上关闭 CDP 了。而另两个有关命令是显示设备有关 CDP 的协议信息的 `show cdp` 命令,以及通过输入设备名称来查看某台具设备信息的 `show cdp entry <Router>` 命令。建议在今天要配置的实验中花些时间,来查看 CDP 的众多输出。
```
Router0#show cdp
Global CDP information:
Sending CDP packets every 60 seconds
Sending a holdtime value of 180 seconds
Sending CDPv2 advertisements is enabled
Router0#show cdp ?
entry Information for specific neighbor entry
interface CDP interface status and configuration
neighbors CDP neighbor entries
traffic CDP statistics
| Output modifiers
<cr>
```
## 交换机端口安全Switch Port Security
端口安全特性,是通过限制某个特定端口或是接口能够学习到的 MAC 地址数目,来保护交换机端口安全,并最终确保 CAM 表的安全的一项Catalyst 交换机的有力特性。具备了端安全特性,交换机就能够维护一张用于明确哪个 MAC 地址(或哪些地址),可以接入哪些本地交换机端口的表格。此外,交换机同样可以配置为仅允许在任何给定的端口上学习到指定数量的 MAC 地址。端口安全如图 4.2 所示。
!["端口安全的运作"](0402.png)
图 4.2 -- 端口安全的运作
图 4.2 展示了在某台 Catalyst 交换机上,通过端口安全特性配置的 4 个端口,它们都只允许单一 MAC 地址接入。从 1 号到 3 号端口连接的 MAC 地址与端口安全所允许的地址匹配。在没有其它过滤的情况下,这些主机就能够经由其各自交换机端口转发流量。而端口 4 上所配置的是允许 AAAA.0000.0004 MAC 地址,但所接入的 MAC 地址却是 BBBB.0000.0001。因为主机 MAC 地址与所允许的 MAC 不一样端口安全port security将在端口上做出如同管理员所设定的适当动作。这些有效端口安全动(the valid port security actions)作将在接下来的部分详细说明。
__端口安全特性__设计用于保护交换局域网the switched LAN免受两种主要的攻击方式。这两种方式在下的小节讲到。
* CAM 表溢出攻击, CAM table overflow attacks
* MAC 欺骗攻击, MAC spoofing attacks
### CAM 表溢出攻击
交换机的 CAM 表是一些存储位置,这些存储位置包含了物理端口上的那些 MAC 地址,及其 VLAN 参数。交换机 CAM 表中动态学习到的内容,或者说 MAC 地址表,可通过命令 `show mac-address-table dynamic` 查看到,如下面的输出所示。
```
VTP-Server-1#show mac-address-table dynamic
Mac Address Table
-------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- -----
2 000c.cea7.f3a0 DYNAMIC Fa0/1
2 0013.1986.0a20 DYNAMIC Fa0/2
6 0004.c16f.8741 DYNAMIC Fa0/3
6 0030.803f.ea81 DYNAMIC Fa0/4
8 0004.c16f.8742 DYNAMIC Fa0/5
8 0030.803f.ea82 DYNAMIC Fa0/6
Total Mac Addresses for this criterion: 6
```
如同所有的计算装置一样,交换机的存储资源也是有限的。这就意味着 __CAM 表的存储空间是固定的已分配好的__

1754
chapter1.md Normal file

File diff suppressed because it is too large Load Diff

BIN
l-0.png Normal file

Binary file not shown.

After

(image error) Size: 70 KiB

BIN
noname-0.png Normal file

Binary file not shown.

After

(image error) Size: 50 KiB

BIN
q-0.png Normal file

Binary file not shown.

After

(image error) Size: 96 KiB