cisco交换机安全配置设定命令详解.docx
《cisco交换机安全配置设定命令详解.docx》由会员分享,可在线阅读,更多相关《cisco交换机安全配置设定命令详解.docx(11页珍藏版)》请在冰豆网上搜索。
cisco交换机安全配置设定命令详解
cisco交换机安全配置设定命令详解
一、交换机访问控制安全配置
1、对交换机特权模式设置密码尽量采用加密和md5hash方式
switch(config)#enablesecret5pass_string
其中0SpecifiesanUNENCRYPTEDpasswordwillfollow
5SpecifiesanENCRYPTEDsecretwillfollow
建议不要采用enablepasswordpass_sting密码,破解及其容易!
2、设置对交换机明文密码自动进行加密隐藏
switch(config)#servicepassword-encryption
3、为提高交换机管理的灵活性,建议权限分级管理并建立多用户
switch(config)#enablesecretlevel75pass_string7/7级用户进入特权模式的密码
switch(config)#enablesecret5pass_string15/15级用户进入特权模式的密码
switch(config)#usernameuserAprivilege7secret5pass_userA
switch(config)#usernameuserBprivilege15secret5pass_userB
/为7级,15级用户设置用户名和密码,Ciscoprivilegelevel分为0-15级,级别越高权限越大
switch(config)#privilegeexeclevel7commands
/为7级用户设置可执行的命令,其中commands可以根据分配给用户的权限自行定义
4、本地console口访问安全配置
switch(config)#lineconsole0
switch(config-line)#exec-timeout50/设置不执行命令操作的超时时间,单位为分钟和秒
switch(config-line)#loggingsynchronous
/强制对弹出的干扰日志信息进行回车换行,使用户输入的命令连续可见
设置登录console口进行密码验证
方式
(1):
本地认证
switch(config-line)#password7pass_sting/设置加密密码
switch(config-line)#login/启用登录验证
方式
(2):
本地AAA认证
switch(config)#aaanew-model/启用AAA认证
switch(config)#aaaauthenticationloginconsole-ingroupacsserverlocal
enable
/设置认证列表console-in优先依次为ACSServer,local用户名和密码,enable特权密码
switch(config)#lineconsole0
switch(config-line)#loginauthenticationconsole-in
/调用authentication设置的console-in列表
5、远程vty访问控制安全配置
switch(config)#access-list18permithostx.x.x.x
/设置标准访问控制列表定义可远程访问的PC主机
switch(config)#aaaauthenticationloginvty-ingroupacsserverlocal
enable
/设置认证列表vty-in,优先依次为ACSServer,local用户名和密码,enable特权密码
switch(config)#aaaauthorizationcommands7vty-ingroupacsserverlocal
if-authenticated
/为7级用户定义vty-in授权列表,优先依次为ACSServer,local授权
switch(config)#aaaauthorizationcommands15vty-ingroupacsserverlocal
if-authenticated
/为15级用户定义vty-in授权列表,优先依次为ACSServer,local授权
switch(config)#linevty015
switch(config-line)#access-class18in/在线路模式下调用前面定义的标准ACL18
switch(config-line)#exec-timeout50/设置不执行命令操作的超时时间,单位为分钟和秒
switch(config-line)#authorizationcommands7vty-in/调用设置的授权列表vty-in
switch(config-line)#authorizationcommands15vty-in
switch(config-line)#loggingsynchronous
/强制对弹出的干扰日志信息进行回车换行,使用户输入的命令连续可见
switch(config-line)#loginauthenticationvty-in
/调用authentication设置的vty-in列表
switch(config-line)#transportinputssh
/有Telnet协议不安全,仅允许通过ssh协议进行远程登录管理
6、AAA安全配置
switch(config)#aaagroupservertacacs+acsserver/设置AAA服务器组名
switch(config-sg-tacacs+)#serverx.x.x.x/设置AAA服务器组成员服务器ip
switch(config-sg-tacacs+)#serverx.x.x.x
switch(config-sg-tacacs+)#exit
switch(config)#tacacs-serverkeypaa_string/设置同tacacs-server服务器通信的密钥
二、交换机网络服务安全配置
禁用不需要的各种服务协议
switch(config)#noservicepad
switch(config)#noservicefinger
switch(config)#noservicetcp-small-servers
switch(config)#noserviceudp-small-servers
switch(config)#noserviceconfig
switch(config)#noserviceftp
switch(config)#noiphttpserver
switch(config)#noiphttpsecure-server
/关闭http,https远程web管理服务,默认cisco交换机是启用的
三、交换机防攻击安全加固配置
MACFlooding(泛洪)和Spoofing(欺骗)攻击
预防方法:
有效配置交换机port-security
STP攻击
预防方法:
有效配置rootguard,bpduguard,bpdufilter
VLAN,DTP攻击
预防方法:
设置专用的nativevlan;不要的接口shut或将端口模式改为access
DHCP攻击
预防方法:
设置dhcpsnooping
ARP攻击
预防方法:
在启用dhcpsnooping功能下配置DAI和port-security在级联上层交换机的trunk下
switch(config)#intgix/x/x
switch(config-if)#swmodetrunk
switch(config-if)#swtrunkencapsdot1q
switch(config-if)#swtrunkallowedvlanx-x
switch(config-if)#spanning-treeguardloop
/启用环路保护功能,启用loopguard时自动关闭rootguard
接终端用户的端口上设定
switch(config)#intgix/x/x
switch(config-if)#spanning-treeportfast
/在STP中交换机端口有5个状态:
disable、blocking、listening、learning、forwarding,只有处于forwarding状态的端口才可以发送数据。
但需经过从blocking-->listening
15s,listening-->learning15s,learning-->forwarding20s
共计50s的时间,启用portfast后将直接从blocking-->forwarding状态,这样大大缩短了等待的时间。
说明:
portfast仅适用于连接终端或服务器的交换机端口,不能在连接交换机的端口上使用!
switch(config-if)#spanning-treeguardroot
/当一端口启用了root
guard功能后,当它收到了一个比根网桥优先值更优的BPDU包,则它会立即阻塞该端口,使之不能形成环路等情况。
这个端口特性是动态的,当没有收到更优的包时,则此端口又会自己变成转发状态了。
switch(config-if)#spanning-treebpdufilterenable
/当启用bpdufilter功能时,该端口将丢弃所有的bpdu包,可能影响网络拓扑的稳定性并造成网络环路
switch(config-if)#spanning-treebpduguardenable
/当启用bpduguard功能的交换机端口接收到bpdu时,会立即将该端口置为error-disabled状态而无法转发数据,进而避免了网络环路!
注意:
同时启用bpduguard与bpdufilter时,bpdufilter优先级较高,bpduguard将失效!
广播、组播风暴控制设定
switch(config-if)#storm-controlbroadcastlevel10/设定广播的阀值为10%
switch(config-if)#storm-controlmulticastlevel10/设定组播的阀值为10%
switch(config-if)#storm-controlactionshutdown/Shutdownthisinterface
ifastormoccurs
orswitch(config-if)#storm-controlactiontrap/SendSNMPtrapifastorm
occurs
MAC地址绑定端口安全设定
switch(config-if)#switchportport-security/启用端口安全
switch(config-if)#switchportport-securitymaximumnumber/默认每个接口最大的值为1
switch(config-if)#switchportport-securityviolation
protect|restrict|shutdown/启用安全违规行为
protect:
当接口学习到设定数量的MAC后,后来的MAC信息将直接丢弃,且不产生通知
restrict:
当接口学习到设定数量的MAC后,后来的MAC信息将直接丢弃并发送snmptrap,syslog信息。
shutdown:
当接口学习到设定数量的MAC后,后来的MAC信息将不再解析并直接关闭该端口,除非手动shut,no
shut或通过errdisablerecoverycause原因来进行恢复
switch(config-if)#switchportport-securitymac-addresssticky
/启用mac自动学习功能,无需手动进行绑定
端口错误检测和自动恢复设定
switch(config)#errdisabledetectcauseall/启用所有类型错误检测
switch(config)#errdisablerecoverycauseall/启用所有类型错误发生后在30s后自动恢复
switch(config)#errdisablerecoveryinterval30/自动恢复间隔时间为30s
四、三层交换机常用路由协议安全配置
1、RIP协议
建议不采用RIPV1,使用支持md5认证的RIPV2版本
switch(config)#keychainchain_name/设置密钥链名
switch(config-key-chain)#key1/设置密钥号
switch(config-key-chain)#key-stringpass_string/设置密钥字符串
switch(config)#routerrip
switch(config-router)#version2/启用RIP-V2
switch(config-router)#networkx.x.x.x
switch(config-router)#passive-interfacex/x
/启用passive-interface禁用一些不需要接收和转发路由信息的端口(只是禁止转发路由信息,并没有禁止接收)
switch(config)#interfacex/x
switch(config-if)#ipripauthenticationmodemd5/指定认证方式为md5
switch(config-if)#ipripauthenticationkey-chainchain_name/调用定义的密钥链名
注意:
启用RIPV2协议的互连路由接口其密钥KeyID和Keystring必须相同才可通过认证!
2、EIGRP协议
eigrp仅支持md5认证
switch(config)#keychainchain_name/设置密钥链名
switch(config-key-chain)#key1/设置密钥号
switch(config-key-chain)#key-stringpass_string/设置密钥字符串
switch(config)#routereigrpas-num/设置eigrp自治系统号,在本地有效
switch(config-router)#networkx.x.x.x
switch(config-router)#noauto-summary/关闭自动汇总功能
switch(config)#interfacex/x
switch(config-if)#ipauthenticationmodeeigrp100md5/指定eigrp
100区域的认证方式为md5
switch(config-if)#ipauthenticationkey-chaineigrp100chain_name
/调用定义的密钥链名
注意:
启用EIGRPmd5认证的互连路由接口其密钥KeyID和Keystring必须相同才可通过认证!
3、OSPF协议
switch(config)#routerospf100/设置本地有效的标识符100
switch(config-router)#areaarea_idauthenticationmessage-digest
/在区域内启用md5认证
switch(config-if)#ipospfauthenticationmessage-digest/在接口下启用md5认证
switch(config-if)#ipospfmessage-digest-keyidmd5pass_string
/在接口下设置md5密钥id及密钥字符串,两端启用OSPF路由协议的端口必须相同
4、HSRP/VRRP协议
switch(config)#keychainchain_name/设置密钥链名
switch(config-key-chain)#key1/设置密钥号
switch(config-key-chain)#key-stringpass_string/设置密钥字符串
switch(config-if)#standbygroup_numauthenticationmd5key-chainchain_name
/在启用hsrp协议的接口下启用md5认证并调用设定的密钥链名
switch(config-if)#vrrpgroup_numauthenticationmd5key-chainchain_name
/在启用vrrp协议的接口下启用md5认证并调用设定的密钥链名
五、交换机日志收集审计安全配置
trunk接口日志事件设定
switch(config)#intgix/x/x
switch(config-if)#swmodetrunk
switch(config-if)#swtrunkencapsdot1q
switch(config-if)#loggingeventtrunk-status
switch(config-if)#loggingeventlink-status
switch(config-if)#loggingeventspanning-tree
switch(config-if)#loggingeventbundle-status
switch(config-if)#loggingeventstatus
access接口日志世界设定
switch(config)#intgix/x/x
switch(config-if)#swmodeaccess
switch(config-if)#swaccessvlanxx
switch(config-if)#loggingeventlink-status
switch(config-if)#loggingeventspanning-tree
switch(config-if)#loggingeventbundle-status
switch(config-if)#loggingeventstatus
日志收集分析设定
switch(config)#loggingon/启动日志
switch(config)#logginghostx.x.x.x/设定收集日志的syslogserver
switch(config)#loggingsource-interfaceloopback0/设定发送日志的原地址
switch(config)#loggingfacilitylocal6/cisco设备的默认类型
switch(config)#loggingtrap7/设定记录日志服务的类型,数据越大,威胁程度越低,分为0-7,
设置为7表示包含所有日志类型
switch(config)#loggingbufferednumber/设定本地日志buffersize大小
时区和时间设定(确保日志记录的准确性)
switch(config)#clocktimezoneUTC8/设定时区为UTC8
switch(config)#ntpserverx.x.x.x/设定NTPServer时间同步服务器
switch(config)#ntpsourceloopback0/设定ntp时间同步原地址
switch(config)#ntpauthenticate/启用ntp认证
switch(config)#ntpauthentication-key1md5pass-string/设置认证密钥和密码
switch(config)#ntptrusted-key1
六、交换机其他安全配置
1、即时关注ciscoios漏洞信息,为漏洞ios安装补丁或升级ios
2、定期备份交换机设备配置文件及ios文件
3、严格设置登录Banner。
必须包含非授权用户禁止登录的字样
4、禁用DNS查找
switch(config)#noipdomain-lookup
/避免输入错误命令时,交换机进行dns解析查找直到dns查找失败,延迟较大;建议关闭
看了“cisco交换机安全配置设定命令详解”还想看: