起序:本文是在 交換機常用命令 基礎上製作的,需要會使用基礎交換機命令。
一、網絡拓撲圖
話不多說,開局一張圖,內容全靠編。
二、配置交換機 S1
交換機
上有一個可以配置IP 地址
的物理接口 。遠程管理這個小接口就可以了,這個IP 地址
就成爲這個交換機
的管理 IP 地址
。
# 進入 `特權模式`
Switch>en
# 進入 `全局配置模式`
Switch#conf t
# 進入可以配置 `IP 地址` 的 `物理接口配置模式`
Switch(config)#int vlan 1
# 給接口配置 IP 地址(格式:ip add IP地址 網關)
Switch(config-if)#ip add 192.168.1.253 255.255.255.0
# 啓動這個接口
Switch(config-if)#no sh
測試
交換機
配置的IP 地址
是否可以 ping 的通。
ping 192.168.1.253
三、通過用戶名和密碼登陸
1、開啓 all 選項
可以使用
telnet
和ssh
連接,這裏兩個都是,而且都是通過用戶名
和密碼
驗證登陸。
# 進入 `特權模式`
Switch>en
# 進入 `全局配置模式`
Switch#conf t
# 表示可以有 5 個人可以同時遠程操作這個設備
Switch(config)#line vty 0 4
# 使用 all,包含 telnet 和 ssh。
Switch(config-line)#transport input all
# 使用本地 賬號密碼 數據庫來驗證
Switch(config-line)#login local
# 離開
Switch(config-line)#exit
# 設置賬號密碼
Switch(config)#username 123 password 123.com
Switch(config)#username 456 password 456.com
# 配置主機名
Router(config)#ho R1
# 配置域名,這個域名隨便起,但要符合域名格式
S1(config)#ip domain-name S1.it.com
# 使用 rsa 算法生成 512 位的 公鑰 和 私鑰
S1(config)#crypto key generate rsa # 點擊回車後,如果選擇默認,直接再次點擊回車就好
彙總
2、telnet、ssh 遠程連接
交換機 S1
設置特權密碼
。
# 進入 `特權模式`
S1>en
# 進入 `全局配置模式`
S1#conf t
# 設置特權密碼(密文)
S1(config)#enable secret 123456
- telnet 遠程連接
- ssh 遠程連接
四、跨網段連接
1、配置交換機 S2
比如現在想控制
網絡拓撲圖
中IP 地址
爲192.168.2.253
的交換機
,首先時配置交換機 S2
,和配置交換機 S1
是一樣的。
# 進入 `特權模式`
Switch>en
# 進入 `全局配置模式`
Switch#conf t
# 進入可以配置 `IP 地址` 的 `物理接口配置模式`
Switch(config)#int vlan 1
# 給接口配置 IP 地址(格式:ip add IP地址 網關)
Switch(config-if)#ip add 192.168.2.253 255.255.255.0
# 啓動這個接口
Switch(config-if)#no sh
Switch(config-if)#exit
Switch(config)#line vty 0 4
Switch(config-line)#transport input all
Switch(config-line)#login local
Switch(config-line)#exit
Switch(config)#username 789 password 789.com
Switch(config)#ho S2
S2(config)#ip domain-name S2.it.com
S2(config)#crypto key generate rsa
但此時通過
PC1
遠程連接交換機 S2
是失敗的,因爲交換機 S2
還需要配置網關
。
S2>en
S2#conf t
S2(config)#ip default-gateway 192.168.2.254
2、telnet、ssh 遠程連接
交換機 S2
設置特權密碼
。
# 進入 `特權模式`
S2>en
# 進入 `全局配置模式`
S2#conf t
# 設置特權密碼(密文)
S2(config)#enable secret 123456
- telnet 遠程連接
- ssh 遠程連接
如果對您有幫助,點個贊再走吧。