1、【安全】 Cisco 路由器的安全配置方案- 原创作者:BluShin2003-7-18Cisco 路由器的安全配置方案Author: BluShinAuditor: AmyE-mail:YVersion 1.0Date: 2002-12-15一,路由器访问控制的安全配置1,严格控制可以访问路由器的管理员。任何一次维护都需要记录备案。2,建议不要远程访问路由器。即使需要远程访问路由器,建议使用访问控制列表和高强度的密码控制。3,严格控制 CON 端口的访问。具体的措施有:A,如果可以开机箱的,则可以切断与 CON 口互联的物理线路。B,可以改变默认的连接属性,例如修改波特率( 默认是 9600
2、0,可以改为其他的)。C,配合使用访问控制列表控制对 CON 口的访问。如:Router(Config)#Access-list 1 permit 192.168.0.1Router(Config)#line con 0Router(Config-line)#Transport input noneRouter(Config-line)#Login localRouter(Config-line)#Exec-timeoute 5 0Router(Config-line)#access-class 1 inRouter(Config-line)#endD,给 CON 口设置高强度的密码。4,如果
3、不使用 AUX 端口,则禁止这个端口。默认是未被启用。禁止如:Router(Config)#line aux 0Router(Config-line)#transport input noneRouter(Config-line)#no exec5,建议采用权限分级策略。如:Router(Config)#username BluShin privilege 10 G00dPa55w0rdRouter(Config)#privilege EXEC level 10 telnetRouter(Config)#privilege EXEC level 10 show ip access-list6,
4、为特权模式的进入设置强壮的密码。不要采用 enable password 设置密码。而要采用enable secret 命令设置。并且要启用 Service password-encryption。7,控制对 VTY 的访问。如果不需要远程访问则禁止它。如果需要则一定要设置强壮的密码。由于 VTY 在网络的传输过程中为加密,所以需要对其进行严格的控制。如:设置强壮的密码;控制连接的并发数目;采用访问列表严格控制访问的地址;可以采用 AAA 设置用户的访问控制等。8,IOS 的升级和备份,以及配置文件的备份建议使用 FTP 代替 TFTP。如:Router(Config)#ip ftp user
5、name BluShinRouter(Config)#ip ftp password 4tppa55w0rdRouter#copy startup-config ftp:9,及时的升级和修补 IOS 软件。二,路由器网络服务安全配置1,禁止 CDP(Cisco Discovery Protocol)。如:Router(Config)#no cdp runRouter(Config-if)# no cdp enable2,禁止其他的 TCP、UDP Small 服务。Router(Config)# no service tcp-small-serversRouter(Config)# no se
6、rvice udp-samll-servers3,禁止 Finger 服务。Router(Config)# no ip fingerRouter(Config)# no service finger4,建议禁止 HTTP 服务。Router(Config)# no ip http server如果启用了 HTTP 服务则需要对其进行安全配置:设置用户名和密码;采用访问列表进行控制。如:Router(Config)# username BluShin privilege 10 G00dPa55w0rdRouter(Config)# ip http auth localRouter(Config)
7、# no access-list 10Router(Config)# access-list 10 permit 192.168.0.1Router(Config)# access-list 10 deny anyRouter(Config)# ip http access-class 10Router(Config)# ip http serverRouter(Config)# exit5,禁止 BOOTp 服务。Router(Config)# no ip bootp server禁止从网络启动和自动从网络下载初始配置文件。Router(Config)# no boot networkRou
8、ter(Config)# no servic config6,禁止 IP Source Routing。Router(Config)# no ip source-route7,建议如果不需要 ARP-Proxy 服务则禁止它,路由器默认识开启的。Router(Config)# no ip proxy-arpRouter(Config-if)# no ip proxy-arp8,明确的禁止 IP Directed Broadcast。Router(Config)# no ip directed-broadcast9,禁止 IP Classless。Router(Config)# no ip cl
9、assless10,禁止 ICMP 协议的 IP Unreachables,Redirects,Mask Replies。Router(Config-if)# no ip unreacheablesRouter(Config-if)# no ip redirectsRouter(Config-if)# no ip mask-reply11,建议禁止 SNMP 协议服务。在禁止时必须删除一些 SNMP 服务的默认配置。或者需要访问列表来过滤。如:Router(Config)# no snmp-server communitypublic RoRouter(Config)# no snmp-ser
10、ver community admin RWRouter(Config)# no access-list 70Router(Config)# access-list 70 deny anyRouter(Config)# snmp-server community MoreHardPublic Ro 70Router(Config)# no snmp-server enable trapsRouter(Config)# no snmp-server system-shutdownRouter(Config)# no snmp-server trap-anthRouter(Config)# no
11、snmp-serverRouter(Config)# end12,如果没必要则禁止 WINS 和 DNS 服务。Router(Config)# no ip domain-lookup如果需要则需要配置:Router(Config)# hostname RouterRouter(Config)# ip name-server 202.102.134.9613,明确禁止不使用的端口。Router(Config)# interface eth0/3Router(Config)# shutdown 三,路由器路由协议安全配置1,首先禁止默认启用的 ARP-Proxy,它容易引起路由表的混乱。Route
12、r(Config)# no ip proxy-arp 或者Router(Config-if)# no ip proxy-arp2,启用 OSPF 路由协议的认证。默认的 OSPF 认证密码是明文传输的,建议启用 MD5 认证。并设置一定强度密钥(key,相对的路由器必须有相同的 Key)。Router(Config)# router ospf 100Router(Config-router)# network 192.168.100.0 0.0.0.255 area 100! 启用 MD5 认证。! area area-id authentication 启用认证,是明文密码认证。!area
13、area-id authentication message-digestRouter(Config-router)# area 100 authentication message-digestRouter(Config)# exitRouter(Config)# interface eth0/1!启用 MD5 密钥 Key 为 routerospfkey。!ip ospf authentication-key key 启用认证密钥,但会是明文传输。!ip ospf message-digest-key key-id(1-255) md5 keyRouter(Config-if)# ip o
14、spf message-digest-key 1 md5 routerospfkey3,RIP 协议的认证。只有 RIP-V2 支持,RIP-1 不支持。建议启用 RIP-V2。并且采用 MD5认证。普通认证同样是明文传输的。Router(Config)# config terminal! 启用设置密钥链Router(Config)# key chain mykeychainnameRouter(Config-keychain)# key 1!设置密钥字串Router(Config-leychain-key)# key-string MyFirstKeyStringRouter(Config-
15、keyschain)# key 2Router(Config-keychain-key)# key-string MySecondKeyString!启用 RIP-V2Router(Config)# router ripRouter(Config-router)# version 2Router(Config-router)# network 192.168.100.0Router(Config)# interface eth0/1! 采用 MD5 模式认证,并选择已配置的密钥链Router(Config-if)# ip rip authentication mode md5Router(Co
16、nfig-if)# ip rip anthentication key-chain mykeychainname4,启用 passive-interface 命令可以禁用一些不需要接收和转发路由信息的端口。建议对于不需要路由的端口,启用 passive-interface。但是,在 RIP 协议是只是禁止转发路由信息,并没有禁止接收。在 OSPF 协议中是禁止转发和接收路由信息。! Rip 中,禁止端口 0/3 转发路由信息Router(Config)# router RipRouter(Config-router)# passive-interface eth0/3!OSPF 中,禁止端口
17、0/3 接收和转发路由信息Router(Config)# router ospf 100Router(Config-router)# passive-interface eth0/35,启用访问列表过滤一些垃圾和恶意路由信息,控制网络的垃圾信息流。Router(Config)# access-list 10 deny 192.168.1.0 0.0.0.255Router(Config)# access-list 10 permit any! 禁止路由器接收更新 192.168.1.0 网络的路由信息Router(Config)# router ospf 100Router(Config-ro
18、uter)# distribute-list 10 in!禁止路由器转发传播 192.168.1.0 网络的路由信息Router(Config)# router ospf 100Router(Config-router)# distribute-list 10 out6,建议启用 IP Unicast Reverse-Path Verification。它能够检查源 IP 地址的准确性,从而可以防止一定的 IP Spooling。但是它只能在启用 CEF(Cisco Express Forwarding)的路由器上使用。Router# config t! 启用 CEFRouter(Config
19、)# ip cef!启用 Unicast Reverse-Path VerificationRouter(Config)# interface eth0/1Router(Config)# ip verify unicast reverse-path四,路由器审核安全配置 五,路由器其他安全配置1,及时的升级 IOS 软件,并且要迅速的为 IOS 安装补丁。2,要严格认真的为 IOS 作安全备份。3,要为路由器的配置文件作安全备份。4,购买 UPS 设备,或者至少要有冗余电源。5,要有完备的路由器的安全访问和维护记录日志。6,要严格设置登录 Banner。必须包含非授权用户禁止登录的字样。7,I
20、P 欺骗得简单防护。如过滤非公有地址访问内部网络。过滤自己内部网络地址;回环地址(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 logRouter(Config)# access-lis
21、t 100 deny ip 127.0.0.0 0.255.255.255 any logRouter(Config)# access-list 100 deny ip 192.168.0.0 0.0.255.255 any logRouter(Config)# access-list 100 deny ip 172.16.0.0 0.15.255.255 any logRouter(Config)# access-list 100 deny ip 10.0.0.0 0.255.255.255 any logRouter(Config)# access-list 100 deny ip 169
22、.254.0.0 0.0.255.255 any logRouter(Config)# access-list 100 deny ip 192.0.2.0 0.0.0.255 any logRouter(Config)# access-list 100 deny ip 224.0.0.0 15.255.255.255 anyRouter(Config)# access-list 100 deny ip 20.20.20.0 0.0.0.255 any logRouter(Config)# access-list 100 deny ip 204.152.64.0 0.0.2.255 any lo
23、gRouter(Config)# access-list 100 deny ip 0.0.0.0 0.255.255.255 any log8,建议采用访问列表控制流出内部网络的地址必须是属于内部网络的。如:Router(Config)# no access-list 101Router(Config)# access-list 101 permit ip 192.168.0.0 0.0.0.255 anyRouter(Config)# access-list 101 deny ip any any logRouter(Config)# interface eth 0/1Router(Conf
24、ig-if)# description “internet Ethernet”Router(Config-if)# ip address 192.168.0.254 255.255.255.0Router(Config-if)# ip access-group 101 in9,TCP SYN 的防范。如:A: 通过访问列表防范。Router(Config)# no access-list 106Router(Config)# access-list 106 permit tcp any 192.168.0.0 0.0.0.255 establishedRouter(Config)# acces
25、s-list 106 deny ip any any logRouter(Config)# interface eth 0/2Router(Config-if)# description “external Ethernet”Router(Config-if)# ip address 192.168.1.254 255.255.255.0Router(Config-if)# ip access-group 106 inB:通过 TCP 截获防范。(这会给路由器产生一定负载 )Router(Config)# ip tcp intercept list 107Router(Config)# acc
26、ess-list 107 permit tcp any 192.168.0.0 0.0.0.255Router(Config)# access-list 107 deny ip any any logRouter(Config)# interface eth0Router(Config)# ip access-group 107 in10,LAND.C 进攻的防范。Router(Config)# access-list 107 deny ip host 192.168.1.254 host 192.168.1.254 logRouter(Config)# access-list permit
27、ip any anyRouter(Config)# interface eth 0/2Router(Config-if)# ip address 192.168.1.254 255.255.255.0Router(Config-if)# ip access-group 107 in11,Smurf 进攻的防范。Router(Config)# access-list 108 deny ip any host 192.168.1.255 logRouter(Config)# access-list 108 deny ip any host 192.168.1.0 log12,ICMP 协议的安全配
28、置。对于进入 ICMP 流,我们要禁止 ICMP 协议的ECHO、Redirect、Mask request。也需要禁止 TraceRoute 命令的探测。对于流出的 ICMP流,我们可以允许 ECHO、Parameter Problem、Packettoo big。还有 TraceRoute 命令的使用。! outbound ICMP ControlRouter(Config)# access-list 110 deny icmp any any echo logRouter(Config)# access-list 110 deny icmp any any redirect logRou
29、ter(Config)# access-list 110 deny icmp any any mask-request logRouter(Config)# access-list 110 permit icmp any any! Inbound ICMP ControlRouter(Config)# access-list 111 permit icmp any any echoRouter(Config)# access-list 111 permit icmp any any Parameter-problemRouter(Config)# access-list 111 permit
30、icmp any any packet-too-bigRouter(Config)# access-list 111 permit icmp any any source-quenchRouter(Config)# access-list 111 deny icmp any any log! Outbound TraceRoute ControlRouter(Config)# access-list 112 deny udp any any range 33400 34400! Inbound TraceRoute ControlRouter(Config)# access-list 112
31、permit udp any any range 33400 3440013,DDoS(Distributed Denial of Service)的防范。! The TRINOO DDoS systemRouter(Config)# access-list 113 deny tcp any any eq 27665 logRouter(Config)# access-list 113 deny udp any any eq 31335 logRouter(Config)# access-list 113 deny udp any any eq 27444 log! The Stacheldt
32、raht DDoS systemRouter(Config)# access-list 113 deny tcp any any eq 16660 logRouter(Config)# access-list 113 deny tcp any any eq 65000 log! The TrinityV3 SystemRouter(Config)# access-list 113 deny tcp any any eq 33270 logRouter(Config)# access-list 113 deny tcp any any eq 39168 log! The SubSeven DDo
33、S system and some VariantsRouter(Config)# access-list 113 deny tcp any any range 6711 6712 logRouter(Config)# access-list 113 deny tcp any any eq 6776 logRouter(Config)# access-list 113 deny tcp any any eq 6669 logRouter(Config)# access-list 113 deny tcp any any eq 2222 logRouter(Config)# access-lis
34、t 113 deny tcp any any eq 7000 log13,建议启用 SSH,废弃掉 Telnet。但只有支持并带有 IPSec 特征集的 IOS 才支持 SSH。并且 IOS12.0-IOS12.2 仅支持 SSH-V1。如下配置 SSH 服务的例子:Router(Config)# config tRouter(Config)# no access-list 22Router(Config)# access-list 22 permit 192.168.0.22Router(Config)# access-list deny anyRouter(Config)# usernam
35、e BluShin privilege 10 G00dPa55w0rd! 设置 SSH 的超时间隔和尝试登录次数Router(Config)# ip ssh timeout 90Router(Config)# ip ssh anthentication-retries 2Router(Config)# line vty 0 4Router(Config-line)# access-class 22 inRouter(Config-line)# transport input sshRouter(Config-line)# login localRouter(Config-line)# exit
36、!启用 SSH 服务,生成 RSA 密钥对。Router(Config)# crypto key generate rsaThe name for the keys will be: router.blushin.orgChoose 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 modulus512: 2048Generating RSA Keys.OKRouter(Config)#六,路由器高级安全配置附:路由器安全配置模板