MDstable
NoteSnippetChecklistPlaybook

DHCP — Configuration & Sécurisation

ISC DHCP / Kea, Cisco IOS DHCP server & relay, Windows DHCP, réservations, options, snooping

snippetintermediate 2026-05-14 4 min read
dhcpciscobind9windowsdhcp-snoopingrelayreservationskeaisc-dhcp

ISC DHCP Server (Linux)

Installation

bash
apt install isc-dhcp-server
# Interface d'écoute
echo 'INTERFACESv4="eth0"' >> /etc/default/isc-dhcp-server

Configuration — /etc/dhcp/dhcpd.conf

text
# Paramètres globaux
authoritative; # rejette les rogue DHCP
default-lease-time 86400; # 24h
max-lease-time 172800; # 48h max
log-facility local7; # syslog
# Options globales
option domain-name "example.local";
option domain-name-servers 192.168.1.1, 192.168.1.2;
option ntp-servers 192.168.1.254;
# Subnet 192.168.1.0/24
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
option routers 192.168.1.254;
option broadcast-address 192.168.1.255;
default-lease-time 86400;
}
# Réservation par adresse MAC
host srv-web {
hardware ethernet aa:bb:cc:dd:ee:ff;
fixed-address 192.168.1.10;
option host-name "srv-web";
}
host poste-compta {
hardware ethernet 11:22:33:44:55:66;
fixed-address 192.168.1.50;
}

Multi-VLAN (plusieurs subnets)

text
# VLAN 10 — Utilisateurs
subnet 10.10.10.0 netmask 255.255.255.0 {
range 10.10.10.50 10.10.10.250;
option routers 10.10.10.1;
option domain-name-servers 192.168.1.1;
default-lease-time 28800; # 8h pour les postes utilisateurs
}
# VLAN 20 — Serveurs (pas de plage dynamique : tout en réservations)
subnet 10.10.20.0 netmask 255.255.255.0 {
option routers 10.10.20.1;
}
# VLAN 30 — IoT
subnet 10.10.30.0 netmask 255.255.255.0 {
range 10.10.30.100 10.10.30.200;
option routers 10.10.30.1;
# Pas de DNS interne pour l'IoT
option domain-name-servers 1.1.1.1;
max-lease-time 3600; # bail court
}

Commandes de gestion

bash
# Vérifier la syntaxe
dhcpd -t -cf /etc/dhcp/dhcpd.conf
# Redémarrer
systemctl restart isc-dhcp-server
# Baux actifs
cat /var/lib/dhcpd/dhcpd.leases
# Voir les attributions en temps réel
tail -f /var/log/syslog | grep dhcp
# Libérer un bail spécifique
# (depuis le client Linux)
dhclient -r && dhclient eth0

Cisco IOS — DHCP Server

text
! Exclure les adresses réservées (gateways, serveurs, imprimantes)
ip dhcp excluded-address 192.168.1.1 192.168.1.20
ip dhcp excluded-address 192.168.1.250 192.168.1.254
! Créer le pool DHCP
ip dhcp pool VLAN10-USERS
network 192.168.1.0 255.255.255.0
default-router 192.168.1.254
dns-server 192.168.1.1 192.168.1.2
domain-name example.local
lease 1 0 0 ! durée : 1 jour
! Réservation par MAC (Cisco)
ip dhcp pool RESERVE-SRV-WEB
host 192.168.1.10 255.255.255.0
client-identifier 01aa.bbcc.ddee.ff ! 01 + MAC sans séparateurs
default-router 192.168.1.254
! Vérifications
show ip dhcp pool
show ip dhcp binding
show ip dhcp conflict
show ip dhcp statistics

Cisco IOS — DHCP Relay Agent

text
! Sur le routeur ou switch L3, interface du VLAN client
interface vlan 10
ip address 10.10.10.1 255.255.255.0
ip helper-address 192.168.1.5 ! IP du serveur DHCP centralisé
no shutdown
! Vérifier que le relay fonctionne
debug ip dhcp server events
show ip dhcp relay information

Windows DHCP Server

powershell
# Installer le rôle DHCP
Install-WindowsFeature DHCP -IncludeManagementTools
# Autoriser le serveur dans Active Directory
Add-DhcpServerInDC -DnsName "srv-dhcp.example.local" -IPAddress 192.168.1.5
# Créer un scope
Add-DhcpServerv4Scope `
-Name "VLAN10-Users" `
-StartRange 192.168.1.100 `
-EndRange 192.168.1.200 `
-SubnetMask 255.255.255.0 `
-LeaseDuration 1.00:00:00
# Options du scope
Set-DhcpServerv4OptionValue -ScopeId 192.168.1.0 `
-Router 192.168.1.254 `
-DnsServer 192.168.1.1, 192.168.1.2 `
-DnsDomain "example.local"
# Réservation par MAC
Add-DhcpServerv4Reservation `
-ScopeId 192.168.1.0 `
-IPAddress 192.168.1.10 `
-ClientId "AA-BB-CC-DD-EE-FF" `
-Name "srv-web"
# Exclure des plages
Add-DhcpServerv4ExclusionRange `
-ScopeId 192.168.1.0 `
-StartRange 192.168.1.1 `
-EndRange 192.168.1.20
# Haute disponibilité DHCP (failover)
Add-DhcpServerv4Failover `
-Name "DHCP-HA" `
-PartnerServer "srv-dhcp2.example.local" `
-ScopeId 192.168.1.0 `
-LoadBalancePercent 50
# Lister les baux actifs
Get-DhcpServerv4Lease -ScopeId 192.168.1.0
# Vérifier les conflits
Get-DhcpServerv4Conflict

DHCP Snooping — Switch Cisco

text
! Activer globalement
ip dhcp snooping
ip dhcp snooping vlan 10,20,30
! Désactiver l'insertion de l'option 82 si pas nécessaire
no ip dhcp snooping information option
! Marquer les ports uplink / connexion serveur DHCP comme trusted
interface GigabitEthernet0/1
description UPLINK-DISTRIBUTION
ip dhcp snooping trust
interface GigabitEthernet0/24
description SERVEUR-DHCP
ip dhcp snooping trust
! Les ports clients restent untrusted (par défaut)
! Optionnel : limiter le taux de requêtes DHCP par port
interface range GigabitEthernet0/2 - 23
ip dhcp snooping limit rate 15 ! max 15 paquets/s
! Vérifications
show ip dhcp snooping
show ip dhcp snooping binding
show ip dhcp snooping statistics
💡 Tip —

Activer Dynamic ARP Inspection (DAI) conjointement au DHCP snooping — DAI utilise la table de binding DHCP snooping pour valider les requêtes ARP et bloquer l'ARP spoofing.

text
! DAI — Dynamic ARP Inspection
ip arp inspection vlan 10,20,30
interface GigabitEthernet0/1
ip arp inspection trust ! même ports trusted que DHCP snooping
show ip arp inspection
show ip arp inspection vlan 10
Checklist0/12
OPS·BRAIN v1.027 notes · Networklocal