计算机网络实验|交换机的基本配置

交换机的基本配置

【实验目的】
掌握交换机命令行各种操作模式的区别,能够使用各种帮助信息,以及用命令进行基本的配置。

【背景描述】
你是某公司新进的网管,公司要求你熟悉网络产品,公司采用全系列锐捷网络产品,首先要求你登录交换机,了解、掌握交换机的命令行操作技巧,以及如何使用一些基本命令进行配置。

【需求分析】
需要在交换机上熟悉各种不同的配置模式以及如何在配置模式间切换,使用命令进行基本的配置,并熟悉命令行界面的操作技巧。

【实验拓扑】
计算机网络实验|交换机的基本配置_第1张图片
【实验设备】
三层交换机 1 台

【预备知识】
交换机的命令行界面和基本操作

【实验原理】
交换机的管理方式基本分为两种:带内管理和带外管理。通过交换机的 Console 口管理交换机属于带外管理,不占用交换机的网络接口,其特点是需要使用配置线缆,近距离配置。

第一次配置交换机时必须利用 Console 端口进行配置。

交换机的命令行操作模式,主要包括:

  1. 用户模式
    进入交换机后得到的第一个操作模式,该模式下可以简单查看交换机的软、硬件版本信 息,并进行简单的测试。用户模式提示符为 switch>

  2. 特权模式
    由用户模式进入的下一级模式,该模式下可以对交换机的配置文件进行管理,查看交换 机的配置信息,进行网络的测试和调试等。特权模式提示符为switch#

  3. 全局配置模式
    属于特权模式的下一级模式,该模式下可以配置交换机的全局性参数(如主机名、登录 信息等)。在该模式下可以进入下一级的配置模式,对交换机具体的功能进行配置。全局模 式提示符为 switch(config)#

  4. 端口模式
    属于全局模式的下一级模式,该模式下可以对交换机的端口进行参数配置。端口模式提 示符为 switch(config-if)#

交换机的基本操作命令包括:

  1. Exit 命令是退回到上一级操作模式。
  2. End 命令是指用户从特权模式以下级别直接返回到特权模式。
    交换机命令行支持获取帮助信息、命令的简写、命令的自动补齐、快捷键功能。 配置交换机的设备名称和配置交换机的描述信息必须在全局配置模式下执行。
  3. Hostname 配置交换机的设备名称。
    当用户登录交换机时,你可能需要告诉用户一些必要的信息。你可以通过设置标题来达到这个目的。你可以创建两种类型的标题:每日通知和登录标题。
  4. Banner motd 配置交换机每日提示信息 motdmessage of the day。
  5. Banner login 配置交换机登录提示信息,位于每日提示信息之后。
  6. 查看交换机的系统和配置信息命令要在特权模式下执行。
    a)Show version 查看交换机的版本信息,可以查看到交换机的硬件版本信息和软件版本 信息,用于进行交换机操作系统升级时的依据。
    b)Show mac-address-table 查看交换机当前的 MAC 地址表信息。 c)Show running-config 查看交换机当前生效的配置信息。

【实验步骤】
第一步:交换机各个操作模式直接的切换

Swtich>enable
!使用 enable 命令从用户模式进入特权模式
Swtich#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
!使用 configure terminal 命令从特权模式进入全局配置模式
Swtich(config)#interface fastEthernet 0/1
!使用 interface 命令进入接口配置模式
Swtich(config-if)#
Swtich(config-if)#exit
!使用 exit 命令退回上一级操作模式
Swtich(config)#interface fastEthernet 0/2 
Swtich(config-if)#end
Swtich#
!使用 end 命令直接退回特权模式

第二步:交换机命令行界面基本功能

Switch> ?
!显示当前模式下所有可执行的命令
disable		Turn off privileged commands
enable		Turn on privileged commands
exit		Exit from the EXEC
help		Description of the interactive help system

pingSend echo messages
rcommand Run command on remote switch 
show Show running system information
telnet 		Open a telnet connection 
tracerouteTrace route to destination

