Aucun résumé des modifications
 
(7 versions intermédiaires par le même utilisateur non affichées)
Ligne 1 : Ligne 1 :
= <span style="color:#2c3e50;">DHCP</span> =
= <span style="color:#2c3e50;">DHCP</span> =


{| style="width:100%; background:#f0f4f8; border:1px solid #c7d3e0; padding:15px;"
{| style="width:100%; background:#f0f4f8; border:1px solid #c7d3e0; padding:15px; border-radius:10px; overflow:hidden;"
|
|
<span style="font-size:120%; color:#2c3e50;">
<span style="font-size:120%; color:#2c3e50;">
Ligne 10 : Ligne 10 :
= <span style="color:#2c3e50;">Infrastructure DHCP — Rocky Linux</span> =
= <span style="color:#2c3e50;">Infrastructure DHCP — Rocky Linux</span> =


{| style="width:100%; background:#f5f7fa; border:1px solid #d6dbe1; padding:15px;"
{| style="width:100%; background:#f5f7fa; border:1px solid #d6dbe1; padding:15px; border-radius:10px; overflow:hidden;"
|
|
<span style="font-size:115%; color:#34495e;">
<span style="font-size:115%; color:#34495e;">
<b>Documentation complète de mise en place d’une infrastructure DHCP sous Rocky Linux</b>
<b>Documentation complète de mise en place d’une infrastructure DHCP sous Rocky Linux</b>
</span>
</span>
|}


__TOC__
__TOC__


= <span style="color:#196f3d;">1 — Création du Serveur DHCP</span> =
= <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; padding:12px; border-radius:10px; overflow:hidden;"
|
|
<b style="color:#196f3d;">Installation et configuration du service DHCP</b>
<b style="color:#196f3d;">Installation et configuration du service DHCP</b>
Ligne 32 : Ligne 32 :
</pre>
</pre>


Vérifier installation :
Vérifier l’installation :


<pre>
<pre>
Ligne 51 : Ligne 51 :


     option routers 192.168.30.254;
     option routers 192.168.30.254;
     option domain-name-servers 192.168.40.253;
     option domain-name-servers 192.168.40.253;
     range 192.168.30.10 192.168.30.50;
     range 192.168.30.10 192.168.30.50;
}
}
</pre>
</pre>


== <span style="color:#239b56;">Vérification configuration</span> ==
== <span style="color:#239b56;">Vérification de la configuration</span> ==


<pre>
<pre>
Ligne 70 : Ligne 70 :
</pre>
</pre>


== <span style="color:#239b56;">Ouverture Iptable</span> ==
== <span style="color:#239b56;">Ouverture de iptables</span> ==


<pre>
<pre>
vi /etc/sysconfig/iptables
vi /etc/sysconfig/iptables
</pre>
Dans le fichier inserer cette ligne
<pre>
-I INPUT 2 -p udp --dport 67 -j ACCEPT
-I INPUT 2 -p udp --dport 67 -j ACCEPT
</pre>
</pre>
Ligne 92 : Ligne 87 :
= <span style="color:#b9770e;">2 — Configuration DHCP détaillée</span> =
= <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; padding:12px; border-radius:10px; overflow:hidden;"
|
|
<b style="color:#b9770e;">Configuration avancée du serveur DHCP</b>
<b style="color:#b9770e;">Configuration avancée du serveur DHCP</b>
|}
|}


== <span style="color:#ca6f1e;">Explication directives</span> ==
== <span style="color:#ca6f1e;">Explication des directives</span> ==


{| class="wikitable" style="background:#ffffff; border:1px solid #fad7a0;"
{| class="wikitable" style="width:50%; background:#ffffff; border:1px solid #fad7a0; border-radius:10px; overflow:hidden;"
! Directive !! Description
! Directive !! Description
|-
|-
Ligne 113 : Ligne 108 :
|}
|}


== <span style="color:#ca6f1e;">Attribution IP fixe</span> ==
== <span style="color:#ca6f1e;">Attribution d’une IP fixe</span> ==


<pre>
<pre>
Ligne 124 : Ligne 119 :
== <span style="color:#ca6f1e;">Plusieurs réseaux</span> ==
== <span style="color:#ca6f1e;">Plusieurs réseaux</span> ==


Répeter cette procédure avec autant de réseaux nécessaires
Répétez cette procédure pour tous les réseaux nécessaires.


----


= <span style="color:#7d3c98;">3 — DHCP Relay sur Firewall</span> =
= <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; padding:12px; border-radius:10px; overflow:hidden;"
|
|
<b style="color:#7d3c98;">Transmission des requêtes DHCP entre réseaux</b>
<b style="color:#7d3c98;">Transmission des requêtes DHCP entre réseaux</b>
Ligne 136 : Ligne 132 :
== <span style="color:#884ea0;">Principe</span> ==
== <span style="color:#884ea0;">Principe</span> ==


{| style="width:100%; background:#fafafa; border:1px solid #ddd;"
{| style="width:100%; background:#fafafa; border:1px solid #ddd; padding:12px; border-radius:10px; overflow:hidden;"
|
|
Le DHCP fonctionne en broadcast.   
Le DHCP fonctionne en broadcast.   
Ligne 156 : Ligne 152 :


== <span style="color:#884ea0;">Configuration</span> ==
== <span style="color:#884ea0;">Configuration</span> ==
Copier le fichier daemon dans un répertoire pour pouvoir etre executer et modifier
 
<pre>
<pre>
cp /lib/systemd/system/dhcrelay.service /etc/systemd/system/
cp /lib/systemd/system/dhcrelay.service /etc/systemd/system/
</pre>
Modifier le fichier fraichement copier
<pre>
vi /etc/systemd/system/dhcrelay.service
vi /etc/systemd/system/dhcrelay.service
</pre>
Modifier la ligne ExecStart
<pre>
ExecStart=/usr/sbin/dhcrelay -d --no-pid -i pri -i lan -i dmz 192.168.40.253 192.168.40.251
ExecStart=/usr/sbin/dhcrelay -d --no-pid -i pri -i lan -i dmz 192.168.40.253 192.168.40.251
systemctl daemon-reload
vi /etc/sysconfig/dhcrelay
</pre>
</pre>


Reload le Daemon pour appliquer les changements de manière effective
Ajouter :
<pre>
systemctl daemon-reload
</pre>


Nous allons modifier le DhcRelay
<pre>
vi /etc/sysconfig/dhcrelay
</pre>
Ajout de ces lignes dans le fichier
<pre>
<pre>
INTERFACES="dmz pri lan"
INTERFACES="dmz pri lan"
Ligne 198 : Ligne 179 :
= <span style="color:#922b21;">4 — DHCP Maître / Esclave (Failover)</span> =
= <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; padding:12px; border-radius:10px; overflow:hidden;"
|
|
<b style="color:#922b21;">Haute disponibilité du service DHCP</b>
<b style="color:#922b21;">Haute disponibilité du service DHCP</b>
Ligne 211 : Ligne 192 :
== <span style="color:#a93226;">Modes</span> ==
== <span style="color:#a93226;">Modes</span> ==


{| class="wikitable" style="background:#ffffff; border:1px solid #f5b7b1;"
{| class="wikitable" style="width:35%; border:1px solid #f5b7b1; border-radius:10px; overflow:hidden;"
! Mode !! Description
! Mode !! Description
|-
|-
Ligne 223 : Ligne 204 :
= <span style="color:#117864;">5 — Configuration DHCP Maître / Esclave</span> =
= <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; padding:12px; border-radius:10px; overflow:hidden;"
|
|
<b style="color:#117864;">Configuration complète du failover DHCP</b>
<b style="color:#117864;">Configuration complète du failover DHCP</b>
Ligne 231 : Ligne 212 :


<pre>
<pre>
MASTER : 192.168.1.10
MASTER : 192.168.40.253
SLAVE  : 192.168.1.11
SLAVE  : 192.168.40.251
</pre>
</pre>


Installer sur les deux :
Installation sur les deux serveurs :


<pre>
<pre>
Ligne 244 : Ligne 225 :


<pre>
<pre>
failover peer "dhcp-failover" {
failover peer "dhcp" {
primary;
  primary;
address 192.168.1.10;
  address 192.168.40.253;
port 647;
  port 520;
peer address 192.168.1.11;
  peer address 192.168.40.251;
peer port 647;
  peer port 520;
max-response-delay 60;
  max-response-delay 60;
max-unacked-updates 10;
  max-unacked-updates 10;
  mclt 3600;
  split 128;
  load balance max seconds 3;
}
}


subnet 192.168.1.0 netmask 255.255.255.0 {
subnet 192.168.30.0 netmask 255.255.255.0 {
option routers 192.168.1.1;
    authoritative;
 
    option routers 192.168.30.254;
    option domain-name-servers 192.168.40.253;


pool {
    pool {
  failover peer "dhcp-failover";
        failover peer "dhcp";
  range 192.168.1.100 192.168.1.200;
        option routers 192.168.30.254;
}
        range 192.168.30.10 192.168.30.50;
    }
}
}
</pre>
</pre>
Ligne 267 : Ligne 255 :


<pre>
<pre>
failover peer "dhcp-failover" {
failover peer "dhcp" {
secondary;
  secondary;
address 192.168.1.11;
  address 192.168.40.251;
port 647;
  port 520;
peer address 192.168.1.10;
  peer address 192.168.40.253;
peer port 647;
  peer port 520;
  max-response-delay 60;
  max-unacked-updates 10;
  mclt 3600;
}
subnet 192.168.30.0 netmask 255.255.255.0 {
    option routers 192.168.30.254;
    option domain-name-servers 192.168.40.253;
 
    pool {
        failover peer "dhcp";
        option routers 192.168.30.254;
        range 192.168.30.10 192.168.30.50;
    }
}
}
</pre>
</pre>


== <span style="color:#148f77;">Ouverture port failover</span> ==
== <span style="color:#148f77;">Ouverture du port failover</span> ==


<pre>
<pre>
firewall-cmd --add-port=647/tcp --permanent
vi /etc/sysconfig/iptables
firewall-cmd --reload
-I INPUT 2 -p tcp --dport 520 -j ACCEPT
systemctl reload iptables
</pre>
</pre>


== <span style="color:#148f77;">Démarrage</span> ==
== <span style="color:#148f77;">Redémarrage du service DHCP</span> ==


<pre>
<pre>
systemctl enable dhcpd
systemctl restart dhcpd
systemctl start dhcpd
</pre>
</pre>


----
----


{| style="width:100%; background:#e8f5e9; border:1px solid #c8e6c9; padding:15px;"
{| style="width:100%; background:#e8f5e9; border:1px solid #c8e6c9; padding:15px; border-radius:10px; overflow:hidden;"
|
|
<span style="font-size:120%; color:#1e8449;">
<span style="font-size:120%; color:#1e8449;">

Dernière version du 21 février 2026 à 15:27

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

1 — Création du Serveur DHCP

Installation et configuration du service DHCP

Installation du service

dnf install dhcp-server -y

Vérifier l’installation :

rpm -qa | grep dhcp

Configuration principale

vi /etc/dhcp/dhcpd.conf

Configuration minimale :

subnet 192.168.30.0 netmask 255.255.255.0 {
    authoritative;

    option routers 192.168.30.254;
    option domain-name-servers 192.168.40.253;
    range 192.168.30.10 192.168.30.50;
}

Vérification de la configuration

dhcpd -t

Démarrage du service

systemctl enable dhcpd
systemctl start dhcpd
systemctl status dhcpd

Ouverture de iptables

vi /etc/sysconfig/iptables
-I INPUT 2 -p udp --dport 67 -j ACCEPT

Enregistrement des changements

systemctl reload iptables

2 — Configuration DHCP détaillée

Configuration avancée du serveur DHCP

Explication des directives

Directive Description
subnet Réseau géré
authoritative Serveur DHCP officiel
option routers Passerelle réseau
option domain-name-servers Serveurs DNS fournis
range Plage IP distribuée

Attribution d’une IP fixe

host dhcp1 {
 hardware ethernet 00:00:00:00:00:00;
 fixed-address 192.168.40.253;
}

Plusieurs réseaux

Répétez cette procédure pour tous les réseaux nécessaires.


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

cp /lib/systemd/system/dhcrelay.service /etc/systemd/system/
vi /etc/systemd/system/dhcrelay.service
ExecStart=/usr/sbin/dhcrelay -d --no-pid -i pri -i lan -i dmz 192.168.40.253 192.168.40.251
systemctl daemon-reload
vi /etc/sysconfig/dhcrelay

Ajouter :

INTERFACES="dmz pri lan"
DHCPSERVERS="192.168.40.253"

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.40.253
SLAVE  : 192.168.40.251

Installation sur les deux serveurs :

dnf install dhcp-server -y

Configuration MASTER

failover peer "dhcp" {
  primary;
  address 192.168.40.253;
  port 520;
  peer address 192.168.40.251;
  peer port 520;
  max-response-delay 60;
  max-unacked-updates 10;
  mclt 3600;
  split 128;
  load balance max seconds 3;
}

subnet 192.168.30.0 netmask 255.255.255.0 {
    authoritative;

    option routers 192.168.30.254;
    option domain-name-servers 192.168.40.253;

    pool {
        failover peer "dhcp";
        option routers 192.168.30.254;
        range 192.168.30.10 192.168.30.50;
    }
}

Configuration SLAVE

failover peer "dhcp" {
  secondary;
  address 192.168.40.251;
  port 520;
  peer address 192.168.40.253;
  peer port 520;
  max-response-delay 60;
  max-unacked-updates 10;
  mclt 3600;
}
subnet 192.168.30.0 netmask 255.255.255.0 {
    option routers 192.168.30.254;
    option domain-name-servers 192.168.40.253;

    pool {
        failover peer "dhcp";
        option routers 192.168.30.254;
        range 192.168.30.10 192.168.30.50;
    }
}

Ouverture du port failover

vi /etc/sysconfig/iptables
-I INPUT 2 -p tcp --dport 520 -j ACCEPT
systemctl reload iptables

Redémarrage du service DHCP

systemctl restart dhcpd

Infrastructure DHCP opérationnelle