Limitar el máximo direcciones mac Cisco I


 _     _           _ _              ___  ___ ___  _____   _____ 
| |   (_)         (_| |             |  \/  |/ _ \/  __ \ |_   _|
| |    _ _ __ ___  _| |_ __ _ _ __  | .  . / /_\ | /  \/   | |  
| |   | | '_ ` _ \| | __/ _` | '__| | |\/| |  _  | |       | |  
| |___| | | | | | | | || (_| | |    | |  | | | | | \__/\  _| |_ 
\_____|_|_| |_| |_|_|\__\__,_|_|    \_|  |_\_| |_/\____/  \___/ 
                                                                
 |
 |
 |
 |
 |
 |




Vamos a realizar una configuración muy sencilla a nivel de puerto para limitar el número de direcciones mac concurrentes en ese puerto.

Comenzaremos viendo el estado actual del puerto en el que vamos a actuar.

SWITCH01#show port-security interface gigabitEthernet 5/0/21
Port Security              : Disabled
Port Status                : Secure-down
Violation Mode             : Shutdown
Aging Time                 : 0 mins
Aging Type                 : Absolute
SecureStatic Address Aging : Disabled
Maximum MAC Addresses      : 1
Total MAC Addresses        : 0
Configured MAC Addresses   : 0
Sticky MAC Addresses       : 0
Last Source Address:Vlan   : 0000.0000.0000:0
Security Violation Count   : 0
 
Estos son los valores por defecto, comprobar que en la primera línea indica que la función está deshabilitada.

Accedemos a la configuración del puerto:
 
SWITCH01(config)#interface gigabitEthernet 5/0/21

SWITCH01(config-if)#switchport port-security

SWITCH01(config-if)#switchport port-security maximum 2

SWITCH01(config-if)#switchport port-security violation shutdown

Línea a línea:
  • switchport port-security, activamos la seguridad en ese puerto.
  • switchport port-security maximum 2, indicamos que el número máximo de direcciones mac concurrentes en este puerto son dos.
  • port-security violation shutdown, indicamos que deseamos hacer en caso de detectar una infracción, en mi caso prefiero apagarlo y cuando se detecte investigar las causas por las que ha saltado. Existen más opciones que se indican abajo.

Comprobamos el estado despues de configurar.
 
SWITCH01#show port-security interface gigabitEthernet 5/0/21
Port Security              : Enabled
Port Status                : Secure-shutdown
Violation Mode             : Shutdown
Aging Time                 : 0 mins
Aging Type                 : Absolute
SecureStatic Address Aging : Disabled
Maximum MAC Addresses      : 2
Total MAC Addresses        : 0
Configured MAC Addresses   : 0
Sticky MAC Addresses       : 0
Last Source Address:Vlan   : 10e7.c6ad.0888:216
Security Violation Count   : 0


El valor Security Violation Count es un contador que indica el número de veces que este puerto ha detectado un infracción de seguridad.

Si realizamos una prueba física podremos comprobar que el puerto pasa al estado shutdown

SWITCH01#show interfaces status err-disabled
Port     Name   Status       Reason         Err-disabled Vlans
Gi5/0/21 Prueba  err-disabled psecure-violation

Con el comando anterior comprobamos el estado (err-disabled)y el tipo de error (psecure-violation).

Además si volvemos a lanzar el comando
show port-security interface gigabitEthernet 5/0/21 observaremos que el valor Security Violation Count
ha incrementado

Otro comando para observar estos estados sería show port:

SWITCH01#show port
Secure Port  MaxSecureAddr  CurrentAddr  SecurityViolation  Security Action
                (Count)       (Count)          (Count)
---------------------------------------------------------------------------
   Gi1/0/20              1            0                  0         Shutdown
   Gi5/0/21              1            0                  1         Shutdown
   Gi5/0/22              1            0                  2         Shutdown
---------------------------------------------------------------------------

Para restablecer el puerto accediendo al mismo y con un shutdown no shutdown se habilitaría, es aconsejable investigar el motivo de la infracción de seguridad.
 
Tenemos este comando errdisable recovery cause psecure-violation que se engloba dentro de errdisable recovery

SWITCH01(config)#errdisable recovery cause ?
  all                  Enable timer to recover from all error causes
  arp-inspection       Enable timer to recover from arp inspection error disable state
  bpduguard            Enable timer to recover from BPDU Guard error
  channel-misconfig    Enable timer to recover from channel misconfig error (STP)
  dhcp-rate-limit      Enable timer to recover from dhcp-rate-limit error
  dtp-flap             Enable timer to recover from dtp-flap error
  gbic-invalid         Enable timer to recover from invalid GBIC error
  inline-power         Enable timer to recover from inline-power error
  link-flap            Enable timer to recover from link-flap error
  loopback             Enable timer to recover from loopback error
  mac-limit            Enable timer to recover from mac limit disable state
  pagp-flap            Enable timer to recover from pagp-flap error
  port-mode-failure    Enable timer to recover from port mode change failure
  pppoe-ia-rate-limit  Enable timer to recover from PPPoE IA rate-limit error
  psecure-violation    Enable timer to recover from psecure violation error
  psp                  Enable timer to recover from psp
  security-violation   Enable timer to recover from 802.1x violation error
  sfp-config-mismatch  Enable timer to recover from SFP config mismatch error
  small-frame          Enable timer to recover from small frame error
  storm-control        Enable timer to recover from storm-control error
  udld                 Enable timer to recover from udld error
  vmps                 Enable timer to recover from vmps shutdown error
 
 
Existen otras configuraciones como fijar a nivel de puerto el valor de la mac para que de esta forma solo ese dispositivo pueda funcionar en ese puerto o que en lugar de shutdown definitivo se levante al cierto tiempo, estas configuraciones exceden esta entrada pero dejo aquí todas las opciones disponibles.

SWITCH01(config-if)#switchport port-security ?
  aging        Port-security aging commands
  mac-address  Secure mac address
  maximum      Max secure addresses
  violation    Security violation mode
  
SWITCH01(config-if)#switchport port-security mac-address ?
  H.H.H   48 bit mac address
  sticky  Configure dynamic secure addresses as sticky

SWITCH01(config-if)#switchport port-security aging ?
  static  Enable aging for configured secure addresses
  time    Port-security aging time
  type    Port-security aging type

SWITCH01(config-if)#switchport port-security maximum ?
  <1-16384>  Maximum addresses

SWITCH01(config-if)#switchport port-security violation ?
  protect   Security violation protect mode
  restrict  Security violation restrict mode
  shutdown  Security violation shutdown mode


Si queremos conocer el estado de errdisable
Config t
SWITCH01#show errdisable recovery
ErrDisable Reason            Timer Status
-----------------            --------------
arp-inspection               Enabled
bpduguard                    Enabled
channel-misconfig (STP)      Enabled
dhcp-rate-limit              Enabled
dtp-flap                     Enabled
gbic-invalid                 Enabled
inline-power                 Enabled
link-flap                    Enabled
mac-limit                    Enabled
loopback                     Enabled
pagp-flap                    Enabled
port-mode-failure            Enabled
pppoe-ia-rate-limit          Enabled
psecure-violation            Enabled
security-violation           Enabled
sfp-config-mismatch          Enabled
small-frame                  Enabled
storm-control                Enabled
udld                         Enabled
vmps                         Enabled
psp                          Enabled
dual-active-recovery         Disabled
evc-lite input mapping fa    Disabled
Recovery command: "clear     Disabled

Timer interval: 300 seconds

Interfaces that will be enabled at the next timeout:

Interface       Errdisable reason       Time left(sec)
---------       -----------------       --------------
Gi5/0/21       psecure-violation          244

 


No hay comentarios:

Publicar un comentario