CCNA Discovery 在中小型企業或 ISP 工作
實驗 5.4.4 設定 Cisco 2960 交換器
裝置編號 主機名稱/介面 IP 位址 子網路遮罩 預設閘道
PC 1 Host-A 192.168.1.2 255.255.255.0 192.168.1.1 PC 2 Host-B 192.168.1.4 255.255.255.0 192.168.1.1 PC 3 Host-C 192.168.1.6 255.255.255.0 192.168.1.1 交換器
CustomerSwitch
VLAN 1 介面 192.168.1.5 255.255.255.0 192.168.1.1 Router
CustomerRouter
F0/0 介面 192.168.1.1 255.255.255.0 不適用
目標
• 為交換器設定起始全域設定
• 設定主機 PC 並將它們連接到交換器
• 設定路由器並將其連接到交換器
• 設定交換器管理 VLAN IP 位址。
• 設定基本連接埠安全性。
• 設定連接埠雙工模式和速度設定。
背景/準備工作
本實驗的主要內容是使用 Cisco IOS 命令為 Cisco 2960 交換器執行基本設定。本實驗的資訊同樣適用於其他 交換器,但命令語法可能會有所差異。Cisco Catalyst 2960 交換器出廠時已預先設定,接入網路之前,只需要 為它指定基本安全資訊即可。要對 Cisco 交換器使用基於 IP 的管理產品或 Telnet,需要設定管理 IP 位址。
在本實驗中,您將設定 VLAN 1,以便為管理功能提供 IP 接入。您還將測試主機與交換器的連通性,以檢驗管 理 IP 位址設定是否正確。此外,還需設定連接埠安全、連接埠速度和雙工。
本實驗需要以下資源:
• Cisco 2960 交換器或其他同類型交換器
• 乙太網路介面已連接到交換器的路由器
• 三台 Windows 電腦,其中一台需裝有終端模擬程式
• RJ-45-to-DB-9 連接器的控制台纜線
• 三條直通乙太網路纜線
• PC 命令提示字元的存取權
• 對 PC 網路 TCP/IP 設定的修改權
注意:轉到本實驗說明末尾的「清除並重新載入交換器」。在繼續執行下面的步驟之前,先對本實驗中所有用 到的交換器執行該說明中講到的操作。
注意:本實驗結束時請按照「清除和重新載入路由器」的指示操作。在參與本實驗的所有路由器上執行這些步 驟,然後再繼續。
注意:SDM 路由器 - 如果在 SDM 路由器中刪除了 startup-config,那麼在重新啟動該路由器後 SDM 不會預 設啟動。而必須使用 IOS 的基本路由器設定。請參閱本實驗末尾的步驟,或者請教教師。
步驟 1: 將主機連接到交換器並設定主機。
a. 將 Host-A 連接到高速乙太網路交換器連接埠 Fa0/1,Host-B 連接到 Fa0/4。為這些主機設定 IP 位址 和子網路遮罩,使主機所在的子網路與交換器的子網路一致(如上面的拓撲圖所示)。
b. 現在不要將 Host-C 連接到交換器。
步驟 2: 將路由器連接到交換器並設定路由器。
注意:如有必要,可參照實驗 5.3.5「使用 IOS CLI 設定基本路由器組態」來為路由器設定主機名稱、
密碼和介面位址。」
a. 將路由器連接到高速乙太網路交換器連接埠 Fa0/3。
b. 將路由器的主機名稱設定為 CustomerRouter。
c. 設定控制台存取與密碼、vty 存取與密碼和啟用加密密碼。
d. 按照上面的拓撲圖,設定路由器的 Fa0/0 介面。
步驟 3: 在交換器上執行起始設定。
a. 將交換器的主機名稱設定為 CustomerSwitch:
Switch>enable
Switch#Config Terminal
Switch(config)#hostname CustomerSwitch b. 將特權執行模式密碼設定為 cisco:
CustomerSwitch(config)#enable password cisco c. 將特權執行模式加密密碼設定為 cisco123:
CustomerSwitch(config)#enable secret cisco123 d. 將控制台密碼設定為 cisco123:
CustomerSwitch(config)#line console 0
CustomerSwitch(config-line)#password cisco123 e. 將控制台線路設定為登入時需要輸入密碼:
CustomerSwitch(config-line)#login f. 將 vty 密碼設定為 cisco123:
CustomerSwitch(config-line)#line vty 0 15 CustomerSwitch(config-line)#password cisco123 g. 將 vty 設定為登入時需要輸入密碼:
CustomerSwitch(config-line)#login CustomerSwitch(config-line)#end 步驟 4: 設定 VLAN 1 上的管理介面。
a. 進入全域設定模式。記得使用新密碼。
CustomerSwitch>enable
CustomerSwitch#configure terminal b. 進入 VLAN 1 的介面設定模式:
CustomerSwitch(config)#interface vlan 1
c. 為管理介面設定 IP 位址、子網路遮罩和預設閘道。該 IP 位址必須與交換器所在的區域網路相符。
CustomerSwitch(config-if)#ip address 192.168.1.5 255.255.255.0 CustomerSwitch(config-if)#exit
CustomerSwitch(config)#ip default-gateway 192.168.1.1 CustomerSwitch(config)#end
步驟 5: 校驗交換器的設定。
a. 檢查交換器 VLAN 1 上管理介面的 IP 位址與 Host-A 的 IP 位址是否在同一區域網路中。使用 show running-configuration 命令來檢視交換器的 IP 位址設定:
CustomerSwitch#
show running-configuration
Building configuration...Current configuration : 1283 bytes
!
version 12.2
no service pad
hostname CustomerSwitch
!
enable secret 5 $1$XUe/$ch4WQ/SpcFCDd2iqd9bda/
enable password cisco
!
interface FastEthernet0/1
!
*** 輸出已省略 ***
!
interface FastEthernet0/24
!
interface Vlan1
ip address 192.168.1.5 255.255.255.0 no ip route-cache
!
ip default-gateway 192.168.1.1 ip http server
!
line con 0
password cisco123 login
line vty 0 4
password cisco123 login
line vty 5 15 password cisco123 login
! end
b. 使用下面的命令儲存設定:
CustomerSwitch#copy running-configuration startup-configuration 步驟 6: 使用 ping 和 Telnet 檢查連通性。
a. 要檢查交換器和路由器是否設定正確,從交換器 CLI ping 路由器 Fa0/0 介面(預設閘道)IP 位址。
b. ping 是否成功?__________________________________________________
c. 要檢查主機和交換器是否設定正確,從 Host-A ping 交換器 IP 位址。
d. ping 是否成功?_______________________________________________
e. 如果 ping 命令失敗,則再次檢查設定和連接。確保所有連接都使用了正確的纜線,且穩固插入。檢查 主機、交換器和路由器設定。
f. 在 Host-A 上開啟命令提示字元,然後輸入 telnet 命令,後面接著指定給交換器管理 VLAN 1 的 IP 位址。
g. 輸入在步驟 3 設定的 vty 密碼。結果是什麼?
____________________________________________________
h. 在交換器提示字元下,輸入 show version 命令。
CustomerSwitch>show version
Cisco IOS Software, C2960 Software (C2960-LANBASE-M), Version 12.2(0.0.16)FX, CISCO
DEVELOPMENT TEST VERSION
Copyright (c) 1986-2005 by Cisco Systems, Inc.
Compiled Tue 17-May-05 01:43 by yenanh ROM: Bootstrap program is C2960 boot loader
BOOTLDR: C2960 Boot Loader (C2960-HBOOT-M), Version 12.2 [lqian- flo_pilsner 100]
Switch uptime is 3 days, 20 hours, 8 minutes System returned to ROM by power-on
System image file is "flash:c2960-lanbase-mz.122-0.0.16.FX.bin"
cisco WS-C2960-24TC-L (PowerPC405) processor with 61440K/4088K bytes of memory.
Processor board ID FHH0916001J Last reset from power-on
Target IOS Version 12.2(25)FX 1 Virtual Ethernet interface 24 FastEthernet interfaces 2 Gigabit Ethernet interfaces
The password-recovery mechanism is enabled.
64K bytes of flash-simulated non-volatile configuration memory.
Base ethernet MAC Address : 00:0B:FC:FF:E8:80 Motherboard assembly number : 73-9832-02
Motherboard serial number : FHH0916001J Motherboard revision number : 01
System serial number : FHH0916001J Hardware Board Revision Number : 0x01
Switch Ports Model SW Version SW Image --- --- --- --- ---
* 1 26 WS-C2960-24TC-L 12.2(0.0.16)FX C2960- LANBASE-M
Configuration register is 0xF
i. 此交換器的 Cisco IOS 版本是多少?___________________
j. 在交換器命令提示字元下鍵入 quit 以終止 Telnet 會談。
步驟 7: 確定交換器獲取到哪些 MAC 位址。
a. 在 Windows 命令提示字元下,使用 ipconfig /all 命令來確定每台主機的 PC 網路介面卡的第 2 層 位址。
Host-A:_______________________________________________
Host-B:_______________________________________________
Host-C:_______________________________________________
b. 在特權執行模式提示字元下,使用 show mac-address-table 命令來確定交換器到底獲取到了哪些 MAC 位址。
CustomerSwitch#show mac-address-table Mac Address Table
--- Vlan Mac Address Type Ports ---- --- --- --- All 000b.be7f.ed40 STATIC CPU All 0100.0ccc.cccc STATIC CPU All 0100.0ccc.cccd STATIC CPU All 0100.0cdd.dddd STATIC CPU 1 000b.db04.a5cd DYNAMIC Fa0/1 1 000c.3076.8380 DYNAMIC Fa0/3 1 000d.1496.36ad DYNAMIC Fa0/4 Total Mac Addresses for this criterion: 7 c. 一共有多少個動態位址?____________________________
d. 這些 MAC 位址是否與主機 MAC 位址相符?_______________
e. 使用 ? 選項檢視 mac-address-table 命令可使用的各個選項:
CustomerSwitch(config)#
mac-address-table ?
address address keywordaging-time aging-time keyword count count keyword dynamic dynamic entry type interface interface keyword
multicast multicast info for selected wildcard
notification MAC notification parameters and history table static static entry type
vlan VLAN keyword | Output modifiers <cr>
f. 在高速乙太網路介面 0/4 上設定靜態 MAC 位址。使用在步驟 7 中記錄的 Host-B 的位址。MAC 位址 XXXX.YYYY.ZZZZ 僅做示範用。
CustomerSwitch(config)#mac-address-table static XXXX.YYYY.ZZZZ interface fastethernet 0/4 vlan 1
g. 檢查 MAC 位址表條目:
CustomerSwitch#show mac-address-table Mac Address Table
---
Vlan Mac Address Type Ports ---- --- --- --- All 000b.be7f.ed40 STATIC CPU All 0100.0ccc.cccc STATIC CPU All 0100.0ccc.cccd STATIC CPU All 0100.0cdd.dddd STATIC CPU 1 000b.db04.a5cd DYNAMIC Fa0/1 1 000c.3076.8380 DYNAMIC Fa0/3 1 000d.1496.36ad STATIC Fa0/4
現在表中一共有多少個 MAC 位址?________________________
h. 這些位址分別屬於哪種類型?____________________________________________
步驟 8: 設定基本連接埠安全性。
a. 確定高速乙太網路介面 0/4 上有哪些設定連接埠安全性的選項。
CustomerSwitch#configure terminal
CustomerSwitch(config)#interface fastEthernet 0/4 CustomerSwitch(config-if)#switchport port-security ?
aging Port-security aging commands mac-address Secure mac address maximum Max secure addrs
violation Security Violation Mode
b. 為使交換器連接埠 FastEthernet 0/4 只能接受一個裝置,請如下設定連接埠安全:
CustomerSwitch(config-if)#switchport mode access CustomerSwitch(config-if)#switchport port-security
CustomerSwitch(config-if)#switchport port-security mac-address sticky CustomerSwitch(config-if)#end
c. 檢查連接埠安全性設定。
CustomerSwitch#show port-security
Secure Port MaxSecureAddr CurrentAddr SecurityViolation Security Action (Count) (Count) (Count)
--- Fa0/4 1 0 0 Shutdown
--- d. 連接埠 fa0/4 的安全措施為何?_______________
e. 最大安全位址數目是多少?____________
f. 顯示執行設定
注意:以下內容中省略了一些輸出資訊。
CustomerSwitch#
show running-config
Building configuration...Current configuration : 1452 bytes version 12.2
hostname CustomerSwitch
!
interface FastEthernet0/1
!
interface FastEthernet0/2
!
interface FastEthernet0/3
!
interface FastEthernet0/4 switchport mode access switchport port-security
switchport port-security mac-address sticky
!
interface FastEthernet0/5
!
*** 輸出已省略 ***
mac-address-table static 000b.db04.a5cd vlan 1 interface FastEthernet0/4
! end
g. 執行時期設定的列表中是否有敘述直接反映安全實作?
__________________________________________________
步驟 9: 將另一台 PC 連接到安全交換器連接埠。
a. 斷開 Host-B 與 FastEthernet 0/4 的連接,然後將 Host-C 連接到該連接埠。此時 Host-C 尚未連接到交 換器。Ping 交換器位址 192.168.1.5 來產生一定的流量。
b. 記錄下 PC 和交換器終端會談中觀察到的所有資訊。
______________________________________________________________________________
______________________________________________________________________________
01:11:12: %PM-4-ERR_DISABLE: psecure-violation error detected on Fa0/4, putting Fa0/4 in err-disable state
01:11:12: %PORT_SECURITY-2-PSECURE_VIOLATION: Security violation occurred, cause d by MAC address 000c.3076.8380 on port FastEthernet0/4.
01:11:13: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/4, chang ed state to down
01:11:14: %LINK-3-UPDOWN: Interface FastEthernet0/4, changed state to down c. 如果只想檢視高速乙太網路連接埠 0/4 的設定資訊,在特權執行模式提示字元下輸入以下命令:
CustomerSwitch#show interface fastethernet 0/4 d. 介面的狀態是什麼?
FastEthernet0/4 為 ________________,線路協定為 _____________。
步驟 10: 重新啟動連接埠。
a. 如果連接埠因安全違規事件關閉,則使用 no shutdown 命令來重新啟動它。
CustomerSwitch(config)#interface fastEthernet 0/4 CustomerSwitch(config-if)#no shutdown
b. 輪流使用起始連接埠 0/4 主機和新的主機來試著重新啟動此連接埠幾次。插上最開始的那台主機,在介 面中鍵入 no shutdown 命令,然後使用命令提示字元執行 ping 操作。您必須多 ping 幾次,或者也可 使用 ping 192.168.1.5 –n 200 命令(此命令將 ping 封包的數量從 4 個變更為 200 個)。
c. 更換主機並重試。
步驟 11: 為連接埠設定速度和雙工選項。
a. 交換器連接埠設定預設為 Auto-duplex(自動雙工)和 Auto-speed(自動速度)。如果一台裝有 100 Mbps 網路介面卡的電腦連接到該連接埠,則連接埠會自動進入全雙工 100 Mbps 模式。如果是一台集線器連 接到該電腦連接埠,那麼連接埠一般會進入半雙工 10 Mbps 模式。
b. 執行 show interfaces 命令來檢視連接埠 Fa0/1 和 Fa0/5 的設定,此命令會產生大量的輸出。不停按 空白鍵,直到您閱讀完有關這些連接埠的全部資訊為止。這些連接埠的雙工設定和速度設定是什麼?
連接埠 Fa0/2 ________________________________
連接埠 Fa0/4 ________________________________
連接埠 Fa0/5 ________________________________
c. 有時候有必要為連接埠設定速度和雙工模式,以確保連接埠的執行模式正確。在介面設定模式下,您可 使用 duplex 和 speed 命令來設定雙工和速度設定。要使高速乙太網路連接埠 5 以半雙工、10 Mbps 模 式運作,執行以下命令:
Switch>enable
Switch#Config Terminal
Switch(config-if)#interface fastEthernet 0/5 Switch(config-if)#speed 10
Switch(config-if)#duplex half Switch(config-if)#end
Switch#
d. 再次執行 show interfaces 命令。Fa0/5 現在的雙工設定和速度設定是什麼?
________________________________
步驟 12: 退出交換器。
a. 鍵入 exit 以退出交換器並返回歡迎螢幕:
Switch#exit
b. 完成上面的步驟後,關閉全部裝置。收好纜線和介面卡並妥善保管。
步驟 13: 思考
a. 在 Cisco 交換器上,要從使用者模式切換到特權執行模式需要輸入什麼密碼?原因是什麼?
____________________________________________________________________________
____________________________________________________________________________
b. Cisco IOS 軟體中使用哪個符號來顯示 ping 成功?
____________________________________________________________________________
c. 使用連接埠安全有哪些好處? ____________________________________________________
____________________________________________________________________________
d. 要提升交換器安全性,還可採取哪些與連接埠相關的安全措施?
____________________________________________________________________________
____________________________________________________________________________
清除並重新載入交換器
CCNA Discovery 中大多數實驗都需在沒有設定的交換器上開始。使用帶有設定的交換器可能會造成無法預見 的結果。以下說明用於在開始實驗前準備交換器,以免受到之前設定的影響。這些說明適用於 2900 和 2950 系 列交換器。
a. 鍵入 enable 命令以進入特權執行模式。如果提示輸入密碼,則輸入 class(若此密碼無效,請諮詢教 師)。
Switch>enable b. 刪除 VLAN 資料庫資訊檔。
Switch#delete flash:vlan.dat
Delete filename [vlan.dat]? [Enter]
Delete flash:vlan.dat? [confirm] [Enter]
如果沒有 VLAN 檔案,則會顯示以下訊息:
%Error deleting flash:vlan.dat (No such file or directory) c. 從 NVRAM 刪除交換器啟動設定檔。
Switch#erase startup-config 回應行顯示的提示資訊為:
Erasing the nvram filesystem will remove all files!Continue? [confirm]
按 Enter 確認。
隨後系統顯示:
Erase of nvram: complete d. 檢查 VLAN 資訊是否已刪除。
使用 show vlan 命令檢查步驟 b 是否確實刪除了 VLAN 設定。如果之前的 VLAN 設定資訊(預設管理 VLAN 1 除外)仍然存在,則必須將交換器重新通電(硬體重新啟動),而不能使用 reload 命令。要 將交換器重新通電,拔下交換器背後的電源線然後重新插上。如果步驟 b 成功刪除了 VLAN 資訊,則 轉到步驟 e 並使用 reload 命令重新啟動交換器。
e. 使用 reload 命令重新啟動軟體。
注意:如果已透過重新通電的方式重啟了交換器,則無需執行此步驟。
1) 在特權執行模式下,輸入 reload 命令。
Switch(config)#reload 回應行顯示的提示資訊為:
System configuration has been modified. Save? [yes/no]:
2) 鍵入 n 並按 Enter。
回應行顯示的提示資訊為:
Proceed with reload? [confirm] [Enter]
系統回應的第一行顯示為:
Reload requested by console.
交換器重新載入後,行提示為:
Would you like to enter the initial configuration dialog? [yes/no]:
3) 鍵入 n 並按 Enter。
回應行顯示的提示資訊為:
Press RETURN to get started! [Enter]
清除並重新載入路由器
a. 鍵入 enable 進入特權執行模式。
Router>enable
b. 在特權執行模式下,輸入 erase startup-config 命令。
Router#erase startup-config 回應行顯示的提示資訊為:
Erasing the nvram filesystem will remove all files! Continue?
[confirm]
c. 按 Enter 確認。
回應為:
Erase of nvram: complete d. 在特權執行模式下,輸入 reload 命令。
Router(config)#reload 回應行顯示的提示資訊為:
System configuration has been modified.Save? [yes/no]:
e. 鍵入 n,然後按 Enter。
回應行顯示的提示資訊為:
Proceed with reload? [confirm]
f. 按 Enter 確認。
回應的第一行為:
Reload requested by console.
路由器重新載入後,行提示為:
Would you like to enter the initial configuration dialog? [yes/no]:
g. 鍵入 n,然後按 Enter。
回應行顯示的提示資訊為:
Press RETURN to get started!
h. 按 Enter。
這樣,該路由器便可用於指定的實驗。
建立 SDM 路由器基本 IOS 設定以啟動 SDM
如果在 SDM 路由器上刪除了 startup-config,則當路由器重新啟動時,SDM 不再預設啟動,必須建立 基本設定,如下所示。有關設定和使用 SDM 的更多詳細資訊,請參閱 SDM Quick Start Guide(SDM 快速入門指南):
http://www.cisco.com/en/US/products/sw/secursw/ps5318/products_quick_start09186a0080511c89.h tml#wp44788
1) 設定路由器 Fa0/0 IP 位址
(這是在 PC 上透過瀏覽器連線以啟動 SDM 所使用的介面。PC 的 IP 位址應設定為 10.10.10.2 255.255.255.248)
注意:非 1841 的 SDM 路由器可能需要連接到不同的連接埠才能存取 SDM。
Router(config)# interface Fa0/0
Router(config-if)# ip address 10.10.10.1 255.255.255.248 Router(config-if)# no shutdown
2) 使用以下 Cisco IOS 命令啟用路由器的 HTTP/HTTPS 伺服器:
Router(config)#ip http server
Router(config)#ip http secure-server
Router(config)#ip http authentication local 3) 建立權限等級為 15 的使用者帳戶(啟用特權)。
Router(config)# username <username> privilege 15 password 0 <password>
將 <username> 和 <password> 取代為要設定的使用者名稱和密碼。
4) 為本機登入和權限級別 15 設定 SSH 和 Telnet:
Router(config)# line vty 0 4
Router(config-line)# privilege level 15 Router(config-line)# login local
Router(config-line)# transport input telnet Router(config-line)# transport input telnet ssh Router(config-line)# exit