A.实验环境: Cisco packet tracer (思科模拟器)
B.基本要求:
完成基本实验拓扑的搭建。完成对switch/router 设备的重命名。(删除重命名)清除非初始配置。保护用户模式(设置密码)保护远程 telnet/ssh 访问保护特权模式保护配置文件中的所有密码提供约定通知详细配置ssh登录查看各种配置信息保存配置
C.实验拓扑图
D.2-8配置命令
Switch>Switch>enSwitch#conf tEnter 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 //保护用户模式,设置密码为ciscoS1(config-line)#password ciscoS1(config-line)#login//使console口配置生效S1(config-line)#line vty 0 15//保护远程访问,配置16个远程终端S1(config-line)#password cisco//配置密码ciscoS1(config-line)#exec-timeout 10 //闲暇时自动断开用户S1(config-line)#login//使远程端口配置生效S1(config-line)#enable secret class //保护特权模式,配置密码为classS1(config)#service password-encryption //保护配置文件中所有密码(变明文为密文)S1(config)#banner motd #no unautherized access allowed#//设置标语信息
E.配置SSH登录
S1#show ip ssh //首先查看设备是否支持SSHSSH 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//配置域名为S1(config)#crypto key generate rsa //生成加密密钥The name for the keys will be: Choose the size of the key modulus in the range of 360 to 2048 for yourGeneral Purpose Keys. Choosing a key modulus greater than 512 may takea 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 4S1(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
补充:理论知识
模式
模式1:用户模式
当显示switch>时,表明为用户模式。
用户模式主要用于查看统计信息,能做的非常有限。但也是通过用户模式才能进入更高级模式进行配置。
模式2:特权模式
当显示switch#时,表明为特权模式。
特权模式就可以修改思科路由器的配置了。需要进入此模式,只需在用户模式下输入enable
switch>enableswitch#
当需要从特权模式返回用户模式,只需要输入disable
switch#diableswitch>
当想要退出控制台时,输入命令logout
switch>logout
模式2:全局模式
进入全局配置模式,可以对运行配置进行修改,通常情况下,只需修改一次,就会影响整台路由器。
从特权模式进行全局模式:
switch#configure terminalswitch(conf)#
补充:常用代码集合
switch>enable //进入特权模式Switch(config)#hostname S1 //完成对设备的重命名S1(config)#no hostname //删除重命名switch#configure terminal //进入全局设置模式S1(config)#line console 0 //保护用户模式,设置密码为ciscoS1(config-line)#password ciscoS1(config-line)#login//使console口配置生效S1(config-line)#line vty 0 15//保护远程访问,配置16个远程终端S1(config-line)#password cisco//配置密码ciscoS1(config-line)#exec-timeout 10 //闲暇时自动断开用户S1(config-line)#login//使console口配置生效S1#username test secert cisco //创建一个名为test,密码为cisco的用户。S1(config)#service password-encryption //保护配置文件中所有密码(变明文为密文)S1(config)#banner motd #no unautherized access allowed#//设置标语信息SwitchA#copy running-config startup-config //保存当前配置于启动配置中。Destination filename [startup-config]? Building configuration...[OK]SwitchA#switch(conf)#//1.查看当前配置SwitchA#show running-config
配置管理SV1
S-1(config)#int vlan 1//生成配置VLAN1S-1(config-if)#ip addS-1(config-if)#ip address 10.1.0.1 ?A.B.C.D IP subnet maskS-1(config-if)#ip address 10.1.0.1 255.255.255.0//配置VLAN1 IP地址S-1(config-if)#no shutdown //启用VLAN1