交换网络安全性

一,交换网络的攻击分类
           1)MAC层攻击
           2)VLAN攻击
           3)欺骗攻击
           4)攻击交换机设备
          
           己知单播帧----精确转发                                                      
           末知单播帧----泛洪                                                            
           广播/组播帧---泛洪      
                        
二port-security  ----靠MAC地址的方式,但是MAC地址可以随便修改!

  功能:限制指定端口上最多能学到 多少个 MAC地址,配置在Access端口上
  trunk端口上学到多少个MAC地址 不能限制,一般不配端口安全性
  缺省情况下,没有开启

 int fa0/1
 switchport port-security maximum  2 violation(违背) protect / restrict/shutdown
                          

  二个参数:
     1)设置这个端口能学几个MAC地址, 缺省为1个
     2)设置 违规动作,  缺省为shutdown 进入error-disable状态
                 违规动作: protect  /  restrict
 
                  假设 PC1(MAC1)接到fa0/1,(正常使用)
                           PC2(MAC2)接到fa0/1,(正常使用)
                           PC3(MAC3)接到fa0/1,(无法使用)
         protect 发现违规时,不发送SNMP trap给网管
         restrict发现违规时,将发送SNMP trap给网管
         shutdown发现违规时,将该端口置为err-disable状态-----(默认违规动作)

实际配置里有问题?
SW1(config-if)#switchport port-security max
SW1(config-if)#switchport port-security maximum 2 ?
  vlan  Max secure addresses per vlan
  <cr>


关于err-disable:
    【err-disable】状态的如何恢复?
    (1)配置err-disable recovery:
    一定时间后自动恢复(不推荐使用)
  (2)手工恢复:
     int fa0/1
     shutdown
     no shutdown

查看命令show port-security
        show port-security interface fa5/1
        show port-security address


关于Trap:
         【SNMP(简单网络管理协议)工作原理】:  
      NMS(网络管理服务器)----------SNMP-------------网络设备
                     --->GET------定期轮询设备的状态,周期不可能太短
                     --->SET------对设备进行配置
                                                                  <---TRAP<----

          配置 端口安全性命令:
            interface Fa0/1
              switchport mode access
              switchport port-security

     查看命令:show port-security
                      show port-security interface Fa0/1

     显示以下内容:
     SW1#show port-security
     *Mar  1 04:55:54.394: %SYS-5-CONFIG_I: Configured from console by console
     SW1#show port-security
     Secure Port  MaxSecureAddr  CurrentAddr  SecurityViolation  Security Action
                     (Count)       (Count)          (Count)
     ---------------------------------------------------------------------------
           Fa0/9              1            0                  0         Shutdown
     ---------------------------------------------------------------------------
     Total Addresses in System (excluding one mac per port)     : 0
     Max Addresses limit in System (excluding one mac per port) : 5120


Sticky MAC Address:
  存储在running config--->保存到启动配置
  功能:在端口上开启该功能,那第一次学进来的MAC地址存储到running config,保存下来
  省去手工配置MAC地址的麻烦,会去存储动态学习到的MAC地址
   再存储到start-config !!!


三 AAA----根据不同用户作身份验证
    802.1X 开启后,基于端口的验证机制.
    之后交换机端口缺省的是非授权状态,经过验证通过之后,该端口才会开发!
   Authentication:验证用户的身份
    Authorization:授权,指定用户的权限
    Accounting:计帐

AAA典型协议:
    RADIUS(RFC标准)
   TACACS+(Cisco私有)

【802.1x验证过程】:
  【针对接入层交换机,使用802.1x这种基于端口的验证功能来提高安全性,使非法用户无法接到网络中】
   1--交换机开启dot1x功能 aaa new-model  
   2--交换机将端口的授权状态处于AUTO状态---没有经过验证Authentication,处于非授权状态                         
   只有通过验证Authentication  之后,处于授权状态;
   3--验证通常转交给后台的AAA Server来验证帐号和密码,将结果返回回交换机,再来判断!