Swtich>en <tab>
Swtich>enable
!使用 tab 键补齐命令
Swtich#con?
configure connect
!使用?显示当前模式下所有以“con”开头的命令
Swtich#conf t
Enter configuration commands, one per line. End with CNTL/Z. Swtich(config)#
!使用命令的简写 
Swtich(config)#interface ?
!显示 interface 命令后可执行的参数
Aggregateport			Aggregate port interface
Dialer					Dialer interface
FastEthernet 			Fast IEEE 802.3
GigabitEthernet 		Gbyte Ethernet interface
Loopback 				Loopback interface
Multilink				Multilink-group interface
Null					Null interface
Tunnel					Tunnel interface
Virtual-ppp				Virtual PPP interface
Virtual-template 		Virtual Template interface 
Vlan 					Vlan interface
range 					Interface range command

Switch(config)#interface
Swtich(config)#interface fastEthernet 0/1
Switch(config-if)# ^Z
Switch#
!使用快捷键“Ctrl+Z”可以直接退回到特权模式
Switch#ping 1.1.1.1
sending 5, 100-byte ICMP Echos to 1.1.1.1,
timeout is 2000 milliseconds.
. ^C
Switch#

!在交换机特权模式下执行 ping 1.1.1.1 命令,发现不能 ping 通目标地址,交换机默认情况下需要发送 5 个数据包,如不想等到 5 个数据包均不能 ping 通目标地址的反馈出 现,可在数据包未发出 5 个之前通过执行快捷键“Ctrl+C”终止当前操作。

第三步:配置交换机的名称和每日提示信息

Switch(config)#hostname SW-1
!使用 hostname 命令更改交换机的名称 
SW-1(config)#banner motd $
!使用 banner 命令设置交换机的每日提示信息,参数 motd 指定以哪个字符为信息的结束符
Enter TEXT message. End with the character '$'.
Welcome to SW-1, if you are admin, you can config it.
If you are not admin, please EXIT!
$
SW-1(config)#
SW-1(config)#exit
SW-1#Nov 25 22:04:01 %SYS-5-CONFIG_I: Configured from console by console SW-1#exit
SW-1 CON0 is now available
Press RETURN to get started
Welcome to SW-1, if you are admin, you can config it.
If you are not admin, please EXIT!
SW-1>

第四步:配置接口状态

锐捷全系列交换机 Fastethernet 接口默认情况下是 10M/100Mbit/s 自适应端口,双工 模式也为自适应(端口速率、双工模式可配置)。默认情况下,所有交换机端口均开启。

如果网络中存在一些型号比较旧的主机,还在使用 10Mbit/s 半双工的网卡,此时为了 能够实现主机之间的正常访问,应当在交换机上进行相应的配置,把连接这些主机的交换机 端口速率设为 10Mbit/s,传输模式设为半双工。

