← Retour au portail

🔷 Module C3 – Commandes switches Cisco

📘 Fiche de cours ⏱️ 4h 🎯 Bloc 2 – SISR
Objectifs : maîtriser les commandes de configuration des switchs Cisco : VLAN, trunk, Spanning Tree (STP) avancé, port-security, EtherChannel.

📖 Introduction

Les switchs Cisco sont au cœur des infrastructures réseau. Ce module vous présente les commandes essentielles pour configurer les VLAN, les trunks, Spanning Tree (STP) avec ses optimisations, la sécurité des ports et l'agrégation de liens (EtherChannel).

🎯

À l'issue de ce module, vous serez capable de :

  • Créer et gérer des VLAN.
  • Configurer des ports en mode access et trunk.
  • Maîtriser Spanning Tree (portfast, root guard, BPDUguard).
  • Sécuriser les ports avec port-security (sticky MAC, violation).
  • Configurer EtherChannel (LACP, PAgP).

📐 Gestion des VLAN

  • Créer un VLAN : vlan 10 puis name IT
  • Attribuer un port en accès : switchport mode access ; switchport access vlan 10
  • Attribuer plusieurs ports : interface range fastEthernet 0/1-10
  • Vérifier : show vlan brief

🔀 Trunk

  • Configurer un trunk : switchport mode trunk
  • Autoriser certains VLAN : switchport trunk allowed vlan 10,20,30
  • VLAN natif : switchport trunk native vlan 99 (pour la sécurité).
  • Vérifier : show interfaces trunk

🌳 Spanning Tree Protocol (STP)

  • Rôle : éviter les boucles réseau en bloquant certains ports.
  • États : Blocking, Listening, Learning, Forwarding, Disabled.
  • Optimisations :
    • Portfast : spanning-tree portfast (pour les ports d'utilisateurs, permet une transition directe vers Forwarding).
    • BPDUguard : spanning-tree bpduguard enable (désactive le port s'il reçoit des BPDU, utile sur les ports d'utilisateurs).
    • Root guard : spanning-tree guard root (empêche un port de devenir root).
  • Vérifier : show spanning-tree
  • Piège : oublier Portfast sur les ports d'utilisateurs peut causer des temps d'attente de 30 à 50 secondes (Listening + Learning).

🔒 Port-security

  • Activer : switchport port-security
  • Nombre max de MAC : switchport port-security maximum 2
  • Action en cas de violation :
    • shutdown : le port est désactivé (erreur-disabled).
    • restrict : les paquets sont rejetés, mais le port reste actif (logs).
    • protect : les paquets sont rejetés sans logs.
  • MAC adresses dynamiques (sticky) : switchport port-security mac-address sticky (apprend et sauvegarde les MAC).
  • Afficher : show port-security, show port-security address

🔗 EtherChannel (Agrégation de liens)

  • Rôle : regrouper plusieurs liens physiques en un seul lien logique (augmente la bande passante et la redondance).
  • Protocoles :
    • PAgP : propriétaire Cisco (Port Aggregation Protocol).
    • LACP : standard IEEE 802.3ad.
  • Configuration LACP :
    Switch(config)# interface range fastEthernet 0/1-2
    Switch(config-if-range)# channel-group 1 mode active
    Switch(config-if-range)# exit
    Switch(config)# interface port-channel 1
    Switch(config-if)# switchport mode trunk
  • Vérifier : show etherchannel summary

🛠️ Mise en pratique

Configuration complète d'un switch (VLAN, trunk, STP, port-security, EtherChannel)

Exemple complet :

Switch# configure terminal
Switch(config)# hostname SW1
SW1(config)# vlan 10
SW1(config-vlan)# name IT
SW1(config-vlan)# vlan 20
SW1(config-vlan)# name RH
SW1(config-vlan)# exit

SW1(config)# interface range fastEthernet 0/1-10
SW1(config-if-range)# switchport mode access
SW1(config-if-range)# switchport access vlan 10
SW1(config-if-range)# spanning-tree portfast
SW1(config-if-range)# spanning-tree bpduguard enable
SW1(config-if-range)# switchport port-security
SW1(config-if-range)# switchport port-security maximum 1
SW1(config-if-range)# switchport port-security violation shutdown
SW1(config-if-range)# exit

SW1(config)# interface fastEthernet 0/24
SW1(config-if)# switchport mode trunk
SW1(config-if)# switchport trunk allowed vlan 10,20
SW1(config-if)# switchport trunk native vlan 99
SW1(config-if)# exit

SW1(config)# interface range fastEthernet 0/22-23
SW1(config-if-range)# channel-group 1 mode active
SW1(config-if-range)# exit
SW1(config)# interface port-channel 1
SW1(config-if)# switchport mode trunk
SW1(config-if)# end

SW1# write memory
  • Création des VLAN 10 et 20.
  • Ports 1 à 10 : accès VLAN 10, Portfast, BPDUguard, port-security à 1 MAC.
  • Port 24 : trunk autorisant VLAN 10 et 20, VLAN natif 99.
  • Ports 22-23 : EtherChannel LACP, trunk sur le port-channel.

📝 Exercices d'application

Exercice 1 – Port-security

Quelle commande active la sécurisation d'un port avec une seule MAC autorisée ?

switchport port-security ; switchport port-security maximum 1

Exercice 2 – EtherChannel

Quel protocole standard permet l'agrégation de liens ?

LACP (IEEE 802.3ad)

🎯 Quiz d'auto‑évaluation

1. La commande spanning-tree portfast :

2. BPDUguard désactive un port s'il reçoit :

3. La commande switchport trunk allowed vlan 10,20 :

4. Un port en état "err-disabled" suite à une violation port-security peut être réactivé avec :

5. EtherChannel avec LACP utilise le mode :

📚 Ressources