----------------------------------------------- 
   一般的配置:
     line vty 0 4
     login
     password 123

   开启AAA功能:
    aaa new-model
   针对登陆操作建立一个新的验证列表
 aaa authentication login vty_login local
 
   应用:
   line vty 0 4
   login authentication vty_login

【AAA验证】:
     格式:aaa authentication 【login】 {default | list-name} method1 [method2...]
    login:针对telnet 通过vty线路,console口登陆到设备本身

  Router(config)#aaa new-model  ---(1)-(启用AAA)
  Router(config)#aaa authentication   login   vty_login   local

(2)-(针对"login"动作进行验证)(验证列表"名称")(验证方法:本地帐号)
  Router(config-line)#aaa authentication  login  default  local
   (console,vty线路默认,缺省用的是default验证列表)
       
**VTY线路:
    Router(config)#line vty 0 4
    Router(config-line)#login authentication vty_login---(3)-(应用:到对应的要使用的VTY线路上)

**Console口:
    Router(config)#line console 0
    Router(config-line)#login authentication vty_login
    Router(config-line)#password 123 --------------------(线路密码没有用,己将验证方法修改为local了)
    Router(config)#username user01 password pass01---(4)-(创建本地local帐号及密码)
----------------------
Router(config)#username user01 password pass01---(创建本地帐号及密码)
Router(config)#aaa new-model---(启用AAA)
Router(config)#aaa authentication login default local
Router(config)#line vty 0 4
Router(config-line)#login authentication default


【配置 802.1x】:
     Switch(config)#aaa new-model   -------(1)-(启用AAA)  要用到身份验证,而身份验证是要用到AAA模块来实现的

     Switch(config)#aaa authentication dot1x   {default}                               method1 [method2...]

      *只能用default,不用写验证列表名称了方法,通常是用外部服务器

     R(config)#aaa authentication login vty_tacacs group tacacs+ none
           注: (group tacacs+:如果验证服务器返回给我结果,无论成功或者失败,都不会用第二种(none))
                      (None:当tacacs+服务器故障了,发报文给它,都无响应,这时才会使用第二种(none))  
                Cannot process authentication server type tacacs+(UNKNOWN)

     R(config)#tacacs-server host 192.168.0.254 key(密钥) alading(与AAA服务器共享一个密钥)

                                  key   per-server encryption key(overrides default)
     在AAA Server上:
          NAS Hostname:   Router
          NAS IP Address: 192.168.222.1
          TACACS+ Key:    alading

--------------------

     Switch(config)#aaa new-model                                            -----Enables AAA

     Switch(config)#aaa authentication dot1x {default} method1 [method2...]  -----(3)Creates an 802.1x port-based authentication method list
                                                                        
     Switch(config)#dot1x system-auth-control                                -----(1)在全局模式下开启802.1x功能
                                                                        
     Switch(config)#interface fa5/1                                          -----(2)在端口下开启802.1x功能
     Switch(config-if)#dot1x port-control auto                                      auto:表示这个端口经过验证之后才会授权
  force-authentication              
force-authen:强制授权,这个端口可以直接使用,不需要经过验证,接服务器
  force-unauthentication          
force-unauthen:强制未授权,这个端口不能使用
-------------------

VLAN Hopping
VLAN跳跃攻击
交换机ACL配置指南
1)Port ACL :
     配置在2层接口上,控制进入 2层接口的流量(3750不支持对"出"流量控制),在每个L2接口上只能够应用1个IP ACL和1个MAC ACL

2)Router ACL:
     配置在3层接口上,控制不同VLAN间 路由的流量,可以对出,入流量控制.

3) VLAN ACL
      即VLAN maps,可以控制 所有的流量 (包括桥接的流量,路由的流量),

      VLAN map无需定义方向,它将过滤所有的出,入流量 

