TP Sécurité PME - ACL / 802.1X / Guest VLAN

Contexte : Authentification 802.1X, ACL dynamiques, Guest VLAN, port-security sur switch Cisco.

60-120 min Niveau : PME avancé IEEE 802.1X
Usage PME : ce module sert à produire une configuration documentée, testée et réutilisable. Il peut être utilisé pour préparer un déploiement, auditer une infrastructure existante ou standardiser une intervention technique.
🔥 Parcours sécurité PME :
1. VLAN & segmentation → 2. Firewall & filtrage → 3. VPN site-à-site → 4. Wi‑Fi sécurisé → 5. 802.1X & contrôle d’accès.
Ce fichier correspond au module 5.
Scénario PME : un poste inconnu, un équipement personnel ou du Shadow IT ne doit pas obtenir automatiquement un accès au VLAN interne.

Objectif opérationnel PME

1
Configurer FreeRADIUS
2
Configurer 802.1X sur switch
3
Configurer Guest VLAN
4
Tester l'authentification
┌─────────────────────────────────────────────────────────────────────────────┐ │ ARCHITECTURE 802.1X │ │ │ │ ┌─────────────┐ ┌─────────────────────────────────────────────────┐ │ │ │ Client │ │ SWITCH 802.1X │ │ │ │ (Supplicant)├──────►│ ┌─────────────────────────────────────────┐ │ │ │ │ user1 │ │ │ Port 1 : 802.1X authenticator │ │ │ │ └─────────────┘ │ │ • Auth OK → VLAN 10 (CORPO) │ │ │ │ │ │ • Auth FAIL → VLAN 30 (GUEST) │ │ │ │ ┌─────────────┐ │ │ • Auth timeout → VLAN 99 (RESTRICTED) │ │ │ │ │ Client │ │ └─────────────────────────────────────────┘ │ │ │ │ (Guest) │ │ │ │ │ │ │ sans auth ├──────►│ │ │ │ │ └─────────────┘ │ │ RADIUS (1812/1813) │ │ │ │ ▼ │ │ │ │ ┌─────────────────────────────────────────┐ │ │ │ │ │ SERVEUR RADIUS (FreeRADIUS/NPS) │ │ │ │ │ │ • user1 → VLAN 10 (CORPO) │ │ │ │ │ │ • user2 → VLAN 10 (CORPO) │ │ │ │ │ │ • autre → VLAN 30 (GUEST) │ │ │ │ │ └─────────────────────────────────────────┘ │ │ │ └─────────────────────────────────────────────────┘ │ │ │ │ 📌 ACL sur VLAN GUEST : HTTP/HTTPS uniquement, logs activés │ │ 📌 Port-security : maximum 2 MAC addresses, action shutdown │ └─────────────────────────────────────────────────────────────────────────────┘
📡 Plan d'adressage :
• VLAN 10 (CORPO) : 10.0.10.0/24 - Authentification OK → accès complet
• VLAN 30 (GUEST) : 10.0.30.0/24 - Échec auth → HTTP/HTTPS uniquement
• VLAN 99 (BLACKHOLE) : 10.0.99.0/24 - Timeout / port-security → aucun trafic

Prérequis

  • ✓ Switch Cisco (ou tout switch supportant 802.1X)
  • ✓ Serveur Linux pour FreeRADIUS (ou Windows Server pour NPS)
  • ✓ Client Windows/Linux avec supplicant 802.1X
  • ✓ GNS3 / EVE-NG pour simulation (ou matériel réel)

Architecture des VLANs et règles

VLANIDUsageConditionsACL / Restrictions
CORPO 10 Postes authentifiés 802.1X OK Accès complet réseau
GUEST 30 Non authentifiés 802.1X FAIL HTTP/HTTPS uniquement + logs
BLACKHOLE 99 Ports suspects 802.1X timeout / MAC inconnue Aucun trafic, alerte syslog

Étape 1 : Configuration FreeRADIUS

FreeRADIUS est le serveur RADIUS open source le plus utilisé.

Installation FreeRADIUS

sudo apt update
sudo apt install freeradius freeradius-utils -y

# Vérifier l'installation
sudo systemctl status freeradius

Configuration des clients (switch)

# /etc/freeradius/3.0/clients.conf
# Ajouter le switch comme client RADIUS
client switch {
    ipaddr = 192.168.1.100
    secret = testing123
    shortname = switch
    nastype = cisco
}

# Redémarrer FreeRADIUS
sudo systemctl restart freeradius

Configuration des utilisateurs et VLANs dynamiques

# /etc/freeradius/3.0/users
# Utilisateurs avec assignation de VLAN
user1 Cleartext-Password := "password1"
    Tunnel-Type = VLAN,
    Tunnel-Medium-Type = IEEE-802,
    Tunnel-Private-Group-Id = 10

user2 Cleartext-Password := "password2"
    Tunnel-Type = VLAN,
    Tunnel-Medium-Type = IEEE-802,
    Tunnel-Private-Group-Id = 10

# Fallback pour les échecs d'authentification
DEFAULT Auth-Type := Reject
    Tunnel-Type = VLAN,
    Tunnel-Medium-Type = IEEE-802,
    Tunnel-Private-Group-Id = 30

# Tester localement
sudo radtest user1 password1 localhost 0 testing123

Étape 2 : Configuration du switch Cisco 802.1X

⚠️ Configuration RADIUS et 802.1X sur le switch.
enable
configure terminal
!
# Configuration RADIUS
radius-server host 192.168.1.200 key testing123
radius-server timeout 5
radius-server retransmit 2
!
# AAA
aaa new-model
aaa authentication dot1x default group radius
aaa authorization network default group radius
!
# VLANs
vlan 10
 name CORPO
!
vlan 30
 name GUEST
!
vlan 99
 name BLACKHOLE
!
# 802.1X global
dot1x system-auth-control
!
# Interface configurée pour 802.1X
interface fastEthernet 0/1
 switchport mode access
 switchport access vlan 10
 authentication port-control auto
 authentication periodic
 authentication timer reauthenticate 3600
 dot1x pae authenticator
 dot1x timeout tx-period 10
 dot1x max-reauth-req 2
!
# Guest VLAN (en cas d'échec)
interface fastEthernet 0/1
 authentication event fail action next-method
 authentication event server dead action authorize vlan 30
 authentication event no-response action authorize vlan 99
!
# Port-security (limite MAC)
interface fastEthernet 0/1
 switchport port-security
 switchport port-security maximum 2
 switchport port-security violation shutdown
 switchport port-security aging time 60
!
# Vérifications
show dot1x all
show authentication sessions
show port-security
exit

Étape 3 : Configuration du client (Supplicant)

# Windows 10/11 - Configuration 802.1X
# 1. Ouvrir "Services" → "Wired AutoConfig" → Démarrer (Type: Automatique)

# 2. Panneau de configuration → Centre Réseau et partage → Modifier les paramètres de la carte

# 3. Clic droit sur Ethernet → Propriétés → Authentification

# 4. Cocher "Activer l'authentification IEEE 802.1X"
#    - Choisir "Authentification par mot de passe protégé (EAP-MSCHAP v2)"
#    - Décocher "Authentifier en tant qu'invité"

# 5. Paramètres supplémentaires → Spécifier le mode d'authentification : "Authentification utilisateur"

# 6. Redémarrer la carte réseau
netsh interface set interface "Ethernet" admin=disable
netsh interface set interface "Ethernet" admin=enable
# Installation wpa_supplicant
sudo apt install wpasupplicant -y

# Configuration /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=/run/wpa_supplicant
network={
    key_mgmt=IEEE8021X
    eap=PEAP
    identity="user1"
    password="password1"
    phase2="auth=MSCHAPV2"
}

# Démarrer wpa_supplicant
sudo wpa_supplicant -i eth0 -c /etc/wpa_supplicant/wpa_supplicant.conf -B

# Vérifier l'authentification
sudo wpa_cli status
# macOS - Configuration 802.1X
# Préférences Système → Réseau → Ethernet → Avancé → 802.1X
# Créer une nouvelle configuration
# - Authentification: PEAP
# - Identifiant: user1
# - Mot de passe: password1
# - Décocher "Authentifier en tant qu'invité"

