交換機基本命令



1 案例1:交換機基本命令模式

1.1 問題

本例要求熟練掌握交換機每個模式的配置命令

對於思科交換機來說,主要有2種配置途徑:其一,使用交換機自帶的Console線纜連接到計算機的COM口,然后利用計算機的超級終端軟件直接配置,首次配置通常使用這種方式;其二,通過telnet方式遠程訪問、配置交換機,這種方式要求此交換機已配置有IP地址且已接入計算機網絡,后續課程會學習此訪問方式。

1)通過超級終端訪問交換機

2)交換機工作模式的進入與退出

真實設備環境,如圖-1所示。

圖-1

1.2 方案

本例中的配置練習可采用思科模擬器 —— Cisco Packet Tracer 6.2來實現。

1)安裝Packet Tracer 6.2

雙擊安裝包執行默認安裝,然后將中文語言文件Chinese.ptl解壓到安裝目錄下的多語言文件夾,比如C:\Program Files (x86)\Cisco Packet Tracer 6.0\languages。

雙擊桌面的Cisco Packet Tracer快捷方式以啟動程序,打開菜單“Options”-->“Preferences”-->切換到“Interface”選項卡-->選擇下方的Chinese.ptl-->單擊右下角“Change Language”按鈕,彈出提示時單擊“OK”,如圖-2所示。

圖-2

關閉當前Packet Tracer程序,然后再重新啟動此程序,可發現已經變成中文語言界面了(當前漢化的還不完整),如圖-3所示。

圖-3

2)建立實驗網絡拓撲

在Packet Tracer程序主窗口中,添加一台Cisco 2960交換機、一台普通PC機,並添加Console連接、直通網線連接,如圖-4所示,確認完畢后將當前拓撲結構保存為c2960-pc.pkt文件。

圖-4

其中,連接細節如下:

  • 交換機的Console口 <--> PC機的RS 232串口。
  • 交換機的FastEthernet0/24接口 <--> PC機的FastEthernet0網卡。

1.3 步驟

實現此案例需要按照如下步驟進行。

步驟一:通過超級終端訪問交換機。

1)配置並打開超級終端

在此前建立的Packet Tracer實驗拓撲環境中,單擊PC機以打開此設備,確認電源已啟動(機箱示意圖上的指示燈為黃綠色),切換到“桌面選項卡”,如圖-5所示,找到其中的“終端”並單擊打開。

圖-5

在彈出的終端配置窗口中,如圖-6所示,單擊“確定”以接受默認值。

圖-6

接下來就可以看到“終端”窗口了,其中顯示了通過Console線連接的交換機初始化信息,回車后可進入交換機的“Switch>”配置系統,如圖-7所示。

圖-7

提示:在Packet Tracer環境中,可直接單擊交換機圖標,然后切換到“命令行”選項卡,也可以進入IOS配置環境。

步驟二:交換機工作模式的進入與退出

1) 交換機工作模式的進入如下:

  1. Switch>enable //切換為特權模式
  2. Switch# configure terminal     //進入全局配置模式
  3. Enter configuration commands, one per line. End with CNTL/Z.
  4. Switch(config)#interface fastEthernet 0/1 //進入接口模式
  5. Switch(config-if)#

2)交換機工作模式的退出下:

  1. Switch(config-if)#exit //接口模式退到全局配置模式
  2. Switch(config)#exit //全局配置模式退到特權模式
  3. Switch#exit //特權模式退到用戶模式
  4. Switch>

注:exit 返回上一模式

end 從接口或者特全局配置模式回到特權模式,快捷鍵Ctrl+z同等效果

思科設備命令行不區分大小寫,與Linux命令行不同

命令輸入錯誤卡住時同時按鍵盤ctrl+shift+6這三個鍵即可

2 案例2:交換機命令行基本配置

2.1 問題

修改及查看交換機配置

1)修改交換機主機名

2)查看交換機配置信息

3)查看IOS名稱以及版本信息

2.2 方案

在Packet Tracer程序主窗口中,添加一台Cisco 2960交換機,進入交換機,輸入相關命令進行配置和查看交換機

2.3 步驟

實現此案例需要按照如下步驟進行。

步驟一:修改交換機主機名

進入全局配置模式后,使用hostname指令可以為交換機設置主機名。例如,以下操作可以將主機名設置為s1:

  1. Switch(config)# hostname s1                     //配置主機名
  2. s1(config)#    

步驟二:查看交換機配置信息