以上3种ACL同时配置时,Port ACL优先于其他2种。
    a)若交换机上同时配置 input Port ACL和VLAN map,
        则应用了Port ACL的接口上收到的报文采用Port ACL过滤,其他报文用VLAN map过滤
    b)若在交换机的一个SVI(交换虚拟接口)上同时存在input Router ACL和input Port ACL
     则应用了Port ACL的接口上接收到的报文采用Port ACL过滤,在其他接口上收到路由的IP报文用Router ACL过滤
    c)若一个SVI上同时存在 output Router ACL和intput Port ACL, 则应用了Port ACL的接口上接收到的报文采用Port ACL过滤,出方向的路由的IP报文将用Router ACL过滤,其他报文不过滤。
    d)若一个SVI上同时存在VLAN map、input Router ACL、input Port ACL,
    则应用了Port ACL的接口上接收到的报文只采用Port ACL过滤,
    在其他端口上收到的路由的IP报文将同时用 VLAN map和Router ACL过滤,其他报文则只用VLAN map过滤。
    e)若一个SVI上同时存在VLAN map、output Router ACL、input Port ACL,
    则应用了Port ACL的接口上接收到的报文只采用Port ACL过滤,在其他端口上发送的路由的IP报文将同时用VLAN map和Router ACL过滤,其他报文则只用VLAN map过滤。

Port ACL:应用于2层端口,支持以下类型的ACL
           ×× 标准IP ACL(源IP)
           ×× 扩展IP ACL(源/目标IP以及可选的协议类型等)
           ×× MAC扩展 ACL(源/目标MAC地址以及可选的协议类型等)

Router ACL:应用于3层接口(如SVI或物理L3接口),支持以下类型的ACL
          ×× 标准IP ACL(源IP)
          ×× 扩展IP ACL(源/目标IP以及可选的协议类型等)

[交换机ACL配置示例]
PC1接在Fa1/0/2下,192.168.1.1
PC2接在Fa1/0/3下,192.168.1.2

interface FastEthernet1/0/2
   switchport access vlan 10
   switchport mode access
   ip access-group 1 in

interface FastEthernet1/0/3
   switchport access vlan 10
   switchport mode access

interface Vlan10
   ip address 192.168.1.254 255.255.255.0
   ip access-group 1 in

int vlan 100
   ip address 192.168.100.1 255.255.255.0
   
access-list 1 permit 192.168.1.1 0.0.0.0

vlan access-map test 10
   action drop
   match ip address 1

vlan access-map test 20
   action forward

vlan filter test vlan-list 10

----------------------------

Private VLANS
   隔离(Isolated):只能访问混杂端口
   混杂(Promiscuous):可以访问任意端口
   团体(Community):同一团体内可以互访 / 可以访问混杂端口


[PVLAN配置示例]
Catalyst 3750
Fa1/0/1    PC1(192.168.1.1)
Fa1/0/2    PC2(192.168.1.2)
Fa1/0/3    Server(192.168.1.3)

PVLAN:VLAN 100

输助VLAN:
         a)隔离VLAN VLAN 200 (在隔离VLAN中的端口相互是隔离,它们可以访问到混杂端口)

         b)团体VLAN VLAN 300 (属于同一个团体VLAN的端口间可以互访,不能访问其他团体VLAN的端口 / 不能访问隔离VLAN的端口,它们可以访问到混杂端口)  VLAN 400
------------------------------------------
Pc1-----Pc3  sales
Pc4-----Pc5  hr
pc6
pc7
pc8
     规划PVLAN,包括辅助vlan: 1个隔离vlan(vlan 200),将pc6/7/8划入该vlan, 2个团体vlan(vlan 300,400),将pc1/2/3划入vlan 300,pc4/5划入vlan 400
-------------------------------------------
配置如下:
更改VTP为透明模式
  vtp mode transparent                 
VTP只能传播普通VLAN信息,不能传播PVLAN,必须配置成透明模式
                                                            
trunk 支持PVLAN传输,PVLAN支持跨交换机

vlan 100   (创建主VLAN)

  private-vlan primary

  private-vlan association 200,300,400(辅助vlan要隶属于主vlan,所在在主VLAN里要配置“关联”关系)

vlan 200  (创建辅助VLAN)
  private-vlan isolated

vlan 300  (创建辅助VLAN)
private-vlan community

vlan 400  (创建辅助VLAN)
  private-vlan community

interface Fa1/0/1 (PC1:192.168.1.1)

  switchport private-vlan host-association 100 200----映射关系

  switchport mode private-vlan host (隔离端口)---团体,隔离VLAN配置相同

