要通過 telnet 訪問路由器,需要先通過 console 口對路由器進行基本配置,例如:IP
地址、密碼等。
1. 實驗目的
通過本實驗,讀者可以掌握如下技能:
(1) 配置路由器以太網接口的 IP 地址,並打開接口;
(2) 配置路由器的 enable 密碼和 vty 密碼;
(3) telnet 程序的使用。
2. 實驗拓撲
3. 實驗步驟
(1) 步驟 1:配置路由器以太網接口 IP 地址
Router>enable
Router#
//以上是進入路由器的特權模式
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router (config)#
//以上是進入路由器的配置模式
Router (config)# interface g0/0
Router (config-if)#
//以上是進入路由器的以太網口 g0/0 接口,g0/0 中 g 表示是 Gig abitEthernet, 0/0 表示
是第 0 個插槽中的第 0 個接口。S0/0/0 則表示爲第 0 個插槽中的第 0 個模塊上的第 0 個串
行接口。
Router (config-if)#ip address 192.168.1.1 255.255.255.0
//以上是配置接口的 IP 地址
Router (config-if)#no shutdown
//以上是打開接口,默認時路由器的所有接口都是關閉的,這一點和交換機有很大差別
Router (config-if)#end
//退出配置模式
(2) 步驟 2:配置路由器密碼
Router#conf terminal
Router(config)#line vty 0 4
//以上是進入路由器的 VTY 虛擬終端下, “vty 0 4”表示 vty 0 到 vty 4,共 5 個虛擬終端
Router(config-line)# password CISCO
Router(config-line)# login
//以上是配置 vty 的密碼,即 telnet 密碼
Router(config-line)# exit
Router(config)#enable password CISCO
//以上是配置進入到路由器特權模式的密碼
Router(config)#end
(3) 步驟 3:通過 telnet 訪問路由器
在計算機上配置網卡的 IP 地址爲 192.168.16.2/255.255.255.0,並打開 DOS 命令行窗口。
首先測試計算機和路由器的 IP 連通性,再進行 telnet 遠程登錄。如下:
C:\>ping 192.168.1.1
Pinging 192.168.1.1 with 32 bytes of data:
Reply from 192.168.1.1: bytes=32 time<1ms TTL=255
Reply from 192.168.1.1: bytes=32 time<1ms TTL=255
Reply from 192.168.1.1: bytes=32 time<1ms TTL=255
Reply from 192.168.1.1: bytes=32 time<1ms TTL=255
Ping statistics for 192.168.1.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% lo
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
//以上表明計算機能 ping 通路由器
C:\>telnet 192.168.1.1
//telnet 路由器以太網卡上的 IP 地址
User Access Verification
Password:
Router>enable
Password:
Router#exit
//輸入 vty 的密碼 CISCO、輸入 enable 的密碼 CISCO,能正常進入路由器的特權模式。
4. 實驗調試
如果無法從計算機上 ping 通路由器,依照以下步驟進行
(1) 檢查計算機、交換機、路由器之間的連接是否鬆動;
(2) 檢查連接線應該是否是直通線;
(3) 檢查計算機的網卡和 IP 地址是否正常;
(4) 在路由器上,檢查以太網接口是否正常
Router#show int g0/0
GigabitEthernet0/0 is up, line protocol is up
Hardware is MV96340 Ethernet, address is 0019.5535.b828 (bia 0019.5535.b828)
Internet address is 192.168.1.1/24
應該看到兩個“up”,否則檢查路由器和交換機之間的連接。