A.实验环境: Cisco packet tracer (思科模拟器)
B.基本要求:
- 完成基本实验拓扑的搭建。
- 完成对switch/router 设备的重命名。(删除重命名)
- 清除非初始配置。
- 保护用户模式(设置密码)
- 保护远程 telnet/ssh 访问
- 保护特权模式
- 保护配置文件中的所有密码
- 提供约定通知
- 详细配置ssh登录
- 查看各种配置信息
- 保存配置
C.实验拓扑图
D.2-8配置命令
Switch>
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname S1 //完成对设备的重命名
S1(config)#no hostname //删除重命名
Switch(config)#clear running config //清除非初始配置
S1(config)#line console 0 //保护用户模式,设置密码为cisco
S1(config-line)#password cisco
S1(config-line)#login //使console口配置生效
S1(config-line)#line vty 0 15 //保护远程访问,配置16个远程终端
S1(config-line)#password cisco //配置密码cisco
S1(config-line)#exec-timeout 10 //闲暇时自动断开用户
S1(config-line)#login //使远程端口配置生效
S1(config-line)#enable secret class //保护特权模式,配置密码为class
S1(config)#service password-encryption //保护配置文件中所有密码(变明文为密文)
S1(config)#banner motd #no unautherized access allowed#
//设置标语信息
E.配置SSH登录
S1#show ip ssh //首先查看设备是否支持SSH
SSH Disabled - version 1.99 //如果显示则代表支持
%Please create RSA keys (of atleast 768 bits size) to enable SSH v2.
Authentication timeout: 120 secs; Authentication retries: 3
S1(config)#ip domain-name test.com //配置域名为test.com
S1(config)#crypto key generate rsa //生成加***
The name for the keys will be: S1.test.com
Choose the size of the key modulus in the range of 360 to 2048 for your
General Purpose Keys. Choosing a key modulus greater than 512 may take
a few minutes.
How many bits in the modulus [512]: //选择**的建模量,默认为512,直接点击回车键即可
% Generating 512 bit RSA keys, keys will be non-exportable...[OK]
S1(config)#username test secret cisco //本地创建一个用户名为test,密码为cisco
S1(config)#line vty 0 4
S1(config-line)#login local //配置认证方式为本地用户认证
S1(config-line)#transport input ssh //接收ssh访问
F.查看各种配置信息
//1.查看当前配置
SwitchA#show running-config
//2.显示当前版本信息
SwitchA#show version
//3.显示交换机的MAC地址
SwitchA#show mac address-table
SwitchA#clear mac address-table dynamic //清除并再次显示MAC表
//4.在PC时显示ARP表
# arp -a
//5.
G.保存配置
SwitchA#copy running-config startup-config //保存当前配置于启动配置中。
Destination filename [startup-config]?
Building configuration...
[OK]
SwitchA#
H.注意事项
- 使设备进行重新加载
#reload
- 在telnet 之前可以先ping一下,确保在能ping通的情况下再进行telnet的配置。
- 远程登录认证方式有多种,其中一种为无认证登录 ,一种为密码认证方式,还有一种为本地用户名+密码的组合认证方式。
//1.无认证登录
#line vty 0 15
#no login
//2密码认证方式
#line vty 0 15
#login
#password cisco
//3本地用户名+密码组合认证方式
#line vty 0 15
#login local
- 创建本地用户名(用于在第三种情况,ssh使用本地用户+密码的方式远程登录)
#username test secert cisco //创建一个名为test,密码为cisco的用户。
- 配置远程登录的保护措施–闲暇时自动断开用户
#line vty 0 4
#exec-timeout 0 10 //表示登录后无操作10秒后超时登出。
#exec-timeout 0 0 //表示 登录永不超时。
#end
- 对配置文件密码的加密,将明文密码变成密文,但是只对设备中的配置文件的密码有效,对于网络发送密码不适于。
S1(config)#service password-encryption