計算機網絡實驗|交換機的基本配置

交換機的基本配置

【實驗目的】
掌握交換機命令行各種操作模式的區別,能夠使用各種幫助信息,以及用命令進行基本的配置。

【背景描述】
你是某公司新進的網管,公司要求你熟悉網絡產品,公司採用全系列銳捷網絡產品,首先要求你登錄交換機,瞭解、掌握交換機的命令行操作技巧,以及如何使用一些基本命令進行配置。

【需求分析】
需要在交換機上熟悉各種不同的配置模式以及如何在配置模式間切換,使用命令進行基本的配置,並熟悉命令行界面的操作技巧。

【實驗拓撲】
在這裏插入圖片描述
【實驗設備】
三層交換機 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(隨機存儲 器裏),當交換機掉電,重新啓動時會重新生成新的配置信息。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章