Configuration VLAN FS <-> DLink

Configuration VLAN FS <-> DLink

Objectif

Configurer le routage du VLAN 101 entre un Raspberry Pi connecté à un switch FS et un switch DLink, permettant la communication inter-VLAN dans l’infrastructure du laboratoire.

Topologie réseau

Architecture

Raspberry Pi (172.16.16.2/24)
    ↓ (eth0.101 - VLAN 101)
Switch FS (172.16.16.3/24)
    ↓ (g0/24 - Trunk)
Switch DLink (172.16.16.1/24)
    ↓ (Port 1-2 - VLAN 101)
Autres équipements VLAN 101

Adressage IP

Équipement Interface VLAN Adresse IP Masque
Raspberry Pi eth0.101 101 172.16.16.2 /24
Switch FS VLAN 101 101 172.16.16.3 /24
Switch DLink VLAN 101 101 172.16.16.1 /24

Configuration Raspberry Pi

Création de l’interface VLAN

# Création de l'interface VLAN 101
ip link add link eth0 name eth0.101 type vlan id 101

# Attribution de l'adresse IP
ip addr add 172.16.16.2/24 dev eth0.101

# Activation de l'interface
ip link set up eth0.101

Configuration persistante

Fichier /etc/systemd/network/eth0.101.netdev

[NetDev]
Name=eth0.101
Kind=vlan

[VLAN]
Id=101

Fichier /etc/systemd/network/eth0.101.network

[Match]
Name=eth0.101

[Network]
DHCP=no
IPV6AcceptRA=no

[Address]
Address=172.16.16.2/24

[Route]
Gateway=172.16.16.1
Destination=0.0.0.0/0

Vérification de la configuration

# État des interfaces
ip link show
ip addr show eth0.101

# Table de routage
ip route show

# Test de connectivité
ping 172.16.16.1  # Switch DLink
ping 172.16.16.3  # Switch FS

Configuration Switch FS

Création du VLAN

# Configuration via CLI
configure terminal
vlan 101
name "LAB_VLAN_101"
exit

Configuration des ports

Port g0/20 (vers équipement local)

interface gigabitethernet 0/20
switchport mode access
switchport access vlan 101
no shutdown
exit
interface gigabitethernet 0/24
switchport mode trunk
switchport trunk allowed vlan 101
switchport trunk native vlan 1
no shutdown
exit

Interface VLAN et routage

# Création de l'interface VLAN
interface vlan 101
ip address 172.16.16.3 255.255.255.0
no shutdown
exit

# Activation du routage IP
ip routing

Configuration complète

# Configuration résumée
vlan 101
 name LAB_VLAN_101

interface gigabitethernet 0/20
 switchport mode access
 switchport access vlan 101

interface gigabitethernet 0/24
 switchport mode trunk
 switchport trunk allowed vlan 101

interface vlan 101
 ip address 172.16.16.3 255.255.255.0

ip routing

Accès à l’interface web

Création du VLAN via interface web

  1. VLAN ConfigurationVLAN Settings
  2. Add VLAN :
    • VLAN ID : 101
    • VLAN Name : LAB_VLAN_101
  3. Apply

Configuration des ports

Ports 1-2 (access VLAN 101)

Port Configuration:
- Port 1: 
  * PVID: 101
  * Mode: Access
  * Tagged VLANs: None
  * Untagged VLAN: 101
  
- Port 2:
  * PVID: 101 
  * Mode: Access
  * Tagged VLANs: None
  * Untagged VLAN: 101
Port 24 (exemple):
- Mode: Trunk
- Tagged VLANs: 101
- Native VLAN: 1

Interface VLAN et IP

VLAN Interface Configuration:
- VLAN ID: 101
- IP Address: 172.16.16.1
- Subnet Mask: 255.255.255.0
- Gateway: 172.16.16.3 (si routage via FS)

Scripts d’automatisation

Script de configuration Raspberry Pi

#!/bin/bash
# setup-vlan101.sh

VLAN_ID=101
INTERFACE="eth0"
VLAN_INTERFACE="${INTERFACE}.${VLAN_ID}"
IP_ADDRESS="172.16.16.2/24"
GATEWAY="172.16.16.1"