查看交換機當前的運行配置:

  1. 查看交換機當前的運行配置(或write terminal):
  2. s1# show running-config                 //查看當前的運行配置
  3. Building configuration...
  4. Current configuration : 1052 bytes
  5. !
  6. version 12.2
  7. no service timestamps log datetime msec
  8. no service timestamps debug datetime msec
  9. no service password-encryption
  10. !
  11. hostname sw1                         //已配置主機名
  12. !
  13. !
  14. !
  15. !
  16. spanning-tree mode pvst
  17. !
  18. interface FastEthernet0/1
  19. !
  20. interface FastEthernet0/2
  21. !
  22. interface FastEthernet0/3
  23. !
  24. interface FastEthernet0/4
  25. !
  26. interface FastEthernet0/5
  27. !
  28. interface FastEthernet0/6
  29. !
  30. interface FastEthernet0/7
  31. !
  32. interface FastEthernet0/8
  33. !
  34. interface FastEthernet0/9
  35. !
  36. interface FastEthernet0/10
  37. !
  38. interface FastEthernet0/11
  39. !
  40. interface FastEthernet0/12
  41. !
  42. interface FastEthernet0/13
  43. !
  44. interface FastEthernet0/14
  45. !
  46. interface FastEthernet0/15
  47. !
  48. interface FastEthernet0/16
  49. !
  50. interface FastEthernet0/17
  51. !
  52. interface FastEthernet0/18
  53. !
  54. interface FastEthernet0/19
  55. !
  56. interface FastEthernet0/20
  57. !
  58. interface FastEthernet0/21
  59. !
  60. interface FastEthernet0/22
  61. !
  62. interface FastEthernet0/23
  63. !
  64. interface FastEthernet0/24
  65. !
  66. interface GigabitEthernet1/1
  67. !
  68. interface GigabitEthernet1/2
  69. !
  70. interface Vlan1
  71. no ip address
  72. shutdown
  73. !
  74. !
  75. line con 0
  76. !
  77. line vty 0 4
  78. login
  79. line vty 5 15
  80. login
  81. !
  82. !
  83. end
  84. sw1#

步驟三:查看IOS名稱以及版本信息

查看ios名稱及版本信息

  1. s1#show version
  2. Cisco Internetwork Operating System Software
  3. IOS (tm) C2950 Software (C2950-I6Q4L2-M), Version 12.1(22)EA4, RELEASE SOFTWARE(fc1)
  4. Copyright (c) 1986-2005 by cisco Systems, Inc.
  5. Compiled Wed 18-May-05 22:31 by jharirba
  6. Image text-base: 0x80010000, data-base: 0x80562000
  7. ROM: Bootstrap program is is C2950 boot loader
  8. Switch uptime is 1 minutes, 39 seconds
  9. System returned to ROM by power-on
  10. Cisco WS-C2950-24 (RC32300) processor (revision C0) with 21039K bytes of memory.
  11. Processor board ID FHK0610Z0WC
  12. Last reset from system-reset
  13. Running Standard Image
  14. 24 FastEthernet/IEEE 802.3 interface(s)
  15. 63488K bytes of flash-simulated non-volatile configuration memory.
  16. Base ethernet MAC Address: 00E0.B026.B88C
  17. Motherboard assembly number: 73-5781-09
  18. Power supply part number: 34-0965-01
  19. Motherboard serial number: FOC061004SZ
  20. Power supply serial number: DAB0609127D
  21. Model revision number: C0
  22. Motherboard revision number: A0
  23. Model number: WS-C2950-24
  24. System serial number: FHK0610Z0WC
  25. Configuration register is 0xF

3 案例3:交換機密碼設置

3.1 問題

配置交換機的訪問口令

1)配置用戶進入特權模式的明文密碼為123

2)配置用戶進入特權模式的密文密碼為456

3)配置conslole口令為789

3.2 方案

配置交換機訪問口令

實現此案例需要按照如下步驟進行。

3.3 步驟

步驟一:交換機密碼配置

1)設置特權模式口令

包括兩種典型的方法:

方法1(明文):enable password 密碼字串

方法2(加密):enable secret 密碼字串

比如,以下操作將明文口令設為123、加密口令設置為456:

  1. sw2960(config)# enable password 123
  2. sw2960(config)# enable secret 456

返回特權模式,查看運行配置可觀察兩種口令設置的差異:

  1. sw2960(config)# end     //返回特權模式
  2. sw2960#
  3. %SYS-5-CONFIG_I: Configured from console by console
  4. sw2960# show running-config     //查看當前的運行配置
  5. .. ..
  6. !
  7. hostname sw2960
  8. !
  9. enable secret 5 $1$mERr$pUBB1obEqpmMUtC1rBieD1         //加密口令設置
  10. enable password 123    //非加密的口令設置
  11. !
  12. !
  13. .. ..

執行disable切換到用戶模式,再執行enable切換到特權模式,此時會要求輸入正確的口令才允許進入(如果明文/密文口令都設置了,則密文口令起作用):

  1. sw2960> enable
  2. Password:     //嘗試明文口令123無效
  3. Password: //輸入密文口令456驗證成功
  4. sw2960#

步驟二:設置console口令

以下操作配置交換機console口令

  1. Sw2960(config)#line console 0
  2. Sw2960(config-line)#password 789 //設置consol口令
  3. Sw2960(config-line)#login

切換到用戶模式,提示輸入conslole口令才能再次進入到用戶模式:

  1. Sw2960(config-line)#end
  2. Sw2960#
  3. %SYS-5-CONFIG_I: Configured from console by console
  4. Sw2960#exit
  5. Sw2960 con0 is now available
  6. Press RETURN to get started.
  7. User Access Verification
  8. Password:

步驟三:清空設備配置

  1. Switch(config)#exit
  2. Switch#write
  3. Switch#erase startup-config
  4. Erasing the nvram filesystem will remove all configuration files! Continue? [confirm] //此時系統詢問是否確定刪除,按回車即可
  5. [OK]
  6. Erase of nvram: complete

步驟四:重啟設備檢測配置狀況

  1. Switch#reload
  2. Proceed with reload? [confirm] //此時系統詢問是否確定重啟,按回車即可


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM