交换机实验之交换机基本配置、交换机端口的基本配置、管理MAC地址表

交换机实验

实验一、交换机基本配置

实验拓扑:

 

实验步骤:

•进入交换机的第一个模式为用户模式,系统提示符为  switch>

•switch> Enable      

!进入特权模式(可以对交换机的配置文件进行管理,查看配置信息,进行网络测试和调试等)

•Switch#configure terminal   !进入全局配置模式(可以配置交换机的全局性参数)

•Switch(config)#Interface fastethernet  0/5   

!进入交换机f0/5的端口配置模式(可以对于该端口进行参数配置)

•Switch(config-if)# Exit    !退回到上一级操作模式

•Switch(config-if)# End     !直接退回特权模式

提示信息:

•switch>? !显示当前模式下所有可执行的命令

•switch#co? !显示当前模式下所有co开头的命令

•switch#copy ? !显示copy命令后可执行的参数

命令的简写

•Switch#conf  term !交换机命令行支持命令的简写,该命令代表configure terminal

 

实验结果截图:

 

实验二

交换机设备名称配置

实验拓扑:

 

实验步骤:

•switch> enable

•switch# configure terminal   !进入全局配置模式

•switch(config)# hostname 105_switch !配置交换机的设备名称为105_switch

!设置系统名称,名称必须由可打印字符组成,长度不能超过255个字节。 

•105_switch(config)# end       !回到特权模式。

•105_switch# show running-config  !验证你的配置。

 可以在全局配置模式下使用no hostname来将系统名称恢复位缺省值。

 

/*启动信息*/

 

Switch>enable

Switch#configure terminal

Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)#hostname 105_seitch

105_seitch(config)#end

105_seitch#

%SYS-5-CONFIG_I: Configured from console by console

show running-config

Building configuration...

 

Current configuration : 1082 bytes

!

version 12.2

no service timestamps log datetime msec

no service timestamps debug datetime msec

no service password-encryption

!

hostname 105_seitch

!

!

!

!

!

spanning-tree mode pvst

spanning-tree extend system-id

!

interface FastEthernet0/1

!

interface FastEthernet0/2

!

 

105_seitch#show running-config

Building configuration...

 

Current configuration : 1082 bytes

!

version 12.2

no service timestamps log datetime msec

no service timestamps debug datetime msec

no service password-encryption

!

hostname 105_seitch

!

!

!

!

!

spanning-tree mode pvst

spanning-tree extend system-id

!

interface FastEthernet0/1

!

interface FastEthernet0/2

!

--More—

 

实验结果截图:

 

交换机每日提示信息配置

实验拓扑:

 

 

实验步骤:

•105_switch(config)# banner motd & !配置每日提示信息以&为终止符

2011-08-10 17:20:52 @5-CONFIG:Configured from outband

Enter TEXT message. End with the character ‘&’.

Welcome to 105_switch,if you are admin,you can config it.

If you are not admin,please EXIT! !输入描述信息

& !以&符号结束输入

验证测试:

•105_switch(config)# exit

•105_switch# exit

Press RETURN to get started

Welcome to 105_switch,if you are admin,you can config it.

If you are not admin,please EXIT!

•105_switch>

 

105_switch#configure terminal

Enter configuration commands, one per line. End with CNTL/Z.

105_switch(config)#banner motd &

Enter TEXT message. End with the character '&'.

welcome to 105_switch.if you are admin you can config it.

if you are not admin,please exit!

&

105_switch(config)#exit

105_switch#

%SYS-5-CONFIG_I: Configured from console by console

exit

 

105_switch con0 is now available

Press RETURN to get started.

welcome to 105_switch.if you are admin you can config it.

if you are not admin,please exit!

105_switch>

 

说明:

  1. banber motd & 配置每日提示信息以&为终止符
  2. 输入描述信息以&符号结束
  3. Exit退出重启验证测试

实验结果截图:

中文不可显示,只可显示英文字符。

实验三交换机端口的基本配置

实验拓扑:

 

实验步骤:

1 交换机端口的基本配置

•Switch# configure terminal   

•Switch(config)# Interface fastethernet  0/5       !进入交换机f0/5的端口配置模式

•Switch(config-if)# speed 10  

!配置端口速率为10M,可配参数为100、10、auto(自适应,为默认值

•Switch(config-if)# duplex  half   

!配置端口为半双工模式,可配参数为full、half、auto(默认值)

•Switch(config-if)# no shutdown            !开启端口,使之能转发数据

2 查看交换机端口的配置信息

•Switch# show interface fastethernet 0/5      !查看交换机端口的配置信息

 

 

Switch#configure terminal

Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)#interface fastethernet 0/5

Switch(config-if)#speed 10

Switch(config-if)#duplex half

Switch(config-if)#no shutdown

Switch(config-if)#end

Switch#

%SYS-5-CONFIG_I: Configured from console by console

show interface fastethernet 0/5

FastEthernet0/5 is down, line protocol is down (disabled)

Hardware is Lance, address is 0002.1662.3105 (bia 0002.1662.3105)

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 "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

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

说明:

  1. interface fastethernet 0/5 进入交换机f0/5的端口配置模式
  2. speed 10 配置端口速率为10M,可配置参数为100、10、auto(自适应,默认值)
  3. duplex half 配置端口为半双工模式,可配置参数为full、half、auto(默认值)
  4. no shutdown 开启端口,使之能转发数据
  5. show interface fastethernet 0/5查看交换机端口的配置信息

实验结果截图:

 

实验四查看交换机的系统和配置信息

实验拓扑:

 

实验步骤:

•Switch# show version !查看交换机的版本信息

注意以下信息:

System hardware version !设备的硬件版本信息

System CTRL version !操作系统版本信息

•Switch# show mac-address-table !查看交换机的MAC地址表

•Switch# show running-config !查看交换机当前生效的配置信息

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 Gigabit Ethernet/IEEE 802.3 interface(s)

63488K bytes of flash-simulated non-volatile configuration memory.

Base ethernet MAC Address : 00E0.8FC8.58E3

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

 

 

Switch#show mac-address-table

Mac Address Table

-------------------------------------------

 

Vlan Mac Address Type Ports

---- ----------- -------- -----

 

Switch#show running-config

Building configuration...

 

Current configuration : 1101 bytes

!

version 12.2

no service timestamps log datetime msec

no service timestamps debug datetime msec

no service password-encryption

!

hostname Switch

!

!

!

!

!

spanning-tree mode pvst

spanning-tree extend system-id

!

interface FastEthernet0/1

!

interface FastEthernet0/2

!

interface FastEthernet0/3

!

interface FastEthernet0/4

!

interface FastEthernet0/5

duplex half

speed 10

!

interface FastEthernet0/6

--More--

 

实验结果截图:

 

 

实验五、管理MAC地址表

实验拓扑:

 

没有配置连接之前交换机地址表为空:

 

连接配置完毕后交换表配置信息:

实验步骤:

1、查看地址表

(1) 给计算机Pc0— Pc4配置IP地址,分别是192.168.1.1、192.168.1.2、192.168.1.3 、192.168.1. 4、192.168.1.5。

(2)在计算机上ping一下其他计算机。

(3)在交换机上执行show mac-address-table address命令。

Switch# show mac-address-table   !显示所有类型的MAC地址信息(包括动态地址,静态地址和过滤地址)。

或者Switch#show mac-address-table dynamic     !显示所有动态地址信息。

2、配置一个静态地址

配置一个静态地址00d0.f800.456c,当在VLAN 1中接受到目的地址为这个地址的包时,这个包将被转发到指定的接口FastEthernet 0/3上。

Switch(config)# mac-address-table static 00d0.f800.073c vlan 1 interface FastEthernet0/3

Switch# show mac-address-table   !显示所有类型的MAC地址信息

3、显示指定接口的所有类型的地址信息:

Switch#show mac-address-table interface fastEthernet0/3     ! 显示指定接口的所有类型的地址信息

 

说明:

1、Switch# show mac-address-table address !查看交换机的MAC地址表

address:可以是空、dynamic、static或者interface。

show mac-address-table 用于显示显示所有类型的MAC地址信息

show mac-address-table dynamic显示所有动态地址信息

show mac-address-table static显示所有静态地址信息

show mac-address-table interface显示指定接口的所有类型的地址信息

2、Switch#clear mac-address-table dynamic     !删除交换机上所有的动态地址;

3、Switch(config)#mac-address-table static mac-addr vlan vlan-id interface interface-id                      !添加静态地址

mac-addr : 指定表项对应的目的MAC 地址

vlan-id: 指定该地址所属的VLAN

interface-id:包将转发到的接口(可以是物理端口或Aggregate Port)当交换机在vlan-id 指定的VLAN 上接收到以mac-addr 指定的地址为目的地址的包时, 这个包将被转发到interface-id 指定的接口上。

在全局配置模式下通过命令no mac-address-table static mac-addr vlan vlan-id interface interface-id 来删除一个静态地址表项。

实验结果截图:

 

实验表明隔一段时间之后如果动态地址没有接收或转发消息则会自动清除(当交换机复位后,交换机学习到的所有动态地址都将丢失,交换机需要重新学习这些地址)。

复位后只进行PC0和PC1之间的通信(计算机PC0ping一了下PC1后):

本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须在文章页面给出原文链接,否则保留追究法律责任的权利。
原文地址:https://www.cnblogs.com/study-hard-forever/p/14387318.html