# Vérification des prérequis
if ! command -v ip &> /dev/null; then
    echo "Erreur: commande 'ip' non trouvée"
    exit 1
fi

# Création de l'interface VLAN
echo "Création de l'interface VLAN ${VLAN_ID}..."
ip link add link $INTERFACE name $VLAN_INTERFACE type vlan id $VLAN_ID

# Configuration IP
echo "Configuration de l'adresse IP..."
ip addr add $IP_ADDRESS dev $VLAN_INTERFACE

# Activation de l'interface
echo "Activation de l'interface..."
ip link set up $VLAN_INTERFACE

# Ajout de la route par défaut si spécifiée
if [ ! -z "$GATEWAY" ]; then
    echo "Ajout de la route par défaut..."
    ip route add default via $GATEWAY dev $VLAN_INTERFACE
fi

echo "Configuration terminée !"
echo "Interface créée : $VLAN_INTERFACE"
echo "Adresse IP : $IP_ADDRESS"

# Vérification
ip addr show $VLAN_INTERFACE

Script de test de connectivité

#!/bin/bash
# test-vlan-connectivity.sh

TARGETS=(
    "172.16.16.1:DLink Switch"
    "172.16.16.3:FS Switch"
)

echo "=== Test de connectivité VLAN 101 ==="
echo "Date : $(date)"
echo

for target in "${TARGETS[@]}"; do
    IFS=':' read -r ip name <<< "$target"
    echo -n "Test vers $name ($ip) : "
    
    if ping -c 3 -W 2 $ip > /dev/null 2>&1; then
        echo "✓ OK"
    else
        echo "✗ ÉCHEC"
    fi
done

echo
echo "=== Informations interface VLAN 101 ==="
ip addr show eth0.101 2>/dev/null || echo "Interface eth0.101 non trouvée"

echo
echo "=== Table de routage ==="
ip route show | grep "172.16.16"

Monitoring et dépannage

Commandes de diagnostic

# État des VLANs sur FS
show vlan brief
show interface vlan 101

# Statistiques des ports
show interface gigabitethernet 0/24 statistics

# Table MAC
show mac-address-table vlan 101

# Logs
show logging

Dépannage des problèmes courants

VLAN non actif

# Vérification de la configuration VLAN
show vlan id 101

# Activation si nécessaire
configure terminal
vlan 101
state active

Port en erreur

# Vérification de l'état du port
show interface gigabitethernet 0/24

# Reset du port si nécessaire
configure terminal
interface gigabitethernet 0/24
shutdown
no shutdown

Problème de routage

# Vérification de la table de routage
show ip route

# Test de connectivité locale
ping 172.16.16.1 source vlan 101

Monitoring avec SNMP

Configuration SNMP sur FS

snmp-server community public ro
snmp-server community private rw
snmp-server location "Laboratoire"
snmp-server contact "admin@rougy.net"

Requêtes SNMP utiles

# État des interfaces
snmpwalk -v2c -c public 172.16.16.3 1.3.6.1.2.1.2.2.1.8

# Trafic des interfaces
snmpwalk -v2c -c public 172.16.16.3 1.3.6.1.2.1.2.2.1.10

# Table VLAN
snmpwalk -v2c -c public 172.16.16.3 1.3.6.1.2.1.17.7.1.4.2.1.3

Sécurité

ACLs sur le switch FS

# Création d'une ACL pour limiter l'accès
access-list extended VLAN101_ACL
permit ip 172.16.16.0 0.0.0.255 any
deny ip any any log

# Application sur l'interface VLAN
interface vlan 101
ip access-group VLAN101_ACL in

Configuration via interface web :

Documentation de référence

Configuration sauvegardée

# FS Switch
show running-config | section vlan
show running-config | section interface

# Sauvegarde
copy running-config startup-config
copy running-config tftp://172.16.16.10/fs-config-backup.txt

Changelog

Date Modification Auteur
2025-02-18 Configuration initiale VLAN 101 YR
2025-02-20 Ajout du trunk FS-DLink YR
2025-02-22 Configuration ACLs sécurité YR

Évolutions prévues


Dernière mise à jour : 18 février 2025