Serveur sms avec traitement de contenu, avec Gammu
Port security
1. Port-security<br />Par Fred le vendredi, avril 18 2008, 14:44 - CCNP - Lien permanent <br />bcmsn<br />CCNP<br />port-security<br />sécurité<br />Cet article présente la fonction port-security que l'on peut appliquer à une interface sur un switch Cisco pour restreindre le nombre d'adresse mac utilisable sur ce port.<br />Configuration<br />Vérification<br />Adresse Dynamic ou Configured<br />Exemple de Violation<br />Recovery<br />Sticky<br />Changer son adresse Mac<br />Configuration<br />Activation<br />Le port-security s'applique sur les interfaces access<br />SW1(config)#int fa 0/3<br />SW1(config-if)#switchport port-security<br />Nombre d'adresse maximum<br />on peut spécifier un nombre maximum d'adresse: 1 (par défaut) à 132.<br />SW1(config-if)#switchport port-security maximum 2<br />Violation<br />la commande violation permet de spécifier le comportement à avoir en cas de détection de violation: <br />protect : les trames venant des adresses non autorisées sont droppées et il n'y a aucun message de log signalant la violation.<br />restrict : les trames venant des adresses non autorisées sont droppées, un message de log est créé et une trap SNMP est envoyée.<br />shutdown : si une trame venant d'une adresse non autorisée est détécté, le port est mis en err-disabled, un message de log est créé et une trap SNMP est envoyée. Une intervention manuelle est nécessaire ou errdisable revovery doit être configuré pour automatiquement faire remonter le port après un certain laps de temps.<br />SW1(config-if)#switchport port-security violation shutdown<br />Adresse Mac<br />On peut spécifier des adresses mac statiquement. A noter que si aucune adresse n'est spécifiée, elle sera apprise automatiquement.<br />SW1(config-if)#switchport port-security mac-address 0050.5611.06b1<br />Il n'est pas possible de mettre n'importe quoi<br />SW1(config-if)#switchport port-security mac-address 0500.4333.5431<br />Invalid secure mac-address 0500.4333.5431.<br />On peut spécifier autant d'adresse que le nombre maximum spécifié. Attention les adresses apprises dynamiquement compte pour une adresse.<br />SW1(config-if)#switchport port-security mac-address 0050.1111.3332<br />Total secure mac-addresses on interface FastEthernet0/3 has reached maximum limit.<br />Vérification<br />Dans l'exemple suivant, nous voyons que pour le port Fa0/3, 2 adresses sont autorisées et une seule a été configurée. En cas de violation, le port est mis en shutdown.<br />SW1#sh port-security<br />Secure Port MaxSecureAddr CurrentAddr SecurityViolation Security Action<br /> (Count) (Count) (Count)<br /> Fa0/3 2 1 0 Shutdown<br />Total Addresses in System (excluding one mac per port) : 0<br />Max Addresses limit in System (excluding one mac per port) : 1024<br />Voir les adresses affectées une interface<br />Dans l'example ci-dessous, la première adresse est configurée statiquement et la seconde a été apprise dynamiquement.<br />SW1#sh port-security address<br /> Secure Mac Address Table<br />Vlan Mac Address Type Ports Remaining Age<br /> (mins)<br /> 11 0050.5564.2111 SecureConfigured Fa0/3 -<br /> 11 0050.5611.06b1 SecureDynamic Fa0/3 -<br />Total Addresses in System (excluding one mac per port) : 1<br />Max Addresses limit in System (excluding one mac per port) : 1024<br />Voir l'état d'un port<br />SW1#sh port-security interface fa 0/3<br />Port Security : Enabled<br />Port Status : Secure-up<br />Violation Mode : Shutdown<br />Aging Time : 0 mins<br />Aging Type : Absolute<br />SecureStatic Address Aging : Disabled<br />Maximum MAC Addresses : 2<br />Total MAC Addresses : 1<br />Configured MAC Addresses : 1<br />Sticky MAC Addresses : 0<br />Last Source Address : 0000.0000.0000<br />Security Violation Count : 0<br />Adresse Dynamic ou Configured<br />Si l'adresse n'a pas été configuré statiquement sur un port, elle peut avoir été apprise dynamiquement<br />SW1#sh port-security address<br /> Secure Mac Address Table<br />Vlan Mac Address Type Ports Remaining Age<br /> (mins)<br /> 11 0050.5611.06b1 SecureDynamic Fa0/3 -<br />Total Addresses in System (excluding one mac per port) : 0<br />Max Addresses limit in System (excluding one mac per port) : 1024<br />Si l'on souhaite ajouter l'adresse dynamiquement dans la configuration de l'interface, un message d'erreur nous indique que l'adresse est déja connue.<br />SW1(config)#int fa 0/3<br />SW1(config-if)#switchport port-security mac-address 0050.5611.06b1<br />Found duplicate mac-address 0050.5611.06b1.<br />Il faut alors supprimer cette adresse (bien que n'apparaissant pas dans la configuration), et la re-assigner. Si vous n'avez pas le temps entre ces 2 lignes, mettez le port en shut et faites la modification calmement.<br />SW1(config-if)#no switchport port-security mac-address 0050.5611.06b1<br />SW1(config-if)#switchport port-security mac-address 0050.5611.06b1<br />L'adresse est maintenant bien connue comme static.<br />SW1#sh port-security address<br /> Secure Mac Address Table<br />Vlan Mac Address Type Ports Remaining Age<br /> (mins)<br /> 11 0050.5611.06b1 SecureConfigured Fa0/3 -<br />Total Addresses in System (excluding one mac per port) : 0<br />Max Addresses limit in System (excluding one mac per port) : 1024<br />Exemple de Violation<br />En fonctionnement normal<br />SW1#sh port-security<br />Secure Port MaxSecureAddr CurrentAddr SecurityViolation Security Action<br /> (Count) (Count) (Count)<br /> Fa0/3 1 1 0 Shutdown<br />Total Addresses in System (excluding one mac per port) : 0<br />Max Addresses limit in System (excluding one mac per port) : 1024<br />Log lors de la violation<br />*Mar 2 19:00:58: %PM-4-ERR_DISABLE: psecure-violation error detected on Fa0/3, putting Fa0/3 in err-disable state<br />*Mar 2 19:00:58: %PORT_SECURITY-2-PSECURE_VIOLATION: Security violation occurred, caused by MAC address 0010.f6b3.d000 on port FastEthernet0/3.<br />*Mar 2 19:00:59: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to down<br />*Mar 2 19:01:00: %LINK-3-UPDOWN: Interface FastEthernet0/3, changed state to down<br />Le port est bloqué<br />SW1#sh port-security<br />Secure Port MaxSecureAddr CurrentAddr SecurityViolation Security Action<br /> (Count) (Count) (Count)<br /> Fa0/3 1 1 1 Shutdown<br />Total Addresses in System (excluding one mac per port) : 0<br />Max Addresses limit in System (excluding one mac per port) : 1024<br />L'état du port est passé en err-disabled.<br />SW1#sh int fa 0/3 status<br />Port Name Status Vlan Duplex Speed Type<br />Fa0/3 PC win XP err-disabled 11 full 100 10/100BaseTX<br />SW1#sh port-security interface fa 0/3<br />Port Security : Enabled<br />Port Status : Secure-shutdown<br />Violation Mode : Shutdown<br />Aging Time : 0 mins<br />Aging Type : Absolute<br />SecureStatic Address Aging : Disabled<br />Maximum MAC Addresses : 2<br />Total MAC Addresses : 2<br />Configured MAC Addresses : 2<br />Sticky MAC Addresses : 0<br />Last Source Address : 0010.f6b3.d000<br />Security Violation Count : 1<br />Recovery<br />Il est possible de faire remonter le port automatiquement après un certain delais. Dans l'exemple suivant, si un port est en err-disabled à cause d'une<br />violation port-security, il est remonté au bout de 30 secondes.<br />errdisable recovery cause psecure-violation<br />errdisable recovery interval 30<br />Mar 2 19:26:24: %PM-4-ERR_RECOVER: Attempting to recover from psecure-violation err-disable state on Fa0/3<br />Mar 2 19:26:29: %LINK-3-UPDOWN: Interface FastEthernet0/3, changed state to up<br />Mar 2 19:26:30: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to up<br />Sticky<br />En mode sticky, le switch va apprendre automatiquement l'adresse de l'utilisateur et la conserve (une ligne apparait automatiquement dans la configuration de l'interface). Ainsi, une fois que l'adresse est connue, on ne peut plus la changer. En mode dynamique, on peut limiter le nombre d'adresse mais si un utilisateur disparaît, un nouveau peut prendre la place.<br />Configurer sticky<br />SW1(config-if)#switchport port-security mac-address sticky<br />Vérifier<br />SW1#sh run int fa 0/3<br />Building configuration...<br />Current configuration : 236 bytes<br />!<br />interface FastEthernet0/3<br /> description PC win XP<br /> switchport access vlan 11<br /> switchport mode access<br /> switchport port-security<br /> switchport port-security mac-address sticky<br /> shutdown<br /> speed 100<br /> duplex full<br /> spanning-tree portfast<br />end<br />Vérification<br />SW1#show port-security address<br /> Secure Mac Address Table<br />Vlan Mac Address Type Ports Remaining Age<br /> (mins)<br /> 11 0010.f6b3.d000 SecureSticky Fa0/3 -<br />Total Addresses in System (excluding one mac per port) : 0<br />Max Addresses limit in System (excluding one mac per port) : 1024<br />On voit qu'une ligne est automatiquement ajoutée dans la configuration<br />SW1#sh run int fa 0/3<br />Building configuration...<br />Current configuration : 286 bytes<br />!<br />interface FastEthernet0/3<br /> description PC win XP<br /> switchport access vlan 11<br /> switchport mode access<br /> switchport port-security<br /> switchport port-security mac-address sticky<br /> switchport port-security mac-address sticky 0010.f6b3.d000<br /> speed 100<br /> duplex full<br /> spanning-tree portfast<br />end<br />Changer son adresse Mac<br />ChangeMac sur PC<br />ChangeMac sur Mac<br />Sous Linux<br />ifconfig eth0 hw ether 0050.1234.4567<br />