|
作者: tuzi [tuzi] 版主 | 登录 |
Cisco路由器的安全配置简易方案 (1) 文章来源:安全焦点 作者: 发布时间:2003.05.22 10:10:37 一.路由器访问控制的安全配置 1.严格控制可以访问路由器的管理员。任何一次维护都需要记录备案。 2.建议不要远程访问路由器。即使需要远程访问路由器,建议使用访问控制列表和高强度的密码控制。 3.严格控制CON端口的访问。具体的措施有: A.如果可以开机箱的,则可以切断与CON口互联的物理线路。 B.可以改变默认的连接属性,例如修改波特率(默认是96000,可以改为其他的)。 C.配合使用访问控制列表控制对CON口的访问。 如:Router(Config)#Access-list 1 permit 192.168.0.1 Router(Config)#line con 0 Router(Config-line)#Transport input none Router(Config-line)#Login local Router(Config-line)#Exec-timeoute 5 0 Router(Config-line)#access-class 1 in Router(Config-line)#end D.给CON口设置高强度的密码。 4.如果不使用AUX端口,则禁止这个端口。默认是未被启用。禁止如: Router(Config)#line aux 0 Router(Config-line)#transport input none Router(Config-line)#no exec 5.建议采用权限分级策略。如: Router(Config)#username BluShin privilege 10 G00dPa55w0rd Router(Config)#privilege EXEC level 10 telnet Router(Config)#privilege EXEC level 10 show ip access-list /pre> 6.为特权模式的进入设置强壮的密码。不要采用enable password设置密码。而要采用enable secret命令设置。并且要启用Service password-encryption。 7.控制对VTY的访问。如果不需要远程访问则禁止它。如果需要则一定要设置强壮的密码。由于VTY在网络的传输过程中为加密,所以需要对其进行严格的控制。如:设置强壮的密码;控制连接的并发数目;采用访问列表严格控制访问的地址;可以采用AAA设置用户的访问控制等。 8.IOS的升级和备份,以及配置文件的备份建议使用FTP代替TFTP。如: Router(Config)#ip ftp username BluShin Router(Config)#ip ftp password 4tppa55w0rd Router#copy startup-config ftp: /pre> 9.及时的升级和修补IOS软件。 二.路由器网络服务安全配置 1.禁止CDP(Cisco Discovery Protocol)。如: Router(Config)#no cdp run Router(Config-if)# no cdp enable /pre> 2.禁止其他的TCP、UDP Small服务。 Router(Config)# no service tcp-small-servers Router(Config)# no service udp-samll-servers /pre> 3.禁止Finger服务。 Router(Config)# no ip finger Router(Config)# no service finger /pre> 4.建议禁止HTTP服务。 Router(Config)# no ip http server 如果启用了HTTP服务则需要对其进行安全配置:设置用户名和密码;采用访问列表进行控制。如: Router(Config)# username BluShin privilege 10 G00dPa55w0rd Router(Config)# ip http auth local Router(Config)# no access-list 10 Router(Config)# access-list 10 permit 192.168.0.1 Router(Config)# access-list 10 deny any Router(Config)# ip http access-class 10 Router(Config)# ip http server Router(Config)# exit /pre> 5.禁止BOOTp服务。 Router(Config)# no ip bootp server 禁止从网络启动和自动从网络下载初始配置文件。 Router(Config)# no boot network Router(Config)# no servic config 6.禁止IP Source Routing。 Router(Config)# no ip source-route 7.建议如果不需要ARP-Proxy服务则禁止它,路由器默认识开启的。 Router(Config)# no ip proxy-arp Router(Config-if)# no ip proxy-arp 8.明确的禁止IP Directed Broadcast。 Router(Config)# no ip directed-broadcast 9.禁止IP Classless。 Router(Config)# no ip classless 10.禁止ICMP协议的IP Unreachables,Redirects,Mask Replies。 Router(Config-if)# no ip unreacheables Router(Config-if)# no ip redirects Router(Config-if)# no ip mask-reply 11.建议禁止SNMP协议服务。在禁止时必须删除一些SNMP服务的默认配置。或者需要访问列表来过滤。如: Router(Config)# no snmp-server community public Ro Router(Config)# no snmp-server community admin RW Router(Config)# no access-list 70 Router(Config)# access-list 70 deny any Router(Config)# snmp-server community MoreHardPublic Ro 70 Router(Config)# no snmp-server enable traps Router(Config)# no snmp-server system-shutdown Router(Config)# no snmp-server trap-anth Router(Config)# no snmp-server Router(Config)# end 12.如果没必要则禁止WINS和DNS服务。 Router(Config)# no ip domain-lookup 如果需要则需要配置: Router(Config)# hostname Router Router(Config)# ip name-server 202.102.134.96 13.明确禁止不使用的端口。 Router(Config)# interface eth0/3 Router(Config)# shutdown 三.路由器路由协议安全配置 1.首先禁止默认启用的ARP-Proxy,它容易引起路由表的混乱。 Router(Config)# no ip proxy-arp 或者 Router(Config-if)# no ip proxy-arp 2.启用OSPF路由协议的认证。默认的OSPF认证密码是明文传输的,建议启用MD5认证。并设置一定强度密钥(key,相对的路由器必须有相同的Key)。 Router(Config)# router ospf 100 Router(Config-router)# network 192.168.100.0 0.0.0.255 area 100 ! 启用MD5认证。 ! area area-id authentication 启用认证,是明文密码认证。 !area area-id authentication message-digest Router(Config-router)# area 100 authentication message-digest Router(Config)# exit Router(Config)# interface eth0/1 !启用MD5密钥Key为routerospfkey。 !ip ospf authentication-key key 启用认证密钥,但会是明文传输。 !ip ospf message-digest-key key-id(1-255) md5 key Router(Config-if)# ip ospf message-digest-key 1 md5 routerospfkey 3.RIP协议的认证。只有RIP-V2支持,RIP-1不支持。建议启用RIP-V2。并且采用MD5认证。普通认证同样是明文传输的。 Router(Config)# config terminal ! 启用设置密钥链 Router(Config)# key chain mykeychainname Router(Config-keychain)# key 1 !设置密钥字串 Router(Config-leychain-key)# key-string MyFirstKeyString Router(Config-keyschain)# key 2 Router(Config-keychain-key)# key-string MySecondKeyString !启用RIP-V2 Router(Config)# router rip Router(Config-router)# version 2 Router(Config-router)# network 192.168.100.0 Router(Config)# interface eth0/1 ! 采用MD5模式认证,并选择已配置的密钥链 Router(Config-if)# ip rip authentication mode md5 Router(Config-if)# ip rip anthentication key-chain mykeychainname 4.启用passive-interface命令可以禁用一些不需要接收和转发路由信息的端口。建议对于不需要路由的端口,启用passive-interface。但是,在RIP协议是只是禁止转发路由信息,并没有禁止接收。在OSPF协议中是禁止转发和接收路由信息。 ! Rip中,禁止端口0/3转发路由信息 Router(Config)# router Rip Router(Config-router)# passive-interface eth0/3 !OSPF中,禁止端口0/3接收和转发路由信息 Router(Config)# router ospf 100 Router(Config-router)# passive-interface eth0/3 5.启用访问列表过滤一些垃圾和恶意路由信息,控制网络的垃圾信息流。 Router(Config)# access-list 10 deny 192.168.1.0 0.0.0.255 Router(Config)# access-list 10 permit any ! 禁止路由器接收更新192.168.1.0网络的路由信息 Router(Config)# router ospf 100 Router(Config-router)# distribute-list 10 in !禁止路由器转发传播192.168.1.0网络的路由信息 Router(Config)# router ospf 100 Router(Config-router)# distribute-list 10 out 6.建议启用IP Unicast Reverse-Path Verification。它能够检查源IP地址的准确性,从而可以防止一定的IP Spooling。但是它只能在启用CEF(Cisco Express Forwarding)的路由器上使用。 Router# config t ! 启用CEF Router(Config)# ip cef !启用Unicast Reverse-Path Verification Router(Config)# interface eth0/1 Router(Config)# ip verify unicast reverse-path 四.路由器其他安全配置 1.及时的升级IOS软件,并且要迅速的为IOS安装补丁。 2.要严格认真的为IOS作安全备份。 3.要为路由器的配置文件作安全备份。 4.购买UPS设备,或者至少要有冗余电源。 5.要有完备的路由器的安全访问和维护记录日志。 6.要严格设置登录Banner。必须包含非授权用户禁止登录的字样。 7.IP欺骗得简单防护。如过滤非公有地址访问内部网络。过滤自己内部网络地址;回环地址(127.0.0.0/8);RFC1918私有地址;DHCP自定义地址(169.254.0.0/16);科学文档作者测试用地址(192.0.2.0/24);不用的组播地址(224.0.0.0/4);SUN公司的古老的测试地址(20.20.20.0/24;204.152.64.0/23);全网络地址(0.0.0.0/8)。 Router(Config)# access-list 100 deny ip 192.168.0.0 0.0.0.255 any log Router(Config)# access-list 100 deny ip 127.0.0.0 0.255.255.255 any log Router(Config)# access-list 100 deny ip 192.168.0.0 0.0.255.255 any log Router(Config)# access-list 100 deny ip 172.16.0.0 0.15.255.255 any log Router(Config)# access-list 100 deny ip 10.0.0.0 0.255.255.255 any log Router(Config)# access-list 100 deny ip 169.254.0.0 0.0.255.255 any log Router(Config)# access-list 100 deny ip 192.0.2.0 0.0.0.255 any log Router(Config)# access-list 100 deny ip 224.0.0.0 15.255.255.255 any Router(Config)# access-list 100 deny ip 20.20.20.0 0.0.0.255 any log Router(Config)# access-list 100 deny ip 204.152.64.0 0.0.2.255 any log Router(Config)# access-list 100 deny ip 0.0.0.0 0.255.255.255 any log 8.建议采用访问列表控制流出内部网络的地址必须是属于内部网络的。如: Router(Config)# no access-list 101 Router(Config)# access-list 101 permit ip 192.168.0.0 0.0.0.255 any Router(Config)# access-list 101 deny ip any any log Router(Config)# interface eth 0/1 Router(Config-if)# description “internet Ethernet” Router(Config-if)# ip address 192.168.0.254 255.255.255.0 Router(Config-if)# ip access-group 101 in 9.TCP SYN的防范。如: A: 通过访问列表防范。 Router(Config)# no access-list 106 Router(Config)# access-list 106 permit tcp any 192.168.0.0 0.0.0.255 established Router(Config)# access-list 106 deny ip any any log Router(Config)# interface eth 0/2 Router(Config-if)# description “external Ethernet” Router(Config-if)# ip address 192.168.1.254 255.255.255.0 Router(Config-if)# ip access-group 106 in B:通过TCP截获防范。(这会给路由器产生一定负载) Router(Config)# ip tcp intercept list 107 Router(Config)# access-list 107 permit tcp any 192.168.0.0 0.0.0.255 Router(Config)# access-list 107 deny ip any any log Router(Config)# interface eth0 Router(Config)# ip access-group 107 in 10.LAND.C 进攻的防范。 Router(Config)# access-list 107 deny ip host 192.168.1.254 host 192.168.1.254 log Router(Config)# access-list permit ip any any Router(Config)# interface eth 0/2 Router(Config-if)# ip address 192.168.1.254 255.255.255.0 Router(Config-if)# ip access-group 107 in 11.Smurf进攻的防范。 Router(Config)# access-list 108 deny ip any host 192.168.1.255 log Router(Config)# access-list 108 deny ip any host 192.168.1.0 log 12.ICMP协议的安全配置。对于进入ICMP流,我们要禁止ICMP协议的ECHO、Redirect、Mask request。也需要禁止TraceRoute命令的探测。对于流出的ICMP流,我们可以允许ECHO、Parameter Problem、Packet too big。还有TraceRoute命令的使用。 ! outbound ICMP Control Router(Config)# access-list 110 deny icmp any any echo log Router(Config)# access-list 110 deny icmp any any redirect log Router(Config)# access-list 110 deny icmp any any mask-request log Router(Config)# access-list 110 permit icmp any any ! Inbound ICMP Control Router(Config)# access-list 111 permit icmp any any echo Router(Config)# access-list 111 permit icmp any any Parameter-problem Router(Config)# access-list 111 permit icmp any any packet-too-big Router(Config)# access-list 111 permit icmp any any source-quench Router(Config)# access-list 111 deny icmp any any log ! Outbound TraceRoute Control Router(Config)# access-list 112 deny udp any any range 33400 34400 ! Inbound TraceRoute Control Router(Config)# access-list 112 permit udp any any range 33400 34400 13.DDoS(Distributed Denial of Service)的防范。 ! The TRINOO DDoS system Router(Config)# access-list 113 deny tcp any any eq 27665 log Router(Config)# access-list 113 deny udp any any eq 31335 log Router(Config)# access-list 113 deny udp any any eq 27444 log ! The Stacheldtraht DDoS system Router(Config)# access-list 113 deny tcp any any eq 16660 log Router(Config)# access-list 113 deny tcp any any eq 65000 log ! The TrinityV3 System Router(Config)# access-list 113 deny tcp any any eq 33270 log Router(Config)# access-list 113 deny tcp any any eq 39168 log ! The SubSeven DDoS system and some Variants Router(Config)# access-list 113 deny tcp any any range 6711 6712 log Router(Config)# access-list 113 deny tcp any any eq 6776 log Router(Config)# access-list 113 deny tcp any any eq 6669 log Router(Config)# access-list 113 deny tcp any any eq 2222 log Router(Config)# access-list 113 deny tcp any any eq 7000 log 14.建议启用SSH,废弃掉Telnet。但只有支持并带有IPSec特征集的IOS才支持SSH。并且IOS12.0-IOS12.2仅支持SSH-V1。如下配置SSH服务的例子: Router(Config)# config t Router(Config)# no access-list 22 Router(Config)# access-list 22 permit 192.168.0.22 Router(Config)# access-list deny any Router(Config)# username BluShin privilege 10 G00dPa55w0rd ! 设置SSH的超时间隔和尝试登录次数 Router(Config)# ip ssh timeout 90 Router(Config)# ip ssh anthentication-retries 2 Router(Config)# line vty 0 4 Router(Config-line)# access-class 22 in Router(Config-line)# transport input ssh Router(Config-line)# login local Router(Config-line)# exit !启用SSH服务,生成RSA密钥对。 Router(Config)# crypto key generate rsa The name for the keys will be: router.blushin.org 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]: 2048 Generating RSA Keys... [OK] Router(Config)# 需要关闭的接口服务 某些IP特性对于校园局域网来说是很好的,但并不意味着对ISP骨干网适用。如果这些功能被网络黑朋客滥用的话,会增加ISP的危险。所有在ISP骨干路由器上的接口都应该将以下几点作为默认值: no ip redirects no ip directed-broadcast no ip proxy-arp “no ip redirects”表示:如果IOS被强迫通过相同的接口重新发送一个包的话,路由器就不会发送重定向(redirect) 信息。 “no ip directed-broadcast”表示:定向广播到物理广播的转换被禁止。如果这一项使能的话,到某个网络的广播可能在路由接口上被定向,同时可能产生非期望和潜在的危害。由于定向广播使能而导致负作用的一个例子,是一种叫做“SMURF”的网络攻击。关于这种SMURF更详细的资料,请到Craig Heugen的SMURF网站参阅:http://www.quadrunner.com/chuegen/smurf.txt “no ip proxy-arp”表示:即使路由器知道某个主机的MAC地址,它也不会响应网络中连接到这个接口的其他主机的ARP请求。这点同样也可以预防一些潜在的安全问题。 no ip domain-lookup //关闭域名查询 no cdp run //禁用cdp no ip http server //禁用http server,这玩意儿的安全漏洞很多的 no ip source-route //禁用IP源路由,防止路由欺骗 no service finger //禁用finger服务 no ip bootp server //禁用bootpe服务 no service udp-small-s //禁用一堆小的udp服务 no service tcp-small-s //禁用一堆小的tcp服务 ! service timestamp log datetime localtime //配置时间戳为datetime方式,使用本地时间 logging 192.168.0.1 //向192.168.0.1发送log logging 192.168.0.2 //向192.168.0.2发送log snmp-server community HSDxdf ro 98//配置snmp只读通讯字,并只允许access-list 98的主机进行通讯 service password-encryption //启用加密服务,将对password密码进行加密 enable secret asdfajkls //配置强加密的特权密码 no enable password //禁用弱加密的特权密码 no access-list 99 //在配置一个新的acl前先清空该ACL access-list 99 permit 192.168.0.0 0.0.0.255 access-list 99 deny any log //log参数说明在有符合该条件的条目时产生一条logo信息 no access-list 98 //在配置一个新的acl前先清空该ACL access-list 98 permit host 192.168.0.1 access-list 98 deny any log //log参数说明在有符合该条件的条目时产生一条logo信息 ! line vty 0 4 access-class 99 in //使用acl 99来控制telnet的源地址 login password 0 asdfaksdlf //配置telnet密码 exec-timeout 2 0 //配置虚终羰超时参数,这里是2分钟 ! line con 0 login password 0 adsfoii //配置console口的密码 exec-timeout 2 0 //配置console口超时参数,这里是两分钟 ! line aux 0 transport input none password 0 asfdkalsfj no exec exit banner motd # //配置提示信息 This is a private system operated for UltraTeam. Authorization from UltraTeam is required to use this system Use by unauthorized persons is prohibited # ! clock timezone PST-8 //设置时区 ntp authenticate //启用NTP认证 ntp authentication-key 1 md5 uadsf //设置NTP认证用的密码,使用MD5加密。需要和ntp server一致 ntp trusted-key 1 //可以信任的Key. ntp acess-group peer 98 //设置ntp服务,只允许对端为符合access-list 98条件的主机 ntp server 192.168.0.1 key 1 //配置ntp server,server为192.168.0.1,使用1号key做为密码 ! interface vlan 10 ip address 10.1.10.254 255.255.255.0 ip ospf authentication message-digest //启用ospf邻接过程中的认证 ip ospf message-digest-key md5 7 24d10564152140a7e //配置ospf认证key,要求所有邻居相同 ip ospf priority 3 //提高ospf的优先级,便于成为DR set cdp disable //禁用cdp set ip http disable //禁用http server,这玩意儿的安全漏洞很多的 ! set logging timestamp enable //启用log时间戳 set logging server 192.168.0.1 //向192.168.0.1发送log set logging server 192.168.0.2 //向192.168.0.2发送log set snmp community HSDxdf //配置snmp只读通讯字 set ip permit enable snmp //启用snmp访问控制 set ip permit 192.168.0.1 snmp //允许192.168.0.1进行snmp访问 set ip permit enable telnet //启用telnet访问控制 set ip permit 192.168.0.1 telnet //允许192.168.0.1进行telnet访问 set password //配置telnet密码 set enable //配置特权密码 set logout 2 //配置超时参数,2分钟 set banner motd //配置提示信息 This is a private system operated for UltraTeam. Authorization from UltraTeam is required to use this system Use by unauthorized persons is prohibited ! set timezone PST-8 //设置时区 set ntp authenticate enable //启用NTP认证 set ntp key 1 md5 uadsf //设置NTP认证用的密码,使用MD5加密。需要和ntp server一致 set ntp server 192.168.0.1 key 1 //配置ntp server,server为192.168.0.1,使用1号key做为密码 set ntp client enable //启用ntp client |
地主 发表时间: 12/16 06:33 |
|
20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon
粤ICP备05087286号