SW-1(config)#interface fastEthernet 0/1
!进入端口 F0/1 的配置模式
SW-1(config-if)#speed 10
!配置端口速率为 10M
SW-1(config-if)#duplex half
!配置端口的双工模式为半双工
SW-1(config-if)#no shutdown 
!开启端口,使端口转发数据。交换机端口默认已经开启。
SW-1(config-if)#description "This is a Accessport." 
!配置端口的描述信息,可作为提示。
SW-1(config-if)#end
SW-1#Nov 25 22:06:37 %SYS-5-CONFIG_I: Configured from console by console
SW-1#
SW-1#show interface fastEthernet 0/1
Index(dec):1 (hex):1
FastEthernet 0/1 is UP , line protocol is UP
Hardware is marvell FastEthernet
Description: "This is a Accessport."
Interface address is: no ip address
MTU 1500 bytes, BW 10000 Kbit
Encapsulation protocol is Bridge, loopback not set
Keepalive interval is 10 sec , set
Carrier delay is 2 sec
RXload is 1 ,Txload is 1
Queueing strategy: WFQ
Switchport attributes:
interface's description:""This is a Accessport.""
medium-type is copper
lastchange time:329 Day:22 Hour: 5 Minute: 2 Second
Priority is 0
admin duplex mode is Force Half Duplex, oper duplex is Half
admin speed is 10M, oper speed is 10M
flow control admin status is OFF,flow control oper status is OFF
broadcast Storm Control is OFF,multicast Storm Control is OFF,unicast Storm Control is OFF
5 minutes input rate 0 bits/sec, 0 packets/sec
5 minutes output rate 0 bits/sec, 0 packets/sec
0 packets input, 0 bytes, 0 no buffer, 0 dropped
Received 0 broadcasts, 0 runts, 0 giants
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 abort
0 packets output, 0 bytes, 0 underruns , 0 dropped
0 output errors, 0 collisions, 0 interface resets
SW-1#
!如果需要将交换机端口的配置恢复默认值,可以使用 default 命令。
SW-1(config)#interface fastEthernet 0/1
SW-1(config-if)#default bandwidth
!恢复端口默认的带宽设置
SW-1(config-if)#default description
!取消端口的描述信息
SW-1(config-if)#default duplex
!恢复端口默认的双工设置
SW-1(config-if)#end
SW-1#Nov 25 22:11:13 %SYS-5-CONFIG_I: Configured from console by console
SW-1#
SW-1#show interface fastEthernet 0/1
Index(dec):1 (hex):1
FastEthernet 0/1 is UP , line protocol is UP
Hardware is marvell FastEthernet
Interface address is: no ip address
MTU 1500 bytes, BW 100000 Kbit
Encapsulation protocol is Bridge, loopback not set
Keepalive interval is 10 sec , set
Carrier delay is 2 sec
RXload is 1 ,Txload is 1
Queueing strategy: WFQ
Switchport attributes:
interface's description:""
medium-type is copper
lastchange time:329 Day:22 Hour:11 Minute:13 Second
Priority is 0
admin duplex mode is AUTO, oper duplex is Full
admin speed is AUTO, oper speed is 100M
flow control admin status is OFF,flow control oper status is ON
broadcast Storm Control is OFF,multicast Storm Control is OFF,unicast Storm Control is OFF
5 minutes input rate 0 bits/sec, 0 packets/sec
5 minutes output rate 0 bits/sec, 0 packets/sec
0 packets input, 0 bytes, 0 no buffer, 0 dropped
Received 0 broadcasts, 0 runts, 0 giants
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 abort
0 packets output, 0 bytes, 0 underruns , 0 dropped 0 output errors, 0 collisions, 0 interface resets 
SW-1#

第五步:查看交换机的系统和配置信息

SW-1#show version
!查看交换机的系统信息
System description : Ruijie Dual Stack Multi-Layer Switch(S3760-24) By Ruijie Network
!交换机的描述信息(型号等)
System start time : 2008-11-25 21:58:44
System hardware version : 1.0
!设备的硬件版本信息
System software version : RGNOS 10.2.00(2), Release(27932)
!操作系统版本信息
System boot version : 10.2.27014
System CTRL version : 10.2.24136
System serial number : 0000000000000
SW-1#
SW-1#show running-config
!查看交换机的配置信息
Building configuration...
Current configuration : 1279 bytes
!
version RGNOS 10.2.00(2), Release(27932)(Thu Dec 13 10:31:41 CST 2007 -ngcf32)
hostname SW-1
!
vlan 1
!
no service password-encryption
!
interface FastEthernet 0/1
!
interface FastEthernet 0/2 
!
interface FastEthernet 0/3 
!
·
·
·
interface GigabitEthernet 0/28
!
!
line con 0
line vty 0 4 login
!
!
banner motd ^C
Welcome to SW-1, if you are admin, you can config it. 
If you are not admin, please EXIT!
^C
!
end

第六步:保存配置
下面的 3 条命令都可以保存配置

SW-1#copy running-config startup-config 
SW-1#write memory
SW-1#write

【注意事项】

  1. 命令行操作进行自动补齐或命令简写时,要求所简写的字母必须能够惟一区别该命令。
    如 switch#conf 可以代表 configure,但 switch#co 无法代表 configure,因为 co 开头的命令有两个,copy 和 configure,设备无法区别。
  2. 注意区别每个操作模式下可执行的命令种类。交换机不可以跨模式执行命令。
  3. 配置设备名称的有效字符是 22 个字节。
  4. 配置每日提示信息时,注意终止符不能在描述文本中出现。如果键入结束的终止符 后仍然输入字符,则这些字符将被系统丢弃。
  5. 交换机端口在默认情况下是开启的,AdminStatus 是 UP 状态,如果该端口没有实 际连接其他设备,OperStatus 是 down 状态。
  6. show running-config 查看的是当前生效的配置信息,该信息存储在 RAM(随机存储 器里),当交换机掉电,重新启动时会重新生成新的配置信息。

你可能感兴趣的:(计算机网络)