« DHCP » : différence entre les versions
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| Ligne 1 : | Ligne 1 : | ||
= DHCP = | = <span style="color:#2c3e50;">DHCP</span> = | ||
Le DHCP (Dynamic Host Configuration Protocol) permet | {| style="width:100%; background:#f0f4f8; border:1px solid #c7d3e0; padding:15px;" | ||
| | |||
<span style="font-size:120%; color:#2c3e50;"> | |||
Le <b>DHCP (Dynamic Host Configuration Protocol)</b> permet d’attribuer automatiquement des adresses IP aux machines d’un réseau. | |||
</span> | |||
|} | |||
= Infrastructure DHCP — Rocky Linux = | = <span style="color:#2c3e50;">Infrastructure DHCP — Rocky Linux</span> = | ||
{| style="width:100%; background:#f5f7fa; border:1px solid #d6dbe1; padding: | {| style="width:100%; background:#f5f7fa; border:1px solid #d6dbe1; padding:15px;" | ||
| | | | ||
<span style="font-size:115%; color:#34495e;"> | |||
<b>Documentation complète de mise en place d’une infrastructure DHCP sous Rocky Linux</b> | |||
</span> | |||
---- | |||
<span style="color:#5d6d7e;"> | |||
• Création du serveur DHCP | |||
• Configuration détaillée | |||
• DHCP Relay sur Firewall | |||
• DHCP Maître / Esclave (Failover) | |||
• Haute disponibilité du service | |||
</span> | |||
|} | |} | ||
__TOC__ | __TOC__ | ||
---- | |||
= <span style="color:#1f618d;">0 — Prérequis</span> = | |||
{| style="width:100%; background:#eef6ff; border:1px solid #bcd6f0; padding:12px;" | |||
{| style="width:100%; background:#eef6ff; border:1px solid #bcd6f0;" | |||
| | | | ||
<b style="color:#1f618d;">Préparation du serveur</b> | |||
|} | |} | ||
== Vérifier l'utilisateur == | == <span style="color:#2874a6;">Vérifier l'utilisateur</span> == | ||
<pre> | <pre> | ||
| Ligne 34 : | Ligne 45 : | ||
Résultat attendu : | Résultat attendu : | ||
<pre> | <pre> | ||
root | root | ||
</pre> | </pre> | ||
== Configuration requise == | == <span style="color:#2874a6;">Configuration requise</span> == | ||
{| class="wikitable" style="background:#ffffff; border:1px solid #d6eaf8;" | |||
! Élément !! Description | |||
|- | |||
| IP fixe || Adresse serveur configurée manuellement | |||
|- | |||
| Interface réseau || Carte réseau active | |||
|- | |||
| Accès réseau || Connectivité fonctionnelle | |||
|} | |||
Voir interfaces réseau : | Voir interfaces réseau : | ||
| Ligne 50 : | Ligne 68 : | ||
</pre> | </pre> | ||
---- | |||
= <span style="color:#196f3d;">1 — Création du Serveur DHCP</span> = | |||
{| style="width:100%; background:#f3f9f1; border:1px solid #cfe5c9; padding:12px;" | |||
{| style="width:100%; background:#f3f9f1; border:1px solid #cfe5c9;" | |||
| | | | ||
<b style="color:#196f3d;">Installation et configuration du service DHCP</b> | |||
|} | |} | ||
== Installation du service == | == <span style="color:#239b56;">Installation du service</span> == | ||
<pre> | <pre> | ||
| Ligne 71 : | Ligne 89 : | ||
</pre> | </pre> | ||
== <span style="color:#239b56;">Configuration de l’interface réseau</span> == | |||
== Configuration de l’interface réseau == | |||
Identifier interface : | Identifier interface : | ||
| Ligne 93 : | Ligne 109 : | ||
</pre> | </pre> | ||
== <span style="color:#239b56;">Configuration principale</span> == | |||
== Configuration principale == | |||
<pre> | <pre> | ||
| Ligne 122 : | Ligne 136 : | ||
</pre> | </pre> | ||
== <span style="color:#239b56;">Vérification configuration</span> == | |||
== Vérification configuration == | |||
<pre> | <pre> | ||
| Ligne 130 : | Ligne 142 : | ||
</pre> | </pre> | ||
== <span style="color:#239b56;">Démarrage du service</span> == | |||
== Démarrage du service == | |||
<pre> | <pre> | ||
| Ligne 140 : | Ligne 150 : | ||
</pre> | </pre> | ||
== <span style="color:#239b56;">Ouverture firewall</span> == | |||
== Ouverture firewall == | |||
<pre> | <pre> | ||
| Ligne 149 : | Ligne 157 : | ||
</pre> | </pre> | ||
== <span style="color:#239b56;">Vérification fonctionnement</span> == | |||
== Vérification fonctionnement == | |||
<pre> | <pre> | ||
| Ligne 158 : | Ligne 164 : | ||
</pre> | </pre> | ||
---- | |||
= <span style="color:#b9770e;">2 — Configuration DHCP détaillée</span> = | |||
{| style="width:100%; background:#fff6e6; border:1px solid #f1d6a8; padding:12px;" | |||
{| style="width:100%; background:#fff6e6; border:1px solid #f1d6a8;" | |||
| | | | ||
<b style="color:#b9770e;">Configuration avancée du serveur DHCP</b> | |||
|} | |} | ||
== Explication directives == | == <span style="color:#ca6f1e;">Explication directives</span> == | ||
{| class="wikitable" style="background:#ffffff;" | {| class="wikitable" style="background:#ffffff; border:1px solid #fad7a0;" | ||
! Directive !! Description | ! Directive !! Description | ||
|- | |- | ||
| Ligne 191 : | Ligne 197 : | ||
|} | |} | ||
== <span style="color:#ca6f1e;">Attribution IP fixe</span> == | |||
== Attribution IP fixe == | |||
<pre> | <pre> | ||
| Ligne 202 : | Ligne 206 : | ||
</pre> | </pre> | ||
== <span style="color:#ca6f1e;">Plusieurs réseaux</span> == | |||
== Plusieurs réseaux == | |||
<pre> | <pre> | ||
| Ligne 213 : | Ligne 215 : | ||
</pre> | </pre> | ||
== <span style="color:#ca6f1e;">Boot réseau PXE</span> == | |||
== Boot réseau PXE == | |||
<pre> | <pre> | ||
| Ligne 222 : | Ligne 222 : | ||
</pre> | </pre> | ||
---- | |||
= <span style="color:#7d3c98;">3 — DHCP Relay sur Firewall</span> = | |||
{| style="width:100%; background:#f5eef8; border:1px solid #d7c6e6; padding:12px;" | |||
{| style="width:100%; background:#f5eef8; border:1px solid #d7c6e6;" | |||
| | | | ||
<b style="color:#7d3c98;">Transmission des requêtes DHCP entre réseaux</b> | |||
|} | |} | ||
== Principe == | == <span style="color:#884ea0;">Principe</span> == | ||
{| style="width:100%; background:#fafafa; border:1px solid #ddd;" | |||
Le DHCP fonctionne en broadcast. | | | ||
Les routeurs bloquent ces requêtes. | Le DHCP fonctionne en broadcast. | ||
Les routeurs bloquent ces requêtes. | |||
Le DHCP Relay transmet les requêtes vers un serveur distant. | Le DHCP Relay transmet les requêtes vers un serveur distant. | ||
|} | |||
Architecture : | Architecture : | ||
| Ligne 245 : | Ligne 246 : | ||
</pre> | </pre> | ||
== <span style="color:#884ea0;">Installation</span> == | |||
== Installation == | |||
<pre> | <pre> | ||
| Ligne 253 : | Ligne 252 : | ||
</pre> | </pre> | ||
== <span style="color:#884ea0;">Configuration</span> == | |||
== Configuration == | |||
<pre> | <pre> | ||
| Ligne 266 : | Ligne 263 : | ||
</pre> | </pre> | ||
== <span style="color:#884ea0;">Activation</span> == | |||
== Activation == | |||
<pre> | <pre> | ||
| Ligne 275 : | Ligne 270 : | ||
</pre> | </pre> | ||
---- | |||
= <span style="color:#922b21;">4 — DHCP Maître / Esclave (Failover)</span> = | |||
{| style="width:100%; background:#fdeeee; border:1px solid #efc2c2; padding:12px;" | |||
{| style="width:100%; background:#fdeeee; border:1px solid #efc2c2;" | |||
| | | | ||
<b style="color:#922b21;">Haute disponibilité du service DHCP</b> | |||
|} | |} | ||
== Objectif == | == <span style="color:#a93226;">Objectif</span> == | ||
* Continuité de service | * Continuité de service | ||
| Ligne 290 : | Ligne 285 : | ||
* Prévention des conflits IP | * Prévention des conflits IP | ||
== <span style="color:#a93226;">Modes</span> == | |||
{| class="wikitable" style="background:#ffffff; border:1px solid #f5b7b1;" | |||
{| class="wikitable" | |||
! Mode !! Description | ! Mode !! Description | ||
|- | |- | ||
| Ligne 302 : | Ligne 295 : | ||
|} | |} | ||
---- | |||
= <span style="color:#117864;">5 — Configuration DHCP Maître / Esclave</span> = | |||
{| style="width:100%; background:#eef7f6; border:1px solid #bfe1dc; padding:12px;" | |||
{| style="width:100%; background:#eef7f6; border:1px solid #bfe1dc;" | |||
| | | | ||
<b style="color:#117864;">Configuration complète du failover DHCP</b> | |||
|} | |} | ||
== Architecture == | == <span style="color:#148f77;">Architecture</span> == | ||
<pre> | <pre> | ||
| Ligne 324 : | Ligne 317 : | ||
</pre> | </pre> | ||
== <span style="color:#148f77;">Configuration MASTER</span> == | |||
== Configuration MASTER == | |||
<pre> | <pre> | ||
| Ligne 349 : | Ligne 340 : | ||
</pre> | </pre> | ||
== <span style="color:#148f77;">Configuration SLAVE</span> == | |||
== Configuration SLAVE == | |||
<pre> | <pre> | ||
| Ligne 363 : | Ligne 352 : | ||
</pre> | </pre> | ||
== <span style="color:#148f77;">Ouverture port failover</span> == | |||
== Ouverture port failover == | |||
<pre> | <pre> | ||
| Ligne 372 : | Ligne 359 : | ||
</pre> | </pre> | ||
== <span style="color:#148f77;">Démarrage</span> == | |||
== Démarrage == | |||
<pre> | <pre> | ||
| Ligne 381 : | Ligne 366 : | ||
</pre> | </pre> | ||
---- | |||
{| style="width:100%; background:#e8f5e9; border:1px solid #c8e6c9; padding:15px;" | |||
{| style="width:100%; background:#e8f5e9; border:1px solid #c8e6c9;" | |||
| | | | ||
<span style="font-size:120%; color:#1e8449;"> | |||
<b>Infrastructure DHCP opérationnelle</b> | |||
</span> | |||
|} | |} | ||
Version du 16 février 2026 à 14:33
DHCP
|
Le DHCP (Dynamic Host Configuration Protocol) permet d’attribuer automatiquement des adresses IP aux machines d’un réseau. |
Infrastructure DHCP — Rocky Linux
|
Documentation complète de mise en place d’une infrastructure DHCP sous Rocky Linux • Création du serveur DHCP • Configuration détaillée • DHCP Relay sur Firewall • DHCP Maître / Esclave (Failover) • Haute disponibilité du service |
0 — Prérequis
|
Préparation du serveur |
Vérifier l'utilisateur
whoami
Résultat attendu :
root
Configuration requise
| Élément | Description |
|---|---|
| IP fixe | Adresse serveur configurée manuellement |
| Interface réseau | Carte réseau active |
| Accès réseau | Connectivité fonctionnelle |
Voir interfaces réseau :
ip a
1 — Création du Serveur DHCP
|
Installation et configuration du service DHCP |
Installation du service
dnf install dhcp-server -y
Vérifier installation :
rpm -qa | grep dhcp
Configuration de l’interface réseau
Identifier interface :
ip a
Configurer DHCP :
nano /etc/sysconfig/dhcpd
Modifier :
DHCPDARGS=ens33
Configuration principale
nano /etc/dhcp/dhcpd.conf
Configuration minimale :
option domain-name "lab.local";
option domain-name-servers 8.8.8.8, 1.1.1.1;
default-lease-time 600;
max-lease-time 7200;
authoritative;
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
option routers 192.168.1.1;
option broadcast-address 192.168.1.255;
}
Vérification configuration
dhcpd -t
Démarrage du service
systemctl enable dhcpd systemctl start dhcpd systemctl status dhcpd
Ouverture firewall
firewall-cmd --add-service=dhcp --permanent firewall-cmd --reload
Vérification fonctionnement
journalctl -u dhcpd cat /var/lib/dhcpd/dhcpd.leases
2 — Configuration DHCP détaillée
|
Configuration avancée du serveur DHCP |
Explication directives
| Directive | Description |
|---|---|
| option domain-name | Domaine local fourni aux clients |
| option domain-name-servers | Serveurs DNS fournis |
| default-lease-time | Durée IP par défaut |
| max-lease-time | Durée maximale du bail |
| authoritative | Serveur DHCP officiel |
| subnet | Réseau géré |
| range | Plage IP distribuée |
| option routers | Passerelle réseau |
| broadcast-address | Adresse broadcast |
Attribution IP fixe
host pc1 {
hardware ethernet 00:11:22:33:44:55;
fixed-address 192.168.1.50;
}
Plusieurs réseaux
subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.100 192.168.2.200;
option routers 192.168.2.1;
}
Boot réseau PXE
next-server 192.168.1.10; filename "pxelinux.0";
3 — DHCP Relay sur Firewall
|
Transmission des requêtes DHCP entre réseaux |
Principe
|
Le DHCP fonctionne en broadcast. Les routeurs bloquent ces requêtes. Le DHCP Relay transmet les requêtes vers un serveur distant. |
Architecture :
Client → Firewall → Serveur DHCP
Installation
dnf install dhcp-relay -y
Configuration
nano /etc/sysconfig/dhcrelay
DHCPSERVERS="192.168.1.10" INTERFACES="ens33 ens34"
Activation
systemctl enable dhcrelay systemctl start dhcrelay
4 — DHCP Maître / Esclave (Failover)
|
Haute disponibilité du service DHCP |
Objectif
- Continuité de service
- Synchronisation des baux
- Prévention des conflits IP
Modes
| Mode | Description |
|---|---|
| Load Balance | Partage de charge |
| Hot Standby | Serveur secondaire de secours |
5 — Configuration DHCP Maître / Esclave
|
Configuration complète du failover DHCP |
Architecture
MASTER : 192.168.1.10 SLAVE : 192.168.1.11
Installer sur les deux :
dnf install dhcp-server -y
Configuration MASTER
failover peer "dhcp-failover" {
primary;
address 192.168.1.10;
port 647;
peer address 192.168.1.11;
peer port 647;
max-response-delay 60;
max-unacked-updates 10;
}
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.1;
pool {
failover peer "dhcp-failover";
range 192.168.1.100 192.168.1.200;
}
}
Configuration SLAVE
failover peer "dhcp-failover" {
secondary;
address 192.168.1.11;
port 647;
peer address 192.168.1.10;
peer port 647;
}
Ouverture port failover
firewall-cmd --add-port=647/tcp --permanent firewall-cmd --reload
Démarrage
systemctl enable dhcpd systemctl start dhcpd
|
Infrastructure DHCP opérationnelle |