环境:Packet Tracer
CLI命令行的几种模式
Switch> #用户模式
Switch>enable
Switch# #特权模式
Switch#configure terminal
Switch(config)# #全局模式
Switch(config)#int vlan 1
Switch(config-if)# #接口配置
Switch(config)#line vty 0 4
Switch(config-line)# #线路模式
基础配置
1、给交换机进行初始配置
Switch>enable
Switch#setup
...
前面有两个“yes”,
Enter host name [Switch]: aaa #配置交换机的主机名
Enter enable password: zbzr0823 #设置交换机密码
Enter virtual terminal password: zbzr0823 #确认密码
Configure SNMP Network Management? [no]:no #不设置SNMP协议
management network from the above interface summary: vlan1 #选择要设置的接口
Configuring interface Vlan1:
Configure IP on this interface? [yes]: yes #是否给交换机设置IP
IP address for this interface: 192.168.9.2 #设置交换机的IP
Subnet mask for this interface [255.255.255.0] : 255.255.255.0 #设置交换机的子网掩码
Would you like to enable as a cluster command switch? [yes/no]:yes #是否要启用群集命令开关?
之后输入”2“选择生效以上的配置即可。
...
2、进vlan1,配置IP
aaa>en
aaa>enable
Password:
aaa#confi
aaa#configure t
aaa#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
aaa(config)#int vlan 1
aaa(config-if)#ip add
aaa(config-if)#ip address 192.168.9.2 255.255.255.0
以Console,和telnet的方式连接交换机
1、Console方式:
选择蓝色的线,用PC的RS 232接口连接交换机的Console接口,然后进入,双击PC的”Terminal“,然后确认即可。
设置Console登陆时需要密码:
Switch(config)#line console 0
Switch(config-line)#password 123456
Switch(config-line)#login
此后在使用Console登陆时就需要这个密码。
2、使用Telnet远程连接的方式:
- 先给交换机,PC配置IP。需要在同一网段。
- 进入到交换机的线路模式,配置用户登陆vty
Switch#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#line vty 0 4
Switch(config-line)#password 123456 #设置密码,不设置不行。
Switch(config-line)#login
- 开启vlan1的端口
Switch(config-if)#no shutdown
4、查看所做的配置
Switch#show running-config
5、在PC的命令行登陆
PC>telnet 192.168.9.2
Trying 192.168.9.2 ...Open
User Access Verification
Password:
Switch>
6、给交换机本身设置密码
Switch(config)#enable password qqq #设置明文密码
Switch(config)#enable secret zzz #设置密文密码
注意此时在使用telnet远程连接时就要输入密文密码。
7、清除配置信息
Switch#erase startup-config
8、将配置全部加密
Switch(config)#service password-encryption
9、直接设置主机名
Switch(config)#hostname ff
10、显示当前运行配置信息
ff#show running-config
快捷键
1、出现如下情况,点击啥不没反应的,如下:
Ctrl+shift+6
2、直接回到特权模式
Ctrl+z
3、补全
Tab键
4、显示历史命令
Ctrl+P 上一条历史命令
Ctrl+N 下一条历史命令
5、移动光标
Ctrl+A #将光标移到命令行之首
Ctrl+E #将光标移到命令行之尾