Hey,
For your situation, you should use "giaddr" as the source address for your requests. Then, configure the DHCP server to match these addresses and allocate IP addresses from the appropriate pool.
Your configuration should resemble the following:
forwarding-options {
dhcp-relay {
server-group {
Lan2 {
192.168.1.200;
}
Lan3 {
192.168.1.200;
}
}
group Lan2 {
active-server-group Lan2;
interface irb.2;
overrides {
replace-ip-source-with giaddr;
}
}
group Lan3 {
active-server-group Lan3;
interface irb.3;
overrides {
replace-ip-source-with giaddr;
}
}
}
}
The next step involves matching a different giaddr and assigning IP addresses from the appropriate pool. Your DHCP configuration should appear as follows:
class "lan2" {
match if (binary-to-ascii(10, 8, ".", packet(24, 4)) = "192.168.2.1");
}
class "lan3" {
match if (binary-to-ascii(10, 8, ".", packet(24, 4)) = "192.168.3.1");
}
shared-network lan-pools {
subnet 192.168.2.0 netmask 255.255.255.0 {
pool {
allow members of "lan2";
default-lease-time 240;
max-lease-time 120;
range 192.168.2.2 192.168.2.254;
option subnet-mask 255.255.255.0;
option routers 192.168.2.1;
option domain-name-servers 8.8.8.8;
}
}
subnet 192.168.3.0 netmask 255.255.255.0 {
pool {
allow members of "lan3";
range 192.168.3.2 192.168.3.254;
option subnet-mask 255.255.255.0;
option routers 192.168.3.1;
option domain-name-servers 8.8.8.8;
}
}
}
Hope this helps!
------------------------------
Ivan Ivanov
------------------------------
Original Message:
Sent: 08-02-2023 08:21
From: Koos147
Subject: Wrong subnet with multiple dhcp relay
Good day,
We have a network with 1 dhcp server. and some EX4300's
to make it simple. lets say we have 3 networks
vlan 1 192.168.1.0
vlan 2 192.168.2.0
vlan 3 192.168.3.0
The dhcp server is 192.168.1.200 so no need for a dhcp relay in this subnet
so i added 2 extra pools to the dhcp server
and on the switch we added 2 dhcp relays
forwarding-options { dhcp-relay { server-group { Lan2 { 192.168.1.200; } Lan3 { 192.168.1.200; } } group Lan2 { active-server-group Lan2; interface irb.2; } group Lan3 { active-server-group Lan3; interface irb.3; } }}
now all clients get an ip.... thats great. however they get an ip from a random pool (192.168.2.x and 192.168.3.x)
so some clients get an ip in theire own vlan and are working. but most of the devices get an ip from the wrong subnet.
had this problem in the past with an srx as dhcp (no relay) and solved this
set system services dhcp-local-server requested-ip-interface-match
However this didn't solve it this time.
for now i disabled the 3th vlan and the 3th dhcp pool (also the 1th since we dont realy need this)
now we have 1 pool with 1 relay server and everything works fine.
How can we make sure the dhcp relay chooses the right pool.