5

On Ubuntu, I've written some host declaration in each subnet with isc-dhcp-server, and each fixed address for each network interface are successfully leased. There are plugged two network cards on this DHCP server.

But how to make corrections for this warning?

dhcpd[11328]: WARNING: Host declarations are global. They are not limited to the scope you declared them in.

This post on the same warning message answers host declarations are out of subnet definitions. I don't think that is true in my case where two cards involved.

1 Answer 1

6

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.

3
  • This will lease the same address if they connect from the other interface. It's not what I want.
    – jumeno
    Jan 22, 2020 at 3:59
  • 1
    It doesn't. if you don't have a static entry on that network (see my update on how you can do this) then it'll try and get a dynamic one. If there's no dynamic address available on the subnet then it won't get any assigned address. DHCPd is pretty smart :-) Jan 22, 2020 at 20:45
  • Thanks. I got the right address.
    – jumeno
    Jan 22, 2020 at 22:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .