Cisco PT案例一:為交換機配置並連接TELNET


Telnet協議是TCP/IP協議族中的一員,是Internet遠程登陸服務的標准協議和主要方式。它為用戶提供了在本地計算機上完成遠程主機工作的能力。在終端使用者的電腦上使用telnet程序,用它連接到服務器。終端使用者可以在telnet程序中輸入命令,這些命令會在服務器上運行,就像直接在服務器的控制台上輸入一樣。可以在本地就能控制服務器。要開始一個telnet會話,必須輸入用戶名和密碼來登錄服務器。Telnet是常用的遠程控制Web服務器的方法。

環境

  • Cisco Packet Tracer 5.3
  • Windows 10

操作

操作:按照如圖所示連接拓撲圖

image.png

(1)配置PC IP
PC0 設置
192.168.1.2/24
PC1 設置
192.168.1.3/24

(2)配置交換機VLAN1 IP

/* part1 為vlan配置ip並開啟vlan */
Switch>enable
Switch#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#interface vlan 1
Switch(config-if)#ip address 192.168.1.1 255.255.255.0
Switch(config-if)#no shutdown

%LINK-5-CHANGED: Interface Vlan1, changed state to up


%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to up
Switch(config-if)#

/* Part2 查看已配置的IP */
Switch(config-if)#^Z
Switch#
%SYS-5-CONFIG_I: Configured from console by console

Switch#show running-config
...
interface Vlan1
 ip address 192.168.1.1 255.255.255.0

/*  Part3 開啟Vlan */
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.    
Switch(config)#interface vlan 1
Switch(config-if)#no shutdown

/* Part4 查看Vlan狀態 */
Switch(config-if)#^Z
Switch#
%SYS-5-CONFIG_I: Configured from console by console

Switch#show interfaces vlan 1
Vlan1 is up, line protocol is up
...

(3)配置交換機本地登錄口令

/* Part 1 設置明文密碼*/
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#enable password 123
// 注:取消密碼可用no enable password

/* Part 2查看設置的密碼 */
Switch(config)#^Z
Switch#
%SYS-5-CONFIG_I: Configured from console by console

Switch#show running-config
...
enable password 123
...

(4)配置交換機遠程登陸及驗證

Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#line vty 0
Switch(config-line)#password 123 //(Telnet密碼為123)
Switch(config-line)#login local //(login是開啟遠程登錄密碼驗證,login local不但要求TELNET密碼,還要求提供用戶名)
Switch(config-line)#

(5)添加可遠程登陸交換機的用戶

/* Part 1 添加用戶 */
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#line vty 0
Switch(config-line)#password 123
Switch(config-line)#login local
Switch(config-line)#
Switch(config-line)#exit
Switch(config)#username admin password admin

/* Part 2 查看添加的用戶 */
Switch(config)#exit
Switch#
%SYS-5-CONFIG_I: Configured from console by console

Switch#show running-config
...
username admin password 0 admin
...


(6)測試連接

// 在PC0的CMD中測試
/* Part 1 Ping交換機 */
PC>ping 192.168.1.1

Pinging 192.168.1.1 with 32 bytes of data:

Reply from 192.168.1.1: bytes=32 time=5ms TTL=255
Reply from 192.168.1.1: bytes=32 time=5ms TTL=255
Reply from 192.168.1.1: bytes=32 time=6ms TTL=255
Reply from 192.168.1.1: bytes=32 time=6ms TTL=255

Ping statistics for 192.168.1.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 5ms, Maximum = 6ms, Average = 5ms
    
/* Part 2 Telnet 連接交換機 */
PC>telnet 192.168.1.1
Trying 192.168.1.1 ...Open

User Access Verification

Username: admin
Password: 
Switch>

(7)配置多用戶連接

// 在PC0連接的前提下,再使用PC1嘗試連接
/* Part 1 PC1 Ping Switch */
PC>ping 192.168.1.1

Pinging 192.168.1.1 with 32 bytes of data:

Request timed out.
Reply from 192.168.1.1: bytes=32 time=6ms TTL=255
Reply from 192.168.1.1: bytes=32 time=6ms TTL=255
Reply from 192.168.1.1: bytes=32 time=5ms TTL=255

Ping statistics for 192.168.1.1:
    Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),
Approximate round trip times in milli-seconds:
    Minimum = 5ms, Maximum = 6ms, Average = 5ms
    
/* Part 2 PC1 Telnet 連接Swithc */
PC>telnet 192.168.1.1
Trying 192.168.1.1 ...Open

[Connection to 192.168.1.1 closed by foreign host]
// 連接失敗,因為交換機vty設置只能同時打開一個會話,下面設置一下,使兩台PC可同時訪問

/* Part 3 修改Tenlet配置 */
// 可直接在PC0直接進行
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#line vty 0 1
Switch(config-line)#password 123
Switch(config-line)#^Z

/* Part 4 重新嘗試Part 2 */
PC>telnet 192.168.1.1
Trying 192.168.1.1 ...Open


User Access Verification

Password: 
Switch>
// 成功


免責聲明!

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



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