CCNA Discovery 在中小型企業或 ISP 工作
實驗 5.3.5 使用 IOS CLI 設定路由器基本設定
路由器編號
路由器 名稱
Fast Ethernet 0 位址
Serial 0
位址 介面類型
兩個介面的 子網路遮罩 路由器 1 R1 172.16.0.1 172.17.0.1 DCE 255.255.0.0 路由器 2 R2 172.18.0.1 172.17.0.2 DTE 255.255.0.0
目標
• 為路由器設定裝置主機名稱。
• 設定控制台密碼、特權模式密碼和虛擬終端密碼。
• 設定乙太網路和序列介面。
• 驗證主機與路由器之間的連通性。
背景/準備工作
參照拓撲圖,建構一個類似的網路。可以使用符合圖中所示介面要求的任何路由器,例如 800、1600、1700、
1800、2500 和 2600 路由器。參考本實驗說明末尾的「路由器介面概要」表,根據實驗設備確定要使用的介面 識別碼。隨著路由器型號的不同,其輸出也可能與本實驗說明中所顯示的有所不同。除非有特別指示,否則本 實驗中的步驟應分別在每一台路由器上執行。
本實驗需要以下資源:
• 兩台路由器,每台都應具備乙太網路和序列介面。如有可能,上述兩台路由器應選用非 SDM 路由器,
因為在刪除 startup-config 時其所需的 SDM 啟動設定也隨之被刪除。
• 兩台 Windows XP 電腦
• 5 類直通乙太網路纜線(PC1 到交換器)
• 5 類交叉乙太網路纜線(PC2 到路由器 R2)
• Null 序列纜線
• 控制台纜線(用於連接 PC1、PC2 與路由器 R1、R2)
• PC 命令提示字元的存取權
• PC 網路 TCP/IP 設定的存取權
分別從每一台 PC,對所連接的路由器啟動 超級終端機 。
注意: 轉到本實驗說明末尾的「清除並重新載入路由器」部份。在繼續執行下面的步驟之前,先對本實驗中用 到的所有路由器執行該說明中講到的操作。
注意: SDM 路由器 - 如果在 SDM 路由器中刪除了 startup-config,那麼在重新啟動該路由器後 SDM 不會預設 啟動。此時就需要使用 IOS 命令構建基本路由器設定。請參閱本實驗說明末尾的操作過程,或諮詢您的教師。
步驟 1: 設定主機 IP 設定
a. 確保所有 PC 均已按照拓撲圖連接妥當。
b. 按照下面的說明,為這些機器設定靜態 IP 位址:
連接到 R1 交換器的 PC:
IP 位址: 172.16.0.2 子網路遮罩: 255.255.0.0 預設閘道: 172.16.0.1 直接連接到 R2 的 PC:
IP 位址: 172.18.0.2 子網路遮罩: 255.255.0.0 預設閘道: 172.18.0.1
步驟 2: 登入每台路由器並設定主機名稱與密碼 a. 為這兩台路由器各設定一個主機名稱。
Router>enable
Router#configure terminal Router(config)#hostname R1
為路由器 R2 重複上述步驟(將第二台路由器命名為 R2)。
b. 分別為這兩台路由器設定控制台密碼並啟用登入。
R1(config)#line console 0 R1(config-line)#password cisco R1(config-line)#login
R1(config-line)#exit R1(config)#
為路由器 R2 重複上述步驟。
c. 分別為這兩台路由器在虛擬終端線路上設定密碼。
R1(config)#line vty 0 4
R1(config-line)#password cisco R1(config-line)#login
R1(config-line)#exit R1(config)#
為路由器 R2 重複上述步驟。
d. 分別為這兩台路由器設定啟用密碼以及使用加密密碼。
R1(config)#enable password cisco R1(config)#enable secret class R1(config)#exit
為路由器 R2 重複上述步驟。
注意: 請記住,從組態檔來看,啟用加密密碼是加密的。另外,不要鍵入 enable secret password class。如果鍵入上述命令,則加密密碼是 password,而不是 class。啟用加密密碼的優先順序高於 啟用密碼。一旦輸入啟用加密密碼,則系統不再接受啟用密碼。
步驟 3: 顯示路由器執行中設定
a. 在特權執行模式提示字元下,執行 show running-config 命令。該命令可縮寫為 sh run。
R1#show running-config
*** 某些輸出已省略 ***
Building configuration...
Current configuration : 605 bytes
!
hostname R1
!
enable secret 5 $1$eJB4$SH2vZ.aiT7/tczUJP2zwT1 enable password cisco
!
interface FastEthernet0/0 no ip address
shutdown duplex auto speed auto
!
interface Serial0/0 no ip address shutdown
!
interface Serial0/1 no ip address shutdown line con 0 password cisco login
line aux 0 line vty 0 4 password cisco login
! end
b. 是否存在加密密碼?_____________
c. 是否存在其他密碼?_____________
d. 其他密碼有否經過加密?_____________
步驟 4: 在 R1 上設定序列介面
在全域設定模式下,設定路由器 R1 上的序列介面 Serial 0。請參閱本實驗說明末尾的路由器介面概要表,
尋找您在本實驗中所採用的路由器上對應的序列介面。
R1(config)#interface serial 0/0
R1(config-if)#ip address 172.17.0.1 255.255.0.0 R1(config-if)#clock rate 64000
R1(config-if)#no shutdown R1(config-if)#exit
R1(config)#exit
注意: 只能在纜線的 DCE 介面端所連接的路由器序列介面上輸入時脈頻率。Null 序列纜線每一端的外側都印 有其纜線類型(DTE 或 DCE)。如有疑問,可在兩個路由器序列介面中同時輸入 clock rate 命令。在連接 DTE 端的路由器上,該命令會被略過。命令 no shutdown 會開啟介面。命令 shutdown 會關閉介面。
步驟 5: 顯示有關 R1 上序列介面的資訊
a. 在 R1 上輸入 show interface 命令。參考路由器介面概要表。
R1#show interface serial 0/0
Serial0/0 is down, line protocol is down Hardware is PowerQUICC Serial
Internet address is 172.17.0.1/16
MTU 1500 bytes, BW 128 Kbit, DLY 20000 usec,
reliability 255/255, txload 1/255, rxload 1/255 Encapsulation HDLC, loopback not set
Keepalive set (10 sec)
Last input never, output never, output hang never Last clearing of "show interface" counters 00:01:55
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0 Queueing strategy: fifo
Output queue :0/40 (size/max)
5 minute input rate 0 bits/sec, 0 packets/sec 5 minute output rate 0 bits/sec, 0 packets/sec 0 packets input, 0 bytes, 0 no buffer
Received 0 broadcasts, 0 runts, 0 giants, 0 throttles
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort 6 packets output, 906 bytes, 0 underruns
0 output errors, 0 collisions, 3 interface resets 0 output buffer failures, 0 output buffers swapped out 0 carrier transitions
DCD=down DSR=down DTR=up RTS=up CTS=down
b. 至少列出三項透過此命令瞭解到的具體資訊。
Serial 0/0 的狀態是:_________。線路協定的狀態是:___________。
網際網路位址是: _____________________
封裝:_______________
封裝涉及 OSI 哪一層?________________
c. 如果設定了序列介面,為什麼 show interface serial 0/0 顯示該介面為關閉狀態?
______________________________________________________________________________
步驟 6: 在 R2 上設定序列介面
在全域設定模式下,設定路由器 R1 上的序列介面 Serial 0。請參閱本實驗說明末尾的路由器介面概要表,
尋找您在本實驗中所採用的路由器上對應的序列介面。
R2(config)#interface serial 0/0
R2(config-if)#ip address 172.17.0.2 255.255.0.0 R2(config-if)#clock rate 64000
R2(config-if)#no shutdown R2(config-if)#exit
R2(config)#exit
注意: 只能在纜線的 DCE 介面端所連接的路由器序列介面上輸入時脈頻率。Null 序列纜線每一端的外側都印 有其纜線類型(DTE 或 DCE)。如有疑問,可在兩個路由器序列介面中同時輸入 clock rate 命令。在連接 DTE 端的路由器上,該命令會被略過。命令 no shutdown 會開啟介面。命令 shutdown 會關閉介面。
步驟 7: 顯示有關 R2 上序列介面的資訊
a. 在 R2 上輸入 show interfaces 命令。參考路由器介面概要表。
R2#show interface serial 0/0
Serial0/0 is up, line protocol is up Hardware is PowerQUICC Serial Internet address is 172.17.0.2/16
MTU 1500 bytes, BW 128 Kbit, DLY 20000 usec,
reliability 255/255, txload 1/255, rxload 1/255 Encapsulation HDLC, loopback not set
Keepalive set (10 sec)
Last input 00:00:08, output 00:00:08, output hang never Last clearing of "show interface" counters 00:04:54
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0 Queueing strategy: fifo
Output queue :0/40 (size/max)
5 minute input rate 0 bits/sec, 0 packets/sec 5 minute output rate 0 bits/sec, 0 packets/sec 3 packets input, 72 bytes, 0 no buffer
Received 3 broadcasts, 0 runts, 0 giants, 0 throttles
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort 6 packets output, 933 bytes, 0 underruns
0 output errors, 0 collisions, 2 interface resets 0 output buffer failures, 0 output buffers swapped out 0 carrier transitions
DCD=up DSR=up DTR=up RTS=up CTS=up b. 至少列出三項透過此命令瞭解到的具體資訊。
Serial 0 的狀態是:_________。線路協定的狀態是:___________。
網際網路位址是: _____________________
封裝:_______________
封裝涉及 OSI 哪一層?________________
c. 為什麼 show interface serial 0/0 顯示該介面為開啟狀態?
______________________________________________________________________________
步驟 8: 校驗序列連接是否能夠正常工作
a. 使用 ping 命令測試與另一個路由器上序列介面的連通性。從 R1 ping R2 路由器的序列介面。
R1#ping 172.17.0.2 能否 ping 通?_____
b. 從 R2 ping R1 路由器的序列介面。
R2#ping 172.17.0.1 能否 ping 通?_____
c. 如果上述任意一個問題的答案為否,則檢查路由器的設定並糾正錯誤。然後重新 ping 這兩個介面,
直到兩個問題都得到肯定回答為止。
步驟 9: 在 R1 上設定 FastEthernet 介面
在全域設定模式下,設定路由器 R1 上的乙太網路介面。請參閱本實驗說明末尾的路由器介面摘要表,
尋找您在本實驗中所採用的路由器上對應的乙太網路介面。
R1(config)#interface FastEthernet 0/0
R1(config-if)#ip address 172.16.0.1 255.255.0.0 R1(config-if)#no shutdown
R1(config-if)#exit R1(config)#exit
注意: Ethernet 介面不區分 DTE 和 DCE。所以沒有必要輸入 clock rate 命令。
步驟 10: 顯示有關 R1 上高速乙太網路介面的資訊
a. 在 R1 上輸入 show interface 命令。參考路由器介面概要表。
R1#show interface FastEthernet 0/0
FastEthernet0/0 is up, line protocol is up
Hardware is AmdFE, address is 000c.3076.8460 (bia 000c.3076.8460) Internet address is 172.16.0.1/16
MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec, reliability 255/255, txload 1/255, rxload 1/255 Encapsulation ARPA, loopback not set
Keepalive set (10 sec)
Auto-duplex, Auto Speed, 100BaseTX/FX ARP type: ARPA, ARP Timeout 04:00:00
Last input never, output 00:00:18, output hang never Last clearing of "show interface" counters never
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0 Queueing strategy: fifo
Output queue :0/40 (size/max)
5 minute input rate 0 bits/sec, 0 packets/sec 5 minute output rate 0 bits/sec, 0 packets/sec 0 packets input, 0 bytes
Received 0 broadcasts, 0 runts, 0 giants, 0 throttles 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored 0 watchdog
0 input packets with dribble condition detected 52 packets output, 5737 bytes, 0 underruns
0 output errors, 0 collisions, 1 interface resets 0 babbles, 0 late collision, 0 deferred
52 lost carrier, 0 no carrier
0 output buffer failures, 0 output buffers swapped out b. 至少列出三項透過此命令瞭解到的具體資訊。
FastEthernet 0 的狀態是:_________。線路協定的狀態是:___________。
網際網路位址是: _____________________
封裝:_______________
封裝涉及 OSI 哪一層?________________
c. 為什麼 show interface FastEthernet 0/0 顯示該介面為開啟狀態?
______________________________________________________________________________
步驟 11: 在 R2 上設定高速乙太網路介面
在全域設定模式下,設定路由器 R2 上的乙太網路介面。請參閱本實驗說明末尾的路由器介面概要表,
尋找您在本實驗中所採用的路由器上對應的乙太網路介面。
R2(config)#interface FastEthernet 0/0
R2(config-if)#ip address 172.18.0.1 255.255.0.0 R2(config-if)#no shutdown
R2(config-if)#exit R2(config)#exit
注意: Ethernet 介面不區分 DTE 和 DCE。所以沒有必要輸入 clock rate 命令。
步驟 12: 顯示有關 R2 上高速乙太網路介面的資訊
a. 在 R2 上輸入 show interface FastEthernet 0/0 命令。參考路由器介面概要表。
R2#show interfaces FastEthernet 0/0
FastEthernet0/0 is up, line protocol is up
Hardware is AmdFE, address is 000c.3076.8460 (bia 000c.3076.8460) Internet address is 172.16.0.1/16
MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec, reliability 255/255, txload 1/255, rxload 1/255 Encapsulation ARPA, loopback not set
Keepalive set (10 sec)
Auto-duplex, Auto Speed, 100BaseTX/FX ARP type: ARPA, ARP Timeout 04:00:00
Last input never, output 00:00:05, output hang never Last clearing of "show interface" counters never
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0 Queueing strategy: fifo
Output queue :0/40 (size/max)
5 minute input rate 0 bits/sec, 0 packets/sec 5 minute output rate 0 bits/sec, 0 packets/sec 0 packets input, 0 bytes
Received 0 broadcasts, 0 runts, 0 giants, 0 throttles 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored 0 watchdog
0 input packets with dribble condition detected
14 packets output, 1620 bytes, 0 underruns
0 output errors, 0 collisions, 1 interface resets 0 babbles, 0 late collision, 0 deferred
14 lost carrier, 0 no carrier
0 output buffer failures, 0 output buffers swapped out b. 至少列出三項透過此命令瞭解到的具體資訊。
FastEthernet 0/0 的狀態是:_________。線路協定的狀態是:___________。
網際網路位址是:_____________________
封裝:_______________
封裝涉及 OSI 哪一層?________________
c. 為什麼 show interfaces FastEthernet 0/0 顯示該介面為開啟狀態?
______________________________________________________________________________
步驟 13: 在兩台路由器上儲存設定
在特權執行模式下,將執行中的設定儲存到啟動設定中。
R1#copy running-config startup-config R2#copy running-config startup-config
注意: 儲存執行中設定的目的是便於路由器在下一次重新啟動時使用該設定。可透過軟體 reload 命令或關 閉電源來重新啟動路由器。如果沒有儲存,那麼在重新啟動後執行中的設定會遺失。路由器啟動後便會執 行啟動設定。
步驟 14: 檢查整體路由器設定
在兩台路由器的特權執行模式下,執行 show running-config 命令,然後檢查到目前為止輸入的所有設定 命令。該命令可縮寫為 sh run。
R1#show running-config R2#show running-config
步驟 15: 校驗高速乙太網路連線是否能夠正常工作
a. 按一下開始 > 執行,然後鍵入 cmd 開啟命令行提示字元。或者,也可按一下開始 > 所有程式 > 附屬 應用程式 > 命令提示字元。
b. 分別針對每一台路由器,在與其相連的 PC 上使用 ping 命令來測試 PC 與路由器高速乙太網路介面的 連通性。從 PC1 ping R1 路由器的高速乙太網路介面。
R1#ping 172.16.0.1 能否 ping 通?_____
c. 從 PC1 ping R2 路由器的高速乙太網路介面。
R2#ping 172.18.0.1 能否 ping 通?_____
d. 如果上述任意一個問題的答案為否定,則檢查路由器的設定糾正錯誤。然後重新 ping 這兩個介面,直 到兩個問題都得到肯定回答為止。
步驟 16:(選作)測試連通性
a. 從 PC1 ping R1 路由器的高速乙太網路介面(預設閘道)。
C:\>ping 172.16.0.1 能否 ping 通?_____
b. 在 PC1 的命令提示字元下,使用 ping 命令測試 PC1 (172.16.0.2) 與 PC2 (172.18.0.2) 的端對端連 通性。
C:\>ping 172.18.0.2 能否 ping 通?_____
c. 從 PC1 ping 不通 PC2,原因是 R1 不瞭解 R2 上的乙太網路,而路由器 R2 也不瞭解 R1 上的乙太網 路。PC1 發出的 ping 命令無法到達 PC2;即使能到達,也收不到回應。
步驟 17:(選作)設定靜態路由和預設路由
a. 要使 PC 之間能夠相互 ping 通,必須在每一台路由器上設定預設路由和靜態路由,或者在它們之間設 定動態路由協定。
b. 按如下所示在兩台路由器上設定預設路由:
R1(config)#ip route 0.0.0.0 0.0.0.0 172.17.0.2 R2(config)#ip route 0.0.0.0 0.0.0.0 172.17.0.1 c. 按如下所示在兩台路由器上設定靜態路由:
R1(config)#ip route 172.18.0.0 255.255.0.0 172.17.0.2 R2(config)#ip route 172.16.0.0 255.255.0.0 172.17.0.1 d. 重複步驟 16 中說明的 ping 操作。現在應該能夠 ping 通。
e. 在每台路由器上分別使用 show ip route 命令來檢視預設路由與靜態路由。
R1(config)#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route
Gateway of last resort is 172.17.0.2 to network 0.0.0.0 C 172.17.0.0/16 is directly connected, Serial0/0
C 172.16.0.0/16 is directly connected, FastEthernet0/0 S 172.18.0.0/16 [1/0] via 172.17.0.2
S* 0.0.0.0/0 [1/0] via 172.17.0.2
R2(config)#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route
Gateway of last resort is 172.17.0.1 to network 0.0.0.0 C 172.17.0.0/16 is directly connected, Serial0/0 S 172.16.0.0/16 [1/0] via 172.17.0.1
C 172.18.0.0/16 is directly connected, FastEthernet0/0 S* 0.0.0.0/0 [1/0] via 172.17.0.1
清除並重新載入路由器
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。
現在便可將路由器用於指定的實驗了。
路由器介面概要
路由器型號 乙太網路介面 #1 乙太網路介面 #2 序列介面 #1 序列介面 #2 800 (806) Ethernet 0 (E0) Ethernet 1 (E1)
1600 Ethernet 0 (E0) Ethernet 1 (E1) Serial 0 (S0) Serial 1 (S1) 1700 Fast Ethernet 0
(FA0)
Fast Ethernet 1 (FA1)
Serial 0 (S0) Serial 1 (S1) 1800 Fast Ethernet 0/0
(FA0/0)
Fast Ethernet 0/1 (FA0/1)
Serial 0/0/0 (S0/0/0)
Serial 0/0/1 (S0/0/1) 2500 Ethernet 0 (E0) Ethernet 1 (E1) Serial 0 (S0) Serial 1 (S1) 2600 Fast Ethernet 0/0
(FA0/0)
Fast Ethernet 0/1 (FA0/1)
Serial 0/0 (S0/0) Serial 0/1 (S0/1) 注意: 要瞭解路由器的確切設定方式,請觀察路由器的介面。這樣可以確定路由器的類型,以及路由 器擁有的介面數量。我們無法為每類路由器列出所有的設定組合,而只能提供裝置介面的可能識別碼 組合。此介面表未包含任何其他類型的介面,但實際的路由器可能會含有其他介面,例如 ISDN BRI 介面。括弧中的字串是合法的縮寫方式,可在 IOS 命令中用來代表介面。
用於啟動 SDM 的 SDM 路由器基本 IOS 設定
如果在 SDM 路由器中刪除 startup-config,那麼在重新啟動該路由器後 SDM 不會預設啟動。此時就需 要按照以下方法構建基本設定。有關設定與使用 SDM 的詳細資訊,請參閱《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