interface Fa1/0/2 (PC2:192.168.1.2)

  switchport private-vlan host-association 100 200----映射关系

switchport mode private-vlan host  (隔离端口)

interface Fa1/0/3 (Server:192.168.1.3)

  swithport private-vlan mapping 100 200,300,400------映射关系

  swithport mode private-vlan promiscuous(混杂端口)

   三层想要访问外网的话,利用同一个网关出去,配置公用一个网关

interface Vlan100---------(使用主VLAN 100)

  ip add 192.168.1.254 255.255.255.0

  private-vlan mapping 200,300,400---------辅助VLAN 200,300,400可以使用三层接口作为网关

总结:
        1---尽可能将端口的trunk协商特性(DTP关闭)关闭,避免通过trunk端口对交换网络进行攻击

   2---Native VLAN尽可能不要进行业务数据的传输

          3---利用访问控制列表对进,出VLAN的数据作流量限制

          4---PVLAN 实现用户与用户之间的隔离

---------------------
措施一:"DHCP欺骗"
措施二:"IP源保护" 功能
[Ip Source Guard配置示例]
--1)DHCP环境
 全局配置命令:
  ip dhcp snooping vlan 12,200       ----在指定VLAN里启动DHCP Snooping
  no ip dhcp snooping information option
  ip dhcp snooping                       ----开启DHCP Snooping
  接口配置命令:
  ip verify source vlan dhcp-snooping(仅对源IP地址进行检测)
  ip verify source vlan dhcp-snooping port-security(同时检测源IP地址+源MAC地址)
--2)不使用DHCP时的静态配置
IOS全局配置命令:
  ip dhcp snooping vlan 12,200
  ip dhcp snooping information option
  ip dhcp snooping                        
  ip source binding 0009.6b88.d387 vlan 200 192.168.10.1 interface fa1/0/1


[ARP Spoofing]
措施三:"DAI"功能
 Dynamic ARP Inspection---动态ARP检测
[DAI配置示例]
标准配置:
  Switch(config)#ip arp inspection vlan vlan_id[,vlan_id]
---1)-指定在哪些VLAN里面开启ARP的检测功能
  Switch(config-if)#ip arp inspection trust
---2)-配置信任端口,缺省情况下,这些端口都是非信任端口
  Switch(config-if)# ip arp inspection validate {[src-mac][dst-mac][ip]}
---3)配置在ARP进行检测时,针对源MAC/目标MAC/IP报文进行检测

