From 7c4e3a8e47446280766c5e9429bd819774821256 Mon Sep 17 00:00:00 2001 From: GnomeZworc Date: Sat, 10 May 2025 12:00:12 +0200 Subject: [PATCH] fix dhcp router ip Signed-off-by: GnomeZworc --- lib/dhcp.sh | 4 +++- lib/subnet.sh | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/dhcp.sh b/lib/dhcp.sh index 08b4692..3e2abef 100644 --- a/lib/dhcp.sh +++ b/lib/dhcp.sh @@ -28,6 +28,8 @@ function int_to_mac() { function generate_dhcp_file { # CIDR de départ (ex: "10.10.10.0/24") cidr="${1}" + gateway_cidr=${3} + gateway="$(echo "${gateway_cidr}" | cut -d\/ -f1)" subnet="$(echo "${cidr}" | cut -d\/ -f1)" output_file="/etc/dnsmasq.d/${2}.conf" @@ -66,7 +68,7 @@ function generate_dhcp_file { echo "no-resolv" >> "$output_file" echo "dhcp-range=${subnet},static,255.255.255.0,12h" >> "$output_file" - echo "dhcp-option=3,240.0.2.1" >> "$output_file" + echo "dhcp-option=3,${gateway}" >> "$output_file" echo "dhcp-option=6,1.1.1.1,8.8.8.8" >> "$output_file" # Variables pour l'incrémentation des MAC et IP diff --git a/lib/subnet.sh b/lib/subnet.sh index 42588f1..b0be7f8 100644 --- a/lib/subnet.sh +++ b/lib/subnet.sh @@ -82,7 +82,7 @@ function create_subnet { ebtables -A FORWARD --out-interface "br-${subnet_id}" -p arp --arp-op Request --arp-ip-dst "${gateway_ip}" -j DROP ebtables -A FORWARD --out-interface "br-${subnet_id}" -p IPv4 --ip-protocol udp --ip-source-port 67:68 --ip-destination-port 67:68 -j DROP - generate_dhcp_file "${subnet}" "${vpc_name}_br-${subnet_id}" + generate_dhcp_file "${subnet}" "${vpc_name}_br-${subnet_id}" "${router_ip}" systemctl start "dnsmasq@${vpc_name}_br-${subnet_id}.service" }