Étape 4 : ACL pour le VLAN GUEST

Les ACL limitent l'accès des clients non authentifiés.
configure terminal
!
# ACL pour VLAN GUEST
ip access-list extended ACL-GUEST
 deny ip any 10.0.0.0 0.255.255.255
 permit tcp any any eq 80
 permit tcp any any eq 443
 permit udp any any eq 53
 deny ip any any log
!
# Appliquer l'ACL sur l'interface VLAN 30
interface vlan 30
 ip access-group ACL-GUEST in
!
# Vérifier l'ACL
show access-lists ACL-GUEST

📦 LIVRABLES PME À PRODUIRE

Ces livrables servent à valider et documenter une configuration exploitable en PME. Cliquez sur chaque bouton pour copier le contenu.

📦 Livrable 1 : Fichier .gns3

Topologie : switch Cisco + FreeRADIUS + clients test.

{
  "name": "TP_8021X_Security",
  "version": "2.2.0",
  "topology": {
    "nodes": [
      {"node_id": "sw", "name": "Switch_8021X", "node_type": "qemu", "x": 200, "y": 200, "properties": {"image": "vios_l2-adventerprisek9-m-15.2.iso"}},
      {"node_id": "radius", "name": "FreeRADIUS_Server", "node_type": "qemu", "x": 500, "y": 200, "properties": {"image": "ubuntu-22.04-server-cloudimg-amd64.img"}},
      {"node_id": "client1", "name": "Client_Auth_OK", "node_type": "vpcs", "x": -100, "y": 100, "properties": {"script": "ip 10.0.10.10/24 10.0.10.254"}},
      {"node_id": "client2", "name": "Client_Guest", "node_type": "vpcs", "x": -100, "y": 200, "properties": {"script": "ip 10.0.30.10/24 10.0.30.254"}}
    ],
    "links": [
      {"nodes": [{"node_id": "sw","adapter":0,"port":1},{"node_id": "client1","adapter":0,"port":0}]},
      {"nodes": [{"node_id": "sw","adapter":0,"port":2},{"node_id": "client2","adapter":0,"port":0}]},
      {"nodes": [{"node_id": "sw","adapter":0,"port":24},{"node_id": "radius","adapter":0,"port":0}]}
    ]
  }
}

🐍 Livrable 2 : Script Python

Testeur RADIUS + vérification VLAN dynamique + rapport.

Installation : pip install colorama pyrad

Utilisation : python3 radius_tester.py --menu

#!/usr/bin/env python3
# radius_tester.py - Testeur RADIUS et 802.1X

import subprocess, sys, argparse, socket
from datetime import datetime
try:
    from colorama import init, Fore, Style
    init()
except:
    class Fore: RED=GREEN=YELLOW=CYAN=RESET=''

class RADIUSTester:
    def __init__(self):
        self.results = []
        self.config = {
            "radius_server": "192.168.1.200",
            "radius_secret": "testing123",
            "users": [
                {"user": "user1", "pass": "password1", "expected_vlan": 10, "expected_auth": "ALLOW"},
                {"user": "user2", "pass": "password2", "expected_vlan": 10, "expected_auth": "ALLOW"},
                {"user": "invalid", "pass": "wrong", "expected_vlan": 30, "expected_auth": "REJECT"}
            ]
        }
    
    def test_radius(self, username, password):
        """Teste l'authentification RADIUS avec radtest"""
        try:
            result = subprocess.run(
                ['radtest', username, password, self.config["radius_server"], '0', self.config["radius_secret"]],
                capture_output=True, text=True, timeout=5
            )
            if "Access-Accept" in result.stdout:
                return True, result.stdout
            else:
                return False, result.stdout
        except Exception as e:
            return False, str(e)
    
    def test_dot1x_status(self):
        """Vérifie l'état 802.1X sur le switch"""
        try:
            result = subprocess.run(['show', 'dot1x', 'all'], capture_output=True, text=True, timeout=5)
            return result.stdout
        except:
            return "Commande non disponible"
    
    def run(self):
        print(f"{Fore.CYAN}🔍 Test des authentifications RADIUS...{Fore.RESET}\n")
        
        for user in self.config["users"]:
            success, output = self.test_radius(user["user"], user["pass"])
            passed = (success and user["expected_auth"] == "ALLOW") or (not success and user["expected_auth"] == "REJECT")
            self.results.append({**user, "auth_success": success, "passed": passed})
            status = f"{Fore.GREEN}✓{Fore.RESET}" if passed else f"{Fore.RED}✗{Fore.RESET}"
            print(f"{status} {user['user']}: {'✅ ACCEPT' if success else '❌ REJECT'} (attendu: {user['expected_auth']})")
        
        return self.results
    
    def html_report(self, filename="radius_report.html"):
        passed = sum(1 for r in self.results if r['passed'])
        total = len(self.results)
        score = (passed/total)*100 if total>0 else 0
        html = f"""TP 5 — 802.1X, ACL & Dynamic VLAN | CyberRéseau Pro

📊 Rapport 802.1X / RADIUS

Date: {datetime.now()}

Score: {score:.1f}% ({passed}/{total})
""" for r in self.results: html += f"" html += "
UtilisateurAuthentificationVLAN attenduStatut
{r['user']}{'✅ ACCEPT' if r['auth_success'] else '❌ REJECT'}{r['expected_vlan']}" html += f"{'✅ OK' if r['passed'] else '❌ ÉCHEC'}

