Un module pratique complet pour créer une segmentation réseau PME propre : VLANs, ports access, trunk 802.1Q, routage inter-VLAN, DHCP, tests d’isolation, dépannage et livrables prêts à produire.
L’objectif est de segmenter le réseau d’une PME afin de séparer les flux administratifs, utilisateurs et invités. Le TP commence par une isolation de niveau 2, puis propose une extension avec routage inter-VLAN contrôlé.
| VLAN | Nom | Rôle | Réseau | Passerelle | Port |
|---|---|---|---|---|---|
| 10 | ADMIN | Administration, imprimantes, supervision | 192.168.10.0/24 | 192.168.10.254 | Fa0/1 |
| 20 | USERS | Postes utilisateurs | 192.168.20.0/24 | 192.168.20.254 | Fa0/2 |
| 30 | GUEST | Invités / Wi‑Fi invité | 192.168.30.0/24 | 192.168.30.254 | Fa0/3 |
| 99 | NATIVE-MGMT | Native VLAN / management | 192.168.99.0/24 | 192.168.99.254 | Trunk |
enable configure terminal hostname SW-PME-01 no ip domain-lookup ! vlan 99 name NATIVE-MGMT exit
vlan 10 name ADMIN exit vlan 20 name USERS exit vlan 30 name GUEST exit show vlan brief
interface fastEthernet 0/1 description PC_ADMIN switchport mode access switchport access vlan 10 spanning-tree portfast exit ! interface fastEthernet 0/2 description PC_USER switchport mode access switchport access vlan 20 spanning-tree portfast exit ! interface fastEthernet 0/3 description PC_GUEST switchport mode access switchport access vlan 30 spanning-tree portfast exit
interface fastEthernet 0/24 description TRUNK_VERS_ROUTEUR_FIREWALL switchport mode trunk switchport trunk native vlan 99 switchport trunk allowed vlan 10,20,30,99 exit show interfaces trunk
show vlan brief show interfaces trunk show interfaces status show mac address-table dynamic
Le routeur reçoit le trunk, crée une sous-interface par VLAN et distribue les adresses via DHCP.
enable configure terminal hostname R-PME-01 ! interface g0/0 no shutdown exit ! interface g0/0.10 encapsulation dot1Q 10 ip address 192.168.10.254 255.255.255.0 exit ! interface g0/0.20 encapsulation dot1Q 20 ip address 192.168.20.254 255.255.255.0 exit ! interface g0/0.30 encapsulation dot1Q 30 ip address 192.168.30.254 255.255.255.0 exit ! interface g0/0.99 encapsulation dot1Q 99 native ip address 192.168.99.254 255.255.255.0 exit
ip dhcp excluded-address 192.168.10.1 192.168.10.20 ip dhcp excluded-address 192.168.20.1 192.168.20.20 ip dhcp excluded-address 192.168.30.1 192.168.30.20 ! ip dhcp pool VLAN10_ADMIN network 192.168.10.0 255.255.255.0 default-router 192.168.10.254 dns-server 1.1.1.1 8.8.8.8 exit ! ip dhcp pool VLAN20_USERS network 192.168.20.0 255.255.255.0 default-router 192.168.20.254 dns-server 1.1.1.1 8.8.8.8 exit ! ip dhcp pool VLAN30_GUEST network 192.168.30.0 255.255.255.0 default-router 192.168.30.254 dns-server 1.1.1.1 8.8.8.8 exit
ip access-list extended GUEST_OUT deny ip 192.168.30.0 0.0.0.255 192.168.10.0 0.0.0.255 deny ip 192.168.30.0 0.0.0.255 192.168.20.0 0.0.0.255 permit ip 192.168.30.0 0.0.0.255 any exit ! interface g0/0.30 ip access-group GUEST_OUT in exit show access-lists
La logique reste identique : VLAN, port untagged/access, trunk/tagged.
vlan 10 name ADMIN vlan 20 name USERS vlan 30 name GUEST vlan 99 name NATIVE-MGMT ! interface gigabitEthernet 0/1 switchport mode access switchport access vlan 10 ! interface gigabitEthernet 0/2 switchport mode access switchport access vlan 20 ! interface gigabitEthernet 0/3 switchport mode access switchport access vlan 30 ! interface gigabitEthernet 0/24 switchport mode trunk switchport trunk native vlan 99 switchport trunk allowed vlan 10,20,30,99
vlan 10 name "ADMIN" untagged 1 exit vlan 20 name "USERS" untagged 2 exit vlan 30 name "GUEST" untagged 3 exit vlan 99 name "NATIVE-MGMT" exit vlan 10,20,30 tagged 24 vlan 99 untagged 24
vlan 10 description ADMIN port gigabitEthernet 1/0/1 vlan 20 description USERS port gigabitEthernet 1/0/2 vlan 30 description GUEST port gigabitEthernet 1/0/3 interface gigabitEthernet 1/0/24 port link-type trunk port trunk permit vlan 10 20 30 99
# UniFi Network — logique 1. Settings → Networks → Create New Network 2. ADMIN : VLAN ID 10 3. USERS : VLAN ID 20 4. GUEST : VLAN ID 30 5. Port PC_ADMIN : Native Network ADMIN 6. Port PC_USER : Native Network USERS 7. Port PC_GUEST : Native Network GUEST 8. Port trunk vers firewall : Tagged VLANs 10,20,30
| Concept | Cisco | Aruba | HP/Comware | UniFi |
|---|---|---|---|---|
| Port utilisateur | access | untagged | access | Native Network |
| Trunk | trunk | tagged | trunk | Tagged VLANs |
| Native VLAN | native vlan | untagged sur trunk | PVID | Native Network |
| # | Source | Destination | Commande | Avant routage | Après routage | Après ACL Guest |
|---|---|---|---|---|---|---|
| 1 | ADMIN | Passerelle ADMIN | ping 192.168.10.254 | — | ✅ OK | ✅ OK |
| 2 | USERS | Passerelle USERS | ping 192.168.20.254 | — | ✅ OK | ✅ OK |
| 3 | GUEST | Passerelle GUEST | ping 192.168.30.254 | — | ✅ OK | ✅ OK |
| 4 | ADMIN | USERS | ping 192.168.20.10 | ❌ KO | ✅ OK | ✅ OK |
| 5 | GUEST | ADMIN | ping 192.168.10.10 | ❌ KO | ✅ OK | ❌ KO |
| 6 | GUEST | USERS | ping 192.168.20.10 | ❌ KO | ✅ OK | ❌ KO |
show vlan brief show interfaces trunk show interfaces status show mac address-table dynamic show running-config interface fa0/24
show ip interface brief show ip route show access-lists ping 192.168.10.254 traceroute 192.168.20.10 tcpdump -i eth0 -n vlan 10
| Symptôme | Cause probable | Vérification | Correction |
|---|---|---|---|
| PC sans IP | DHCP absent ou VLAN incorrect | show vlan brief / ipconfig | Corriger port access et pool DHCP |
| Trunk KO | Mode trunk absent / VLAN non autorisé | show interfaces trunk | Ajouter VLANs autorisés |
| Inter-VLAN impossible | Sous-interface ou passerelle manquante | show ip int brief | Créer g0/0.X |
| Guest accède à ADMIN | ACL absente ou mal appliquée | show access-lists | Appliquer ACL en entrée sur VLAN30 |
Ces livrables ne sont pas pensés comme des devoirs scolaires : ils servent à documenter une segmentation réseau exploitable en PME. Chaque bouton permet de copier rapidement le contenu technique.
Une base GNS3 pour simuler le réseau avant passage en production.
Un contrôle clair de l’isolation VLAN et des flux autorisés.
Des scripts pour accélérer la validation et garder une trace.
Topologie prête à l'emploi pour GNS3. À importer via File → Import portable project.
{
"name": "TP_VLAN_Segmentation_PME",
"version": "2.2.0",
"topology": {
"nodes": [
{"node_id": "node1", "name": "Switch_Main", "node_type": "ethernet_switch", "x": 100, "y": 200, "properties": {"ethernet_ports": 24}},
{"node_id": "node2", "name": "Router_ROAS", "node_type": "qemu", "x": 500, "y": 200, "properties": {"image": "vios-adventerprisek9-m-15.6.1T.iso"}},
{"node_id": "node3", "name": "PC_ADMIN", "node_type": "vpcs", "x": -150, "y": 100, "properties": {"script": "ip 192.168.10.10/24 192.168.10.254"}},
{"node_id": "node4", "name": "PC_USER", "node_type": "vpcs", "x": -150, "y": 200, "properties": {"script": "ip 192.168.20.10/24 192.168.20.254"}},
{"node_id": "node5", "name": "PC_GUEST", "node_type": "vpcs", "x": -150, "y": 300, "properties": {"script": "ip 192.168.30.10/24 192.168.30.254"}}
],
"links": [
{"link_id": "link1", "nodes": [{"node_id": "node1", "adapter_number": 0, "port_number": 1}, {"node_id": "node3", "adapter_number": 0, "port_number": 0}]},
{"link_id": "link2", "nodes": [{"node_id": "node1", "adapter_number": 0, "port_number": 2}, {"node_id": "node4", "adapter_number": 0, "port_number": 0}]},
{"link_id": "link3", "nodes": [{"node_id": "node1", "adapter_number": 0, "port_number": 3}, {"node_id": "node5", "adapter_number": 0, "port_number": 0}]},
{"link_id": "link4", "nodes": [{"node_id": "node1", "adapter_number": 0, "port_number": 24}, {"node_id": "node2", "adapter_number": 0, "port_number": 0}]}
]
}
}
Testeur automatique de VLANs : isolation, connectivité et génération d’un rapport HTML exploitable par une PME.
Installation : pip install colorama
Utilisation : python3 vlan_tester.py --menu ou python3 vlan_tester.py --auto config.json
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Testeur automatique de VLANs - CyberRéseau Pro
Usage PME : vérifier l'isolation, la connectivité et générer un rapport HTML.
"""
import subprocess
import sys
import json
import argparse
from datetime import datetime
try:
from colorama import init, Fore, Style
init()
except ImportError:
class Fore:
RED = GREEN = YELLOW = CYAN = RESET = ''
Style = Fore
class VLAN_Tester:
def __init__(self, config_file=None):
self.results = []
self.config = self._load_config(config_file) if config_file else self._default_config()
def _default_config(self):
return {
"vlans": {
"ADMIN": {"id": 10, "network": "192.168.10.0/24", "gateway": "192.168.10.254", "test_ip": "192.168.10.10"},
"USERS": {"id": 20, "network": "192.168.20.0/24", "gateway": "192.168.20.254", "test_ip": "192.168.20.10"},
"GUEST": {"id": 30, "network": "192.168.30.0/24", "gateway": "192.168.30.254", "test_ip": "192.168.30.10"}
},
"expected_isolation": {
"ADMIN": {"USERS": False, "GUEST": True},
"USERS": {"ADMIN": True, "GUEST": True},
"GUEST": {"ADMIN": True, "USERS": True}
}
}
def _load_config(self, config_file):
with open(config_file, 'r', encoding='utf-8') as f:
return json.load(f)
def ping_host(self, ip, count=2, timeout=2):
param = '-n' if sys.platform.lower().startswith('win') else '-c'
timeout_param = '-w' if sys.platform.lower().startswith('win') else '-W'
try:
result = subprocess.run(
['ping', param, str(count), timeout_param, str(timeout), ip],
capture_output=True, text=True, timeout=timeout + 3
)
return result.returncode == 0
except Exception:
return False
def run_tests(self):
self.results = []
vlans = self.config['vlans']
expected = self.config['expected_isolation']
print(f"{Fore.CYAN}🔍 Démarrage des tests VLAN PME...{Style.RESET_ALL}")
print(f"📅 {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n")
for src_name, src_data in vlans.items():
for dst_name, dst_data in vlans.items():
if src_name == dst_name:
continue
dst_ip = dst_data['test_ip']
expected_isolated = expected.get(src_name, {}).get(dst_name, True)
can_ping = self.ping_host(dst_ip)
actual_isolated = not can_ping
passed = (actual_isolated == expected_isolated)
self.results.append({
"source": src_name,
"destination": dst_name,
"destination_ip": dst_ip,
"expected_isolated": expected_isolated,
"actual_isolated": actual_isolated,
"passed": passed
})
status = f"{Fore.GREEN}✓{Style.RESET_ALL}" if passed else f"{Fore.RED}✗{Style.RESET_ALL}"
real = "ISOLÉ" if actual_isolated else "CONNEXION"
print(f" {status} {src_name} → {dst_name}: {real}")
return self.results
def generate_html_report(self, filename="rapport_vlan_pme.html"):
passed = sum(1 for r in self.results if r['passed'])
total = len(self.results)
score = (passed / total) * 100 if total else 0
html = f"""
TP 1 — Segmentation VLAN PME | CyberRéseau Pro
📊 Rapport de test VLAN PME
Date : {datetime.now().strftime('%d/%m/%Y à %H:%M:%S')}
Score : {score:.1f}% ({passed}/{total})
Source Destination IP destination Attendu Réel Statut
"""
for r in self.results:
html += f"{r['source']} {r['destination']} {r['destination_ip']} "
html += f"{'ISOLÉ' if r['expected_isolated'] else 'CONNEXION'} "
html += f"{'ISOLÉ' if r['actual_isolated'] else 'CONNEXION'} "
html += f"{'✓ OK' if r['passed'] else '✗ À corriger'} "
html += "
Généré par VLAN Tester | CyberRéseau Pro
🎓 Continuer le parmodule sécurité PME
Ce module fait partie du Pack TP Sécurité Réseau : VLAN, firewall, VPN, Wi‑Fi sécurisé et 802.1X. L’objectif est de passer d’une configuration isolée à une démarche complète de sécurisation PME.
Voir tout le Pack TP
Télécharger le guide gratuit
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.
"
with open(filename, 'w', encoding='utf-8') as f:
f.write(html)
print(f"{Fore.GREEN}📄 Rapport généré : {filename}{Style.RESET_ALL}")
return filename
def run_menu(self):
while True:
print(f"\n{Fore.CYAN}=== TESTEUR AUTOMATIQUE VLAN PME ==={Style.RESET_ALL}")
print("1. 🔍 Lancer les tests")
print("2. 📄 Générer rapport HTML")
print("3. 🚪 Quitter")
choice = input(f"{Fore.YELLOW}Votre choix : {Style.RESET_ALL}")
if choice == '1':
self.run_tests()
elif choice == '2':
if self.results:
self.generate_html_report()
else:
print(f"{Fore.YELLOW}⚠️ Lancez d'abord les tests{Style.RESET_ALL}")
elif choice == '3':
break
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--menu', action='store_true')
parser.add_argument('--auto', type=str)
args = parser.parse_args()
tester = VLAN_Tester(args.auto if args.auto else None)
if args.menu or len(sys.argv) == 1:
tester.run_menu()
else:
tester.run_tests()
tester.generate_html_report()
if __name__ == "__main__":
main()
Diagnostic automatique des VLANs et génération d’un rapport texte pour audit interne.
Utilisation : chmod +x diagnostic_vlan.sh && ./diagnostic_vlan.sh --all
#!/bin/bash
RAPPORT="rapport_diag_vlan_pme_$(date +%Y%m%d_%H%M%S).txt"
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m'
log() { echo -e "$1" | tee -a "$RAPPORT"; }
log_header() {
echo "" | tee -a "$RAPPORT"
log "${YELLOW}═══════════════════════════════════════${NC}"
log "$1"
log "${YELLOW}═══════════════════════════════════════${NC}"
}
show_network_state() {
log_header "État réseau local"
ip addr show | tee -a "$RAPPORT"
echo "" | tee -a "$RAPPORT"
ip route show | tee -a "$RAPPORT"
}
check_gateways() {
log_header "Tests des passerelles VLAN"
for ip in 192.168.10.254 192.168.20.254 192.168.30.254; do
if ping -c 2 -W 1 "$ip" &>/dev/null; then
log "${GREEN}✓ Passerelle joignable : $ip${NC}"
else
log "${RED}✗ Passerelle non joignable : $ip${NC}"
fi
done
}
check_isolation() {
log_header "Test d'isolation VLAN"
local ips=("192.168.10.10:ADMIN" "192.168.20.10:USERS" "192.168.30.10:GUEST")
for src in "${ips[@]}"; do
src_ip="${src%:*}"
src_name="${src#*:}"
for dst in "${ips[@]}"; do
dst_ip="${dst%:*}"
dst_name="${dst#*:}"
[ "$src_ip" = "$dst_ip" ] && continue
if ping -c 1 -W 1 "$dst_ip" &>/dev/null; then
log "${YELLOW}⚠ CONNEXION détectée : $src_name → $dst_name${NC}"
else
log "${GREEN}✓ ISOLATION : $src_name → $dst_name${NC}"
fi
done
done
}
checklist() {
log_header "CHECKLIST PME"
cat >> "$RAPPORT" << 'EOF'
□ VLANs créés sur le switch
□ Ports affectés aux bons VLANs
□ Trunk actif vers routeur/firewall
□ VLANs autorisés sur le trunk
□ Native VLAN identique des deux côtés
□ Passerelle par VLAN configurée
□ DHCP ou IP statiques validés
□ Isolation Guest vérifiée
□ Rapport archivé avec date et version
EOF
tail -15 "$RAPPORT"
}
auto_mode() {
log_header "DIAGNOSTIC AUTOMATIQUE VLAN PME"
show_network_state
check_gateways
check_isolation
checklist
echo -e "${GREEN}✓ Rapport sauvegardé : $RAPPORT${NC}"
}
show_menu() {
echo ""
echo -e "${YELLOW}═══════════════════════════════════════${NC}"
echo -e " DIAGNOSTIC VLAN PME"
echo -e "${YELLOW}═══════════════════════════════════════${NC}"
echo "1. 🔍 Diagnostic complet"
echo "2. 🌐 État réseau"
echo "3. 🔒 Tester l'isolation"
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) show_network_state ;;
3) check_isolation ;;
4) checklist ;;
5) echo -e "${GREEN}Au revoir !${NC}"; exit 0 ;;
*) echo -e "${RED}Choix invalide${NC}" ;;
esac
done
fi
# 1. Créer les fichiers
nano vlan_tester.py
nano diagnostic_vlan.sh
# 2. Rendre les scripts exécutables
chmod +x vlan_tester.py
chmod +x diagnostic_vlan.sh
# 3. Installer les dépendances Python
pip3 install colorama
# 4. Lancer le test interactif
python3 vlan_tester.py --menu
# 5. Lancer le diagnostic Bash
./diagnostic_vlan.sh --all
# 6. Archiver les preuves
mkdir preuves_vlan_pme
cp rapport_*.html rapport_*.txt preuves_vlan_pme/ 2>/dev/null
#!/bin/bash RAPPORT="rapport_vlan_$(date +%Y%m%d_%H%M%S).txt" echo "=== RAPPORT DIAGNOSTIC VLAN ===" | tee "$RAPPORT" date | tee -a "$RAPPORT" echo "\n--- Interfaces ---" | tee -a "$RAPPORT" ip addr show | tee -a "$RAPPORT" echo "\n--- Routes ---" | tee -a "$RAPPORT" ip route show | tee -a "$RAPPORT" echo "\n--- Tests passerelles ---" | tee -a "$RAPPORT" for ip in 192.168.10.254 192.168.20.254 192.168.30.254; do ping -c 2 -W 1 "$ip" >/dev/null && echo "OK $ip" | tee -a "$RAPPORT" || echo "KO $ip" | tee -a "$RAPPORT" done echo "Rapport généré : $RAPPORT"
Ces liens correspondent au matériel utile pour reproduire le TP en conditions réelles : switch manageable, routeur inter-VLAN et équipement de sécurité.
Pour pratiquer les ports access, trunk et VLANs.
Voir sur AmazonPour aller plus loin avec filtrage inter-VLAN.
Voir sur AmazonPour le routage inter-VLAN et DHCP.
Voir sur AmazonAlternative pour labs et petites architectures.
Voir sur AmazonLiens affiliés Amazon — aucun surcoût pour vous.
Ce module VLAN constitue la base de segmentation. Le Pack TP complet ajoute les règles firewall, VPN, Wi‑Fi sécurisé et cas concrets PME.
🎓 Voir le Pack TP complet📘 Recevoir le guide gratuitCe 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 packCe module fait partie du Pack TP Sécurité Réseau : VLAN, firewall, VPN, Wi‑Fi sécurisé et 802.1X. L’objectif est de passer d’une configuration isolée à une démarche complète de sécurisation PME.
Voir tout le Pack TP Télécharger le guide gratuitAvant de considérer ce module comme exploitable, vérifiez les points suivants :