« DHCP » : différence entre les versions
Aucun résumé des modifications |
|||
| (4 versions intermédiaires par le même utilisateur non affichées) | |||
| Ligne 15 : | Ligne 15 : | ||
<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__ | ||
| Ligne 73 : | Ligne 74 : | ||
<pre> | <pre> | ||
vi /etc/sysconfig/iptables | vi /etc/sysconfig/iptables | ||
-I INPUT 2 -p udp --dport 67 -j ACCEPT | -I INPUT 2 -p udp --dport 67 -j ACCEPT | ||
</pre> | </pre> | ||
| Ligne 98 : | Ligne 94 : | ||
== <span style="color:#ca6f1e;">Explication des directives</span> == | == <span style="color:#ca6f1e;">Explication des directives</span> == | ||
{| class="wikitable" style="background:#ffffff; border:1px solid #fad7a0; border-radius:10px; overflow:hidden;" | {| class="wikitable" style="width:50%; background:#ffffff; border:1px solid #fad7a0; border-radius:10px; overflow:hidden;" | ||
! Directive !! Description | ! Directive !! Description | ||
|- | |- | ||
| Ligne 156 : | Ligne 152 : | ||
== <span style="color:#884ea0;">Configuration</span> == | == <span style="color:#884ea0;">Configuration</span> == | ||
<pre> | <pre> | ||
cp /lib/systemd/system/dhcrelay.service /etc/systemd/system/ | cp /lib/systemd/system/dhcrelay.service /etc/systemd/system/ | ||
vi /etc/systemd/system/dhcrelay.service | 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 | ExecStart=/usr/sbin/dhcrelay -d --no-pid -i pri -i lan -i dmz 192.168.40.253 192.168.40.251 | ||
systemctl daemon-reload | |||
systemctl daemon-reload | |||
vi /etc/sysconfig/dhcrelay | vi /etc/sysconfig/dhcrelay | ||
</pre> | </pre> | ||
Ajouter : | |||
<pre> | <pre> | ||
| Ligne 218 : | Ligne 192 : | ||
== <span style="color:#a93226;">Modes</span> == | == <span style="color:#a93226;">Modes</span> == | ||
{| class="wikitable" style=" | {| class="wikitable" style="width:35%; border:1px solid #f5b7b1; border-radius:10px; overflow:hidden;" | ||
! Mode !! Description | ! Mode !! Description | ||
|- | |- | ||
| Ligne 249 : | Ligne 223 : | ||
== <span style="color:#148f77;">Configuration MASTER</span> == | == <span style="color:#148f77;">Configuration MASTER</span> == | ||
<pre> | <pre> | ||
| Ligne 281 : | Ligne 253 : | ||
== <span style="color:#148f77;">Configuration SLAVE</span> == | == <span style="color:#148f77;">Configuration SLAVE</span> == | ||
<pre> | <pre> | ||
| Ligne 308 : | Ligne 278 : | ||
== <span style="color:#148f77;">Ouverture du port failover</span> == | == <span style="color:#148f77;">Ouverture du port failover</span> == | ||
<pre> | <pre> | ||
vi /etc/sysconfig/iptables | vi /etc/sysconfig/iptables | ||
-I INPUT 2 -p tcp --dport 520 -j ACCEPT | -I INPUT 2 -p tcp --dport 520 -j ACCEPT | ||
systemctl reload iptables | systemctl reload iptables | ||
</pre> | </pre> | ||
| Ligne 335 : | Ligne 298 : | ||
<b>Infrastructure DHCP opérationnelle</b> | <b>Infrastructure DHCP opérationnelle</b> | ||
</span> | </span> | ||
|} | |} | ||
Dernière version du 21 février 2026 à 15:27
DHCP
Infrastructure DHCP — Rocky Linux
1 — Création du Serveur 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
Explication des directives
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
Principe
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)
Objectif
- Continuité de service
- Synchronisation des baux
- Prévention des conflits IP
Modes
5 — Configuration DHCP Maître / Esclave
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