Généré par RADIUS Tester | CyberRéseau Pro

Validation opérationnelle PME

Avant de considérer ce module comme exploitable, vérifiez les points suivants :

  • La configuration est sauvegardée et datée.
  • Les flux autorisés et bloqués sont documentés.
  • Les tests de connectivité et d’isolation sont réalisés.
  • Les captures ou rapports sont archivés comme preuves techniques.
  • Les risques résiduels sont notés pour une action ultérieure.
Point critique : une configuration non testée donne une fausse impression de sécurité. Le test fait partie du livrable.

🚀 Accéder au pack complet

Ce module fait partie du Pack TP Sécurité Réseau PME. Remplacez le lien ci-dessous par votre lien Gumroad après publication.

Acheter / télécharger le pack Voir la page du pack
" with open(filename, 'w', encoding='utf-8') as f: f.write(html) print(f"{Fore.GREEN}📄 Rapport généré: {filename}{Fore.RESET}") def menu(self): while True: print(f"\n{Fore.CYAN}════════════════════════════════════════╗{Fore.RESET}") print(f"{Fore.CYAN} TESTEUR 802.1X / RADIUS{Fore.RESET}") print(f"{Fore.CYAN}════════════════════════════════════════╝{Fore.RESET}") print("1. 🔍 Lancer tests RADIUS") print("2. 📄 Générer rapport HTML") print("3. 🚪 Quitter") choice = input(f"{Fore.YELLOW}Votre choix : {Fore.RESET}") if choice == '1': self.run() elif choice == '2': if self.results: self.html_report() else: print("Lancez d'abord les tests") elif choice == '3': break if __name__ == "__main__": tester = RADIUSTester() if len(sys.argv) > 1 and '--menu' in sys.argv: tester.menu() else: tester.run() tester.html_report()

🔧 Livrable 3 : Script Bash

Diagnostic RADIUS, logs, état 802.1X, checklist.

Utilisation : chmod +x diagnostic_8021x.sh && ./diagnostic_8021x.sh --all

#!/bin/bash
RAPPORT="dot1x_diag_$(date +%Y%m%d_%H%M%S).txt"
GREEN='\033[0;32m'; RED='\033[0;31m'; YELLOW='\033[1;33m'; CYAN='\033[0;36m'; NC='\033[0m'

log() { echo -e "$1" | tee -a "$RAPPORT"; }
log_header() { echo ""; log "${CYAN}═══════════════════════════════════════${NC}"; log "$1"; log "${CYAN}═══════════════════════════════════════${NC}"; }

check_radius() {
    log_header "État FreeRADIUS"
    sudo systemctl status freeradius --no-pager | tee -a "$RAPPORT"
    log "\n--- Clients RADIUS ---"
    cat /etc/freeradius/3.0/clients.conf | grep -E "^client|ipaddr|secret" | tee -a "$RAPPORT"
}

