关闭CISCO路由器不需要的服务

  • 格式:doc
  • 大小:72.50 KB
  • 文档页数:11

关闭Cisco不需要的服务

这里假设路由器有Ethernet0和Ethernet1端口

Router(config)# no cdp run//关闭CDP协议,CDP使用多播地址,能够发现对端路由器的Hostname,硬件设备类型,IOS版本,三层接口地址,发送CDP多播的地址

Router(config)# no service tcp-small-servers

Router(config)# no service udp-small-servers//关闭TCP和UDP的一些无用的小服务,这些小服务的端口小于19,通常用在以前的UNIX环境中,如chargen,daytime等

Router(config)# no service finger//finger通常用在UNIX中,用来确定谁登陆到设备上:telnet 192.168.1.254 finger

Router(config)# no ip finger//关闭对于finger查询的应答

Router(config)# no ip identd//关闭用户认证服务,一个设备发送一个请求到Ident接口(TCP 113), 目标会回答一个身份识别,如host名称或者设备名称

Router(config)# no ip source-route//关闭IP源路由,通过源路由,能够在IP包头中指定数据包实际要经过的路径

Router(config)# no ftp-server enable//关闭FTP服务

Router(config)# no ip http server//关闭HTTP路由器登陆服务

Router(config)# no ip http secure-server//关闭HTTPS路由器登陆服务

Router(config)# no snmp-server community public RO

Router(config)# no snmp-server community private RW

Router(config)# no snmp-server enable traps

Router(config)# no snmp-server system-shutdown

Router(config)# no snmp-server trap-auth

Router(config)# no snmp-server//关闭SNMP服务

Router(config)# no ip domain-lookup//关闭DNS域名查找

Router(config)# no ip bootp server//bootp服务通常用在无盘站中,为主机申请IP地址

Router(config)# no service dhcp//关闭DHCP服务

Router(config)# no service pad//pad服务一般用在X.25网络中为远端站点提供可靠连接

Router(config)# no boot network//关闭路由器通过TFTP加载IOS启动

Router(config)# no service config//关闭路由器加载IOS成功后通过TFTP加载配置文件

Router(config)# interface ethernet 0

Router(config -if)# no ip proxy-arp//关闭代理ARP服务

Router(config -if)# no ip directed-broadcast//关闭直连广播,因为直连广播是能够被路由的

Router(config -if)# no ip unreachable

Router(config -if)# no ip redirect

Router(config -if)# no ip mask-reply//关闭三种不可靠的ICMP消息

Router(config -if)# exit

注意:使用show ip interface查看接口启用的服务

Router(config)# interface ethernet 0

Router(config -if)# shutdown//手动关闭没有使用的接口

Router(config -if)# exit

Router(config)# service tcp-keepalives -in

Router(config)# service tcp-keepalives -out

//对活动的tcp连接进行监视,及时关闭已经空闲超时的tcp连接,通常和telnet,ssh一起使用

Router(config)# username admin1 privilege 15 secret geekboy

Router(config)# hostname jwy

Bullmastiff(config)# ip domain-name

Bullmastiff(config)# crypto key generate rsa

Bullmastiff(config)# line vty 0 4

Bullmastiff(config -line)# login local

Bullmastiff(config -line)# transport input ssh

Bullmastiff(config -line)# transport output ssh

//只允许其他设备通过SSH登陆到路由器

安全连接:用SSH替代Telnet

如果你一直利用Telnet控制网络设备,你可以考虑采用其他更安全的方式。本文告诉你如何用SSH替换Telnet。

使用Telnet这个用来访问远程计算机的TCP/IP协议以控制你的网络设备相当于在离开某个建筑时大喊你的用户名和口令。很快地,会有人进行监听,并且他们会利用你安全意识的缺乏。

SSH是替代Telnet和其他远程控制台管理应用程序的行业标准。SSH命令是加密的并以几种方式进行保密。

在使用SSH的时候,一个数字证书将认证客户端(你的工作站)和服务器(你的网络设备)之间的连接,并加密受保护的口令。SSH1使用RSA加密密钥,SSH2使用数字签名算法(DSA)密钥保护连接和认证。

加密算法包括Blowfish,数据加密标准(DES),以及三重DES(3DES)。SSH保护并且有助于防止欺骗,“中间人”攻击,以及数据包监听。

实施SSH的第一步是验证你的设备支持SSH。请登录你的路由器或交换机,并确定你是否加载了一个支持SSH的IPSec IOS镜像。

在我们的例子中,我们将使用Cisco IOS命令。运行下面的命令:

Router> Show flash

该命令显示已加载的IOS镜像名称。你可以用结果对比你的供应商的支持特性列表。

在你验证了你的设备支持SSH之后,请确保设备拥有一个主机名和配置正确的主机域,就像下面的一样:

Router> config terminal

Router (config)# hostname hostname

Router (config)# ip domain-name domainname

在这个时候,你就可以启用路由器上的SSH服务器。要启用SSH服务器,你首先必须利用下面的命令产生一对RSA密钥:

Router (config)# crypto key generate rsa

在路由器上产生一对RSA密钥就会自动启用SSH。如果你删除这对RSA密钥,就会自动禁用该SSH服务器。

实施SSH的最后一步是启用认证,授权和审计(AAA)。在你配置AAA的时候,请指定用户名和口令,会话超时时间,一个连接允许的尝试次数。像下面这样使用命令:

Router (config)# aaa new-model

Router (config)# username password

Router (config)# ip ssh time-out

Router (config)# ip ssh authentication-retries

要验证你已经配置了SSH并且它正运行在你的路由器上,执行下面的命令:

Router# show ip ssh

在验证了配置之后,你就可以强制那些你在AAA配置过程中添加的用户使用SSH,而不是Telnet。你也可以在虚拟终端(vty)连接中应用SSH而实现同样的目的。这里给出一个例子:

Router (config)# line vty 0 4

Router (config-line)# transport input SSH

ssh -l gcs 192.168.1.254

在你关闭现存的Telnet会话之前,你需要一个SSH终端客户端程序以测试你的配置。我极力推荐PuTTY;它是免费的,而且它是一个优秀的终端软件。

路由器配置:

Router>enable

Router#config t

Router(config)#host jintian

jintian(config)#enable password 123

jintian(config)#int fa0/0

jintian(config-if)#ip add 192.168.1.1 255.255.255.0

jintian(config-if)#no shut

jintian(config-if)#exit

jintian(config)username jintian password jintian

jintian(config)#ip domain-name

jintian(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 your

General Purpose Keys. Choosing a key modulus greater than 512 may take

a few minutes.

How many bits in the modulus [512]: 512

jintian(config)#line vty 0 4

jintian(config-line)#transport input ssh

jintian(config-line)#login local

jintian(config-line)#

测试:

在PC上:

Packet Tracer PC Command Line 1.0

PC>ping 192.168.1.1

Pinging 192.168.1.1 with 32 bytes of data: