思科 telnet配置

条件
一台交换机能够通过 Telnet 登录的条件是:
1. 交换机已经配置了 IP 地址;
2. 交换机已经配置了远程登录密码;
3. 交换机已经配置了特权密码;
4. 交换机已经接入网络并开始工作。
5. 交换机的 vlan 1 激活

这时,我们可以通过网络中的一台计算机,在命令行下输入 “ telnet 交换机 IP 地址 ”登录到交换机上对交换机进行配置。
如果登录的交换机没有配置远程登录密码,会显示 “ Password required, but none set ” 的错误提示信息;如果没有设置特权密码,在进入特权模式时会显示 “ %Nopassword set ”的错误提示信息。
所以,对于一台新购置的交换机,必须先用控制台为交换机配置 IP 地址和远程 登录密码,以后就可以用远程登录管理这台交换机了。
配置举例: 用控制台为交换机配置 IP 地址、远程登录密码和特权密码。

 Switch> enable

Switch# configure terminal

Switch(config)# interface vlan 1

Switch(config-if)# ip address 192.168.1.5 255.255.255.0

Switch(config-if)# exit

Switch(config)# line vty 0 4

Switch(config-line)# login

Switch(config-line)# password 123

Switch(config-line)# exit

Switch(config)# enable secret 456

Switch(config)# end

Switch#

 

开启和禁止远程录
默认情况下, Telnet Server 是打开的,任何人都可以用 Telnet 访问交换机,
我们可以用命令禁止使用 Telnet 访问交换机。
模式: 在全局配置模式中配置。
关闭 Telnet Server
Switch(config)# no enable service telnet-server
开启 Telnet Server
Switch(config)# enable service telnet-server
说明: 关闭 Telnet 访问不影响使用控制台、 Web SNMP 访问交换机。
配置举例: 关闭交换机的远程登录访问。
Switch> enable
Switch# configure terminal
Switch(config)# no enable service telnet-server

限制远程登录访问
Telnet Server 开启时,我们可以配置允许远程登录的 IP 地址,这样,可以
限制用户只能从指定计算机远程登录交换机。
模式: 在全局配置模式中配置。
配置命令:
Switch(config)# service telnet host host-ip
参数 host-ip 为允许远程登录的用户的 IP 地址。

说明: 你可以多次使用此命令设置多个允许远程登录的合法用户 IP。如果不配 置此项,默认是不限制使用者的 IP 地址。

删除配置的 Telnet 限制:

Switch(config)# no service telnet host host-ip 此命令只删除指定的 IP 。

Switch(config)# no service telnet host 此命令删除所有的 IP。

配置举例: 只允许 IP 地址为 192.168.1.10 和 192.168.1.30 的用户用 Telnet 登录交换机。

Switch> enable

Switch# configure terminal

Switch(config)# service telnet host 192.168.1.10

Switch(config)# service telnet host 192.168.1.30

设置远程登录的超时时间 :

当你用 Telnet 登录交换机后,如果在设定的超时时间内没有任何输入,交换机
会自动断开该连接,所以设置超时时间有一定的保护作用。
Telnet 的超时时间默认为 5 分钟,你可以用命令修改它。
模式: 线路配置模式

配置命令:
Switch(config-line)# exec-timeout time

参数 time 为设置的超时时间,单位为秒,取值为 0~3600 ,如果设置为 0 , 表示不限定超时时间 。说明: 你必须先用 line vty 命令进入远程登录的线路模式再配置超时时间。
删除配置的 Telnet 超时时间:
Switch(config-line)# no exec-timeout
删除后,超时时间恢复为默认的 5 分钟。

配置举例: 设置远程登录的超时时间为 10 分钟( 600 秒)。

Switch> enable

Switch# configure terminal

Switch(config)# line vty

Switch(config-line)# exec-timeout 600

查看 Telnet Server 的状态
在特权模式下, 用 show service 命令可以查看 Telnet Server 是否已被禁用。
举例: 查看交换机 Telnet Server 的状态。
Switch> enable
Switch# show service
SSH-server : Enabled
Snmp-agent : Disabled
Telnet-server : Enabled
Web-server : Enabled

猜你喜欢

转载自www.cnblogs.com/wuyu19/p/12082104.html