test_radius_radtest() {
    log_header "Tests RADIUS"
    radtest user1 password1 localhost 0 testing123 2>&1 | tee -a "$RAPPORT"
}

check_dot1x_switch() {
    log_header "État 802.1X sur le switch"
    if command -v show &>/dev/null; then
        show dot1x all 2>/dev/null | tee -a "$RAPPORT"
        show authentication sessions 2>/dev/null | tee -a "$RAPPORT"
    fi
}

check_radius_logs() {
    log_header "Logs RADIUS"
    sudo tail -30 /var/log/freeradius/radius.log | tee -a "$RAPPORT"
}

checklist() {
    log_header "CHECKLIST 802.1X / RADIUS"
    cat >> "$RAPPORT" << 'EOF'
□ 1. FreeRADIUS installé et configuré
□ 2. Client RADIUS ajouté (switch avec secret)
□ 3. Utilisateurs configurés dans /etc/freeradius/3.0/users
□ 4. Attibuts Tunnel-Private-Group-Id définis (VLAN dynamique)
□ 5. Switch: AAA et RADIUS configurés
□ 6. 802.1X activé sur le port (dot1x system-auth-control)
□ 7. Guest VLAN configuré pour les échecs
□ 8. Port-security activé (max 2 MACs)
□ 9. ACL sur VLAN Guest pour limiter l'accès
□ 10. Client capable de s'authentifier (wpa_supplicant)
□ 11. Test raduser OK depuis le serveur
□ 12. Authentification réussie depuis le client
EOF
    cat "$RAPPORT" | tail -20
}

auto_mode() {
    log_header "DIAGNOSTIC 802.1X AUTOMATIQUE"
    check_radius
    test_radius_radtest
    check_radius_logs
    check_dot1x_switch
    checklist
    echo -e "${GREEN}✓ Rapport sauvegardé: $RAPPORT${NC}"
}

show_menu() {
    echo ""; echo -e "${CYAN}═══════════════════════════════════════${NC}"
    echo -e "      DIAGNOSTIC 802.1X / RADIUS"
    echo -e "${CYAN}═══════════════════════════════════════${NC}"
    echo "1. 🔍 Diagnostic complet"
    echo "2. 🔐 Vérifier FreeRADIUS"
    echo "3. 📡 Tester radtest"
    echo "4. 📋 Afficher checklist"
    echo "5. 🚪 Quitter"
    echo -n "Votre choix : "
}

if [ "$1" == "--all" ] || [ "$1" == "-a" ]; then
    auto_mode
else
    while true; do
        show_menu; read choice
        case $choice in
            1) auto_mode ;;
            2) check_radius | tee -a "$RAPPORT" ;;
            3) test_radius_radtest | tee -a "$RAPPORT" ;;
            4) checklist ;;
            5) echo -e "${GREEN}Au revoir !${NC}"; exit 0 ;;
            *) echo -e "${RED}Choix invalide${NC}" ;;
        esac
    done
fi

Installation et utilisation

# 1. Rendre les scripts exécutables
chmod +x radius_tester.py
chmod +x diagnostic_8021x.sh

# 2. Installer les dépendances Python
pip3 install colorama pyrad

# 3. Lancer le test interactif
python3 radius_tester.py --menu

# 4. Lancer le diagnostic bash
./diagnostic_8021x.sh --all

# 5. Démarrer FreeRADIUS en mode debug
sudo freeradius -X

Erreurs fréquentes & solutions

ErreurPourquoi ?Solution
Access-Reject Mauvais mot de passe / utilisateur inexistant Vérifier le fichier /etc/freeradius/3.0/users
No response Switch ne contacte pas le RADIUS server Vérifier l'IP du serveur et le secret dans clients.conf
guest-vlan actif Authentification échouée Client VLAN 30 → vérifier logs RADIUS
Port shutdown Port-security dépassé shutdown / no shutdown sur l'interface
IP 169.254.x.x Pas de DHCP après auth OK Vérifier serveur DHCP sur VLAN 10

Tests de validation

#TestCommandeRésultat attendu
1 radtest local radtest user1 password1 localhost 0 testing123 Access-Accept
2