1、配置主機名
在全局模式下輸入hostname 名字 然后回車即可立馬生效(在生產環境交換機必須有自己唯一的名字)
Switch(config)#hostname jsh-sw1jsh-sw1(config)#
2、顯示系統OS名稱及版本信息
特權模式下,輸入命令 show version
Switch#show versionCisco 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_teamROM: C2960 Boot Loader (C2960-HBOOT-M) Version 12.2(25r)FX, RELEASE SOFTWARE (fc4)System returned to ROM by power-onCisco WS-C2960-24TT (RC32300) processor (revision C0) with 21039K bytes of memory.
24 FastEthernet/IEEE 802.3 interface(s) ——說明有24個百兆接口2 Gigabit Ethernet/IEEE 802.3 interface(s) ——說明有 2個千兆接口63488K bytes of flash-simulated non-volatile configuration memory.<u>Base ethernet MAC Address : 0040.0BE5.7EEE</u> (MAC地址)Motherboard assembly number : 73-9832-06Power supply part number : 341-0097-02<u>Motherboard serial number : FOC103248MJ</u> (主板S/N序列號,用于辨別交換機)Power supply serial number : DCA102133JAModel revision number : B0Motherboard revision number : C0Model number : WS-C2960-24TTSystem serial number : FOC1033Z1EY--More--
3、查看交換機的MAC地址表
特權模式下輸入命令 show mac-address-table 顯示靜態MAC地址(手工方式添加,無老化時間,會一直存在)
特權模式下輸入命令 show mac-address-table dynamic 顯示動態MAC地址(通過arp學習到的,有老化時間)

Switch3#show mac-address-table Mac Address Table-------------------------------------------Vlan Mac Address Type Ports---- ----------- -------- -----1 0000.0c0c.7a5a DYNAMIC Fa0/24 (其中0000.0c0c.7a5a是MAC地址;類型DYNAMIC表示是動態學習到的;Fa0/24表示該MAC地址對應交換機的端口號)1 0001.9734.c756 DYNAMIC Fa0/241 0001.c981.6818 DYNAMIC Fa0/241 0004.9a65.ed19 DYNAMIC Fa0/11 00e0.f99e.4637 DYNAMIC Fa0/2
4、指定接口的雙工模式
在接口模式下,輸入命令duplex full 則設置為:全雙工
在接口模式下,輸入命令duplex half 則設置為:辦雙工
在接口模式下,輸入命令duplex auto 則設置為:自動(默認為此模式)
5、指定接口的速率
在接口模式下,輸入命令 speed 10 則設置為10M
在接口模式下,輸入命令 speed 100 則設置為100M
在接口模式下,輸入命令 speed 1000 則設置為1000M
在接口模式下,輸入命令 speed auto 則設置為自動(默認為此速度)
Switch(config-if)#speed ?10 Force 10 Mbps operation100 Force 100 Mbps operationauto Enable AUTO speed configurationSwitch(config-if)#speed auto Switch(config-if)#
6、查看接口的雙工模式和速率
在特權模式,使用命令 show interface 端口
Switch#show interfaces fa 0/24
FastEthernet 0/24 is up, line protocol is up (connected)
Hardware is Lance, address is 0005.5eb1.7918 (bia 0005.5eb1.7918)
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 ——雙工模式及速率
7、設備配置的輔助命令
7.1 命令行界面空閑一段時間,重回初始界面的問題
在全局模式下,輸入命令 line con 0 然后回車換行,輸入命令exec-timeout 0 0 即可設置為永不超時
jingshihai-01>
jingshihai-01>en
jingshihai-01#config ter
jingshihai-01#config terminal
Enter configuration commands, one per line. End with CNTL/Z.
jingshihai-01(config)#line con 0
jingshihai-01(config-line)#exec-t
jingshihai-01(config-line)#exec-timeout 0 0
jingshihai-01(config-line)#
7.2 控制臺消息打算輸入的處理
當執行完一個命令,需要輸入另一個命令時,為了保持光標不被返回的消息打擾,可以配置如下命令:在全局模式下,輸入命令 line con 0 然后回車換行,輸入命令logging synchronous(簡寫 logg syn)
jingshihai-01(config)#line con 0
jingshihai-01(config-line)#logging synchronous
7.3 禁用DNS查詢
jingshihai-01#asdadffffffffffffffffffff
Translating "asdadffffffffffffffffffff"...domain server (255.255.255.255)
當遇到如上提示時,一般需要等待很久,此時就要要禁用DNS查詢。
在全局模式下,輸入命令 no ip domain-lookup(簡寫no ip domain-lo)
jingshihai-01#asdadffffffffffffffffffff
Translating "asdadffffffffffffffffffff"...domain server (255.255.255.255)
% Unknown command or computer name, or unable to find computer address (等待很久才會顯示該信息)jingshihai-01#config terminal
Enter configuration commands, one per line. End with CNTL/Z.
jingshihai-01(config)#no ip domain-lookup
jingshihai-01(config)#asdadffffffffffffffffffff
% Invalid input detected at '^' marker. (直接顯示該信息)jingshihai-01(config)#
8、查看交換機的配置
在特權模式下輸入命令 show running-config(可以用來檢查配置)
jingshihai-01#
jingshihai-01#show running-config
Building configuration...Current configuration : 1157 bytes
!
version 12.2
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname jingshihai-01 (歷史輸入的命令,可以用來檢查輸入的是否正確)
!
!
!
jingshihai-01#
9、設置進入特權模式的密碼(明文)
在全局模式下輸入命令 enable password 密碼
jingshihai-01#config terminal
Enter configuration commands, one per line. End with CNTL/Z.
jingshihai-01(config)#enable password 123456
jingshihai-01(config)#end
jingshihai-01#
jingshihai-01#show running-config
Building configuration...Current configuration : 1157 bytes
!
version 12.2
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname jingshihai-01
!
enable password 123456
!
!
jingshihai-01#exit
jingshihai-01>enable
Password:
jingshihai-01#