Host definitions are always global.
So I have 3 networks on my router; "LAN" 10.0.0.0/24, "guest" 10.100.100.0/24 and "IoT" 10.100.200.0/24
My dhcpd.conf
has the following sort of config
subnet 10.0.0.0 netmask 255.255.255.0 {
authoritative;
option routers 10.0.0.1;
blah;
}
subnet 10.100.100.0 netmask 255.255.255.0 {
authoritative;
option routers 10.100.100.1;
blah;
}
subnet 10.100.200.0 netmask 255.255.255.0 {
authoritative;
option routers 10.100.200.1;
blah;
}
host machine1 {
hardware ethernet xx:xx:xx:xx:xx:xx;
fixed-address 10.0.0.13;
option host-name "machine1";
}
host machine2 {
hardware ethernet yy:yy:yy:yy:yy:yy;
fixed-address 10.100.200.15;
option host-name "machine2";
}
DHCPd correctly works out that machine1
is on LAN and machine2
is on the IoT subnet and sends the correct configuration (netmask, default route, DNS server etc etc) relevant to that subnet.
If you have a machine that can connect to multiple interfaces and you want them to get different addresses then you can list the host multiple times. For example, my cellphone:
host s8 {
hardware ethernet aa:aa:aa:aa:aa:aa;
fixed-address 10.0.0.34;
option host-name "s8";
}
host s8-guest {
hardware ethernet aa:aa:aa:aa:aa:aa;
fixed-address 10.100.100.9;
option host-name "s8-guest";
}
Now it'll will get a different address, depending on what network it is on.
If there's no static entry for that network then it'll get a dynamic address. If there's no free addresses on the subnet then it won't get assigned any address.