2

I am setting up a DHCP server on RHEL where some entries in the file are generated at a later stage and may be regenerated often. I was looking at the dhcpd config guide and the include ; guideline seems to be the best approach for this.

But it looks like the DHCP server doesn't load the external file at all.

Here's me dhcpd.conf:

default-lease-time   86400;               # 24 hours in seconds
max-lease-time       604800;              # 7 days in seconds
authoritative;

include "/opt/demo/deploy/extdhcp.conf"; #EXTERNAL FILE

subnet 192.200.1.0 netmask 255.255.255.0 {
    option routers             192.200.1.1;  
    option subnet-mask         255.255.255.0;
    option broadcast-address   192.200.1.255;

    host ANSIBLE-01 {
        hardware ethernet 00:50:56:8c:5e:47;
        fixed-address 192.200.1.10;
    }
}

Here's the external config file:

subnet 10.64.0.0 netmask 255.255.255.0 {
         range 10.64.0.1 10.64.0.100;
         option routers          10.64.0.254;
         option subnet-mask      255.255.255.0;
         option broadcast-address        10.64.0.255;

    host ILO-1 {
         hardware ethernet 00:50:56:8c:0e:fd;
         fixed-address 10.64.0.55;
    }
}

This is what I see in the logs, that tells me that the external file hasn't been loaded in dhcpd.

2019-02-09T15:19:07.493576+00:00 dhcp-01.erewhon.com <daemon.err> dhcpd: DHCPDISCOVER from 00:50:56:8c:0e:fd via eth0: network 192.200.1.0/24: no free leases
2019-02-09T15:19:19.671670+00:00 dhcp-01.erewhon.com <daemon.err> dhcpd: message repeated 3 times: [ DHCPDISCOVER from 00:50:56:8c:0e:fd via eth0: network 192.200.1.0/24: no free leases]
2019-02-09T15:19:26.657147+00:00 dhcp-01.erewhon.com <daemon.err> dhcpd: DHCPDISCOVER from 00:50:56:8c:0e:fd via eth0: network 192.200.1.0/24: no free leases
2019-02-09T15:21:04.257982+00:00 dhcp-01.erewhon.com <daemon.err> dhcpd: message repeated 7 times: [ DHCPDISCOVER from 00:50:56:8c:0e:fd via eth0: network 192.200.1.0/24: no free leases]
2019-02-09T15:21:18.419381+00:00 dhcp-01.erewhon.com <daemon.err> dhcpd: DHCPDISCOVER from 00:50:56:8c:0e:fd via eth0: network 192.200.1.0/24: no free leases

As you see from the logs, the DHCP seems to connect the MAC to the network defined in dhcpd.conf and not the external file.

Is my understanding of the include guideline wrong?

5 Answers 5

1

As it is already mentioned in the comment von Martin W, the problem here is not the external file, rahter the network configuration. The DHCP server will see and try to give a lease from a subnet, from where the request is coming. In the logs it is evident that the request is coming from the 192.200.1.0/24 subent:

dhcpd: DHCPDISCOVER from 00:50:56:8c:0e:fd via eth0: network 192.200.1.0/24: no free leases 

So the DHCP server is trying to lease an address from that range, which apparently seems full. Now even there is another subnet conifugred in the server, it won't automatically just lease address from there. It also doesn't make sense to give away addresses from some other range, when the devices are connected to the 192.200.1.0/24 network. It would not work anyway. The solution here is to use either VLAN in the network with dhcp relay or multiple interfaces at the dhcp server.

0

As you can see, it is showing no free leases. Which is most probably because of it already get IP from other range or other reason. Try to remove this ine from external file.

host ILO-1 { hardware ethernet 00:50:56:8c:0e:fd; fixed-address 10.64.0.55; } }

1
  • If you read my question again, you can see that I want it to get the fixed IP from the external file(10.64.0.55) and not from the 192.200.1.0/24 subnet from the main config file. But from the logs, it looks like the dhcpd is not loading the external config file and tries to assign from 192.200.1.0/24 there by resulting in no free leases.
    – blo0old
    Feb 10, 2019 at 18:11
0

I can confirm that your include line looks correct. We use it in the same way but the extra conf files live in /etc/dhcp/conf.d/ (centos server). Maybe make sure that there are no issues with dhcpd being able to open / read your extra file. Are there any errors in your log lines from when you restart the service which show any difficulty reading that file?

3
  • I haven't seen any errors wrt to opening/accessing the file. Is there a requirement to have the files in a particular location? I will test the /etc/dhcp/conf.d/ location now
    – blo0old
    Feb 11, 2019 at 13:43
  • I created the conf.d directory and made the directory and the file inside own by the dhcpd group. No luck.. :(
    – blo0old
    Feb 11, 2019 at 13:53
  • 2
    looking again at the log lines you pasted earlier I noticed that the discover is coming via your 192. subnet - "via eth0: network 192.200.1.0/24" If it comes via that gateway I think It's always going to try and assign an IP from that pool. You could either try moving the host declaration out of the subnet or make sure it is requesting an IP via the 10.64.0.254 gateway
    – Martin W
    Feb 11, 2019 at 15:53
0

I see you have your include directive above subnet declaration. I'm using the very same setup as your intended one ("static" assignments of IP to particular MAC), I just have the line below all the declarations, at the end of the file, and it works for me:

include "/etc/dhcp/host_defs.conf";
0

Remove or comment out fixed-address statement and... this is hardware-ethernet, not hardware ethernet.

You must log in to answer this question.

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