【实验拓扑】
图1
【实验步骤】
步骤1. 将PC1、PC2、PC3、PC4的IP地址设在同一个子网192.168.1.0/24,对应地址为1、2、3、4,在PC4上分别ping其他三台计算机(如在真实环境中,无需这步)。
用“ipconfig IP地址 掩码”来设置计算机的IP地址,例如:ipconfig 192.168.1.2 255.255.255.0。用“ipconfig /all”来查看计算机的MAC地址以及IP参数的配置。假设计算机对应的MAC地址表如下:
计算机 Pc1 Pc2 Pc3 Pc4
MAC地址 0004.9A2B.4082 00D0.FFE1.D80D 00D0.FFBD.C514 0001.639A.8921 步骤2. 查看交换机A的MAC地址表,验证是否动态获取到了四台PC的MAC地址。
SwitchA#show mac-address-table !查看交换机的MAC地址表 Mac Address Table
------------------------------------------- Vlan Mac Address Type Ports ---- ----------- -------- ----- 1 0004.9A2B.4082 DYNAMIC Fa0/24 1 0001.639A.8921 DYNAMIC Fa0/23
- 11 -
1 00D0.FFE1.D80D DYNAMIC Fa0/24 1 00D0.FFBD.C514 DYNAMIC Fa0/24
结论:
步骤3. 将PC3接到0/22端口,验证是否动态维护(更新)MAC地址表。
SwitchA#show mac-address-table !查看交换机的MAC地址表 Mac Address Table
------------------------------------------- Vlan Mac Address Type Ports ---- ----------- -------- ----- 1 0004.9A2B.4082 DYNAMIC Fa0/24 1 0001.639A.8921 DYNAMIC Fa0/23
1 00D0.FFE1.D80D DYNAMIC Fa0/24 1 00D0.FFBD.C514 DYNAMIC Fa0/22
结论:
步骤4. 设置交换机MAC地址表的老化时间
SwitchA#conf t
SwitchA(config)# mac-address-table aging-time 180
注意:模拟器不能设置老化时间
步骤5. 删除动态MAC地址。
SwtichA#clear mac-address-table dynamic
SwitchA#show mac-address-table !查看交换机的MAC地址表 Mac Address Table
------------------------------------------- Vlan Mac Address Type Ports ---- ----------- -------- -----
步骤6. 在PC4上分别ping其他三台计算机,动态获取MAC地址表。
SwitchA#show mac-address-table !查看交换机的MAC地址表 Mac Address Table
------------------------------------------- Vlan Mac Address Type Ports ---- ----------- -------- ----- 1 0004.9A2B.4082 DYNAMIC Fa0/24 1 0001.639A.8921 DYNAMIC Fa0/23
1 00D0.FFE1.D80D DYNAMIC Fa0/24
- 12 -
1 00D0.FFBD.C514 DYNAMIC Fa0/22
步骤7. 过3分钟,再查看MAC地址表,验证地址表是否过期。
SwitchA#show mac-address-table !查看交换机的MAC地址表 Mac Address Table
------------------------------------------- Vlan Mac Address Type Ports ---- ----------- -------- -----
步骤8. 添加交换机的静态地址表,把PC3的MAC地址静态加到F0/24端口
SwitchA#conf t
SwitchA(config)# mac-address-table static 00D0.FFBD.C514 vlan 1 interface
fastethernet 0/24
SwitchA#show mac-address-table !查看交换机的MAC地址表 Mac Address Table
------------------------------------------- Vlan Mac Address Type Ports ---- ----------- -------- ----- 1 0004.9A2B.4082 DYNAMIC Fa0/24 1 0001.639A.8921 DYNAMIC Fa0/23 1 00D0.FFE1.D80D DYNAMIC Fa0/24 1 00D0.FFBD.C514 STATIC Fa0/24
结论:静态地址优于动态的地址
步骤9. 将PC3直接移到SwitchA的f0/1端口,观察MAC地址表
SwitchA#show mac-address-table
SwitchA#show mac-address-table !查看交换机的MAC地址表 Mac Address Table
------------------------------------------- Vlan Mac Address Type Ports ---- ----------- -------- ----- 1 0004.9A2B.4082 DYNAMIC Fa0/24 1 0001.639A.8921 DYNAMIC Fa0/23 1 00D0.FFE1.D80D DYNAMIC Fa0/24 1 00D0.FFBD.C514 STATIC Fa0/24
步骤10. 用PC4 ping其他三台计算机,不能和PC3通信。 【问题】
PC4为何不能和PC3通信?
- 13 -
实验一(3)交换机端口的基本配置
【实验目的】
掌握交换机端口的常用配置参数。 【背景描述】
你是某公司网管,现公司有部分主机网卡属于10Mbit/s网卡,传输模式为半双工,为了能够实现主机之间的正常访问和管理,现把和主机相连的交换机端口速率设为10Mbit/s,传输模式设为半双工,并设置该端口的描述信息为“To PCA”。 【技术原理】
交换机Fastethernet接口默认情况下是10Mbit/s或100Mbit/s自适应端口,双工模式也为自适应。默认情况下,所有交换机端口均开启。 交换机Fastethernet接口支持端口速率、双工模式的配置。 【实现功能】
配置交换机端口的速率,双工模式和描述,并进行有效查看。 【实验拓扑】
图 1
注:在进行网络连接时,主机的网卡用直连线和交换机连接,注意查看主机连接在交换机的哪个端口,针对该端口进行参数的设置。
【实验步骤】
步骤一、交换机端口参数的配置。
switch> enable
switch# configure terminal
switch(config)#interface fastethernet 0/3 !进行F0/3的端口模式 switch(config-if)#speed 10 !配置端口速率为10M
switch(config-if)#duplex half !配置端口的双工模式为半双工
- 14 -
switch(config-if)#description To PCA !配置端口的描述信息
switch(config-if)#no shutdown !开启该端口,使端口转发数据
注:配置端口速率参数有100(100Mbit/s)、10(10Mbit/s)、auto(自适应),默认是auto。 注:配置双式模式有full(全双工)、half(半双工)、auto(自适应),默认是auto。
步骤二、查看交换机端口的配置信息。
switch#show interface fastethernet 0/3
FastEthernet0/3 is up, line protocol is up (connected)
Hardware is Lance, address is 00e0.f966.4617 (bia 00e0.f966.4617) Description: To PCA
MTU 1500 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) Half-duplex, 10Mb/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 \
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
0 input errors, 0 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
【注意事项】
交换机端口在默认情况下是开启的,如果该端口没有实际连接其他设备,line protocol是down状态。 【实验结论】
- 15 -