1)DHCP环境
全局配置命令:
  ip dhcp snooping                       /*开启DHCP窃听功能
  ip dhcp snooping vlan 100,200
  ip dhcp inspection vlan 100,200        /*定义对哪些VLAN进行ARP报文检测
  ip arp inspection log-buffer entries 1024
  ip arp inspection log-buffer logs 1024 interval 10
接口配置命令:
  ip dhcp snooping trust
  ip arp inspection trust                /*定义哪些接口是信任接口,通常是网络设备接口,TRUNK接口等
  ip arp inspection limit rate 15        /*(pps)定义接口每秒ARP报文数量
2)不使用DHCP时的静态配置
  对于没有使用DHCP设备可以采用下面办法:
   arp access-list static-arp
   permit ip host 192.168.10.1 mac host 000e.6b88.d387
   ip arp inspection filter static-arp vlan 200
----配置DAI后的效果
  在配置DAI技术的接口上,用户端不能采用指定地址地址将接入网络
   由于DAI检查DHCP snooping绑定表中的IP和MAC对应关系,无法实施中间人攻击,攻击工具失效
     下表为进行中间人攻击时的交换机的警告:
           3w0d:%SW_DAI-4-DHCP_SNOOPING_DENY: 1 Invalid ARPs(Req) on Fa5/16,vlan 1.
        ([000b.db1d.6ccd/192.168.1.200/0000.0000.0000/192.168.1.2])
      
   由于对ARP请求报文做了速度限制,客户端无法进行认为或者病毒进行的IP扫描,探测等行为,如果发生这些行为,交换机马上报警或直接切断扫描机器
     下表所示:
     3w0d:%SW_DAI-4-PACKET_RATE_EXCEEDED:16 packets received in 184 milliseconds on Fa5/30.*******报警
          3w0d:%PM-4-ERR_DISABLE: arp-inspection error detected on Fa5/30,putting Fa5/30 in err-disable state  *******切断端口
      
          Catalyst3750#show int fa0/1
          FastEthernet0/1 is down,line protocol is down(err-disable)
          Hardware is Fast Ethernet Port,address is 0002.b90e.3f4d(bia 0002.b90e.3f4d)

      用户获取IP地址后,用户不能修改IP或MAC,如果用户同时修改IP和MAC必须是网络内部合法的IP和MAC才可,对于这种修改可以使用IP Source Guard技术来防范
           下表为手动指定IP的报警:
           3w0d:%SW_DAI-4-DHCP_SNOOPING_DENY: 1 Invalid ARPs(Req) on Fa5/30,vlan 1

--------------------------------------------STP安全机制--------------------------------------------
一,BPDU Guard
       在配置PortFast特性的端口上开启
          若在PortFast端口上接收到BPDU报文,则该端口进入err-disabled
     标准配置:
       Switch(config)#spanning-tree portfast bpduguard
             强烈推荐配置,思科交换机设备缺省开启生成树
     所有接终端(接入层交换设备)的接口配置portfast,然后把BPDU Guard打开

实例:
            SW1(access)----------------(access)SW2
                       思科                         华为
           SW1:
          spanning-tree portfast default                           /*所有Access端口都配置portfast

         spanning-tree portfast bpduguard default        /*所有portfast开启BPDU保护功能,
   
       show int fa0/1
       err-disable

       PortFast端口 只要开启BPDU Guard了,一旦收到一个BPDU报文,马上会err-disable状态


               SW1(trunk)----------------(trunk)SW2
                      思科                         华为
       不会出现以上问题,因为命令spanning-tree portfast default  只会把Access端口配置成PortFast


二,* BPDU Fliter   (最好不用开启)
           在某些端口上,不希望往外发送BPDU,可以配置BPDU filter,
           配置了bpdu filter的端口,将不会发送BPDU报文
           建议在PortFast端口上配置,其他端口最好不配置该特性  
           接入PC的交换机的端口 (PortFast) 会定期向PC发送BPDU报文,可以将其过虑不发送给PC

三,Root Guard
      保护交换网络中的根桥,不会被恶意交换机设备抢占根桥身份.
      若一个端口配置了Root Guard特性,如果它收到一个更优的BPDU报文, 则该端口进入Root-Inconsistent状态
     在所有不希望成为RP(根端口)的端口上配置Root Guard     
     在所有不希望成为RP的端口上开启 Root Guard,防止成为RP端口!   进入root-in-consistance

       在不希望成为RP的端口下配置:
        Switch(config-if)#spanning-tree guard root

       查看命令:违反规则进入inconsistentports
                  show spanning-tree inconsistentports

四, 如何检测单向链路?
       UDLD(Unidirectional Link Detect,单向链路检测)
       如端口开启UDLD检测,当检测到单向链路时,端口进入Err-Disabled.
       若要手工恢复,使用命令Switch#udld reset

       在Cisco设备中,缺省时,所有的光口(all fiber-optic interfaces)都开启该功能
       电口缺省未开启此功能

       命令---udld enable启用 单向链路检测 功能

        ---UDLD只能检测 [硬件]miswiring(线缆接错) 问题导致的单通

五,   Loop Guard特性

   若交换机由于 [软 件]problem in software 的原因无法发送BPDU,导致环路,必须用loop guard特性来避免     
       Loop Guard特性在 RP 或 AP 上配置.

        若RP或AP上配置了Loop Guard,当RP或AP没有接收到对方发送的BPDU时,该端口进入Loop-inconsistent状态,避免环路。

        若该端口重新收到BPDU报文,则端口恢复正常

    配置命令:
           spantree global-default loopguard enable
 

发布了145 篇原创文章 · 获赞 0 · 访问量 3337

猜你喜欢

转载自blog.csdn.net/qq_43207781/article/details/105279940