Problem:
IP addresses already leased are being suggested during a provision.
Expected outcome:
IP addresses not already leased should be suggested
Foreman and Proxy versions:
Foreman and Proxy plugin versions:
3.0.1 both
Distribution and version:
Ubuntu 20.04
Other relevant data:
Foreman proxy says the IP is unused but if I manually check the lease file, it IS used.
2021-11-08T17:03:30 9bc2ff9c [I] Started GET /dhcp/192.168.250.0/unused_ip
2021-11-08T17:03:32 9bc2ff9c [I] Finished GET /dhcp/192.168.250.0/unused_ip with 200 (2005.5 ms)
Provisioning fails as expected as the DHCP cannot add the IP as it is already leased.
show me. When this request is processed, make a curl https://proxy:8443/dhcp/1.2.3.4 and make a copy of dhcpd.leases too.
Note Foreman supports “upgrading a lease to reservation”. If the host sends “preferred IP” address that belongs to the same MAC within the specified range, the lease is converted to reservation. Generally, we do not recommend the lease pool to overlap with Foreman subnet range tho.
You will find this tool useful when curing proxy because of SSL: Introducing fp-curl
That is really strange, can you check the leases file is included in the dhcpd.conf? Our parser is really simple, but it understands “include” statement, maybe there is some weird syntax.
What is in your /etc/foreman-proxy/settings.d/dhcp_isc.yaml ? Can you doublecheck the leases path?
What is your network mask? Note you must provide network address to the curl, just doublechecking. It is uncommon mask, that could be culprit of the problem.
sudo cat dhcp_isc.yml
---
#
# Configuration file for ISC dhcp provider
#
:config: /etc/dhcp/dhcpd.conf
:leases: /var/lib/dhcp/dhcpd.leases
# Redhat 5
#
#:config: /etc/dhcpd.conf
#
# Settings for Ubuntu
#
#:config: /etc/dhcp3/dhcpd.conf
#:leases: /var/lib/dhcp3/dhcpd.leases
# Specifies TSIG key name and secret
#:key_name: secret_key_name
#:key_secret: secret_key
:omapi_port: 7911
# use :server setting in dhcp.yml if you are managing a dhcp server which is not localhost
Next question: what filesystem is your dhcpd.leases on? Does it support inotify? Do you happen to have a custom Linux kernel compiled without inotify support?
Anyways, we can find it. Can you turn on debug for smart proxy in /etc/foreman-proxy/settings.yaml and restart it? Then tail the proxy log, it should print something like:
caught :modify event on #{event.absolute_name}.
You should watch also for the Queue overflow occured when monitoring which would mean the inotify queue was full and messages were dropped.
2021-11-15T09:24:24 d15a4061 [W] Failed to add DHCP reservation for HOSTDN (192.168.250.166 / 00:50:56:84:d3:b9): No response from DHCP server: <Proxy::DHCP::Error>: Failed to add DHCP reservation for HOSTDN (192.168.250.166 / 00:50:56:84:d3:b9): No response from DHCP server
Thanks, got it. For the record, if you use my github email remove the “-x” from the address, otherwise it goes to spam right next to those “job offers”. I recently created a new email lukasNOSPAM@zapletalovi.com which is hopefully more obvious.
The offending record is this one:
2021-11-22T09:14:46 [D] Added a reservation: 192.168.250.159:00:50:56:84:d1:d2:test-foreman-06.config.landcareresearch.co.nz
Problem is not MAC or IP address, problem is the host name. See, in ISC DHCP, every reservation must have a name and foreman uses the FQDN for such name, ISC insists on the name to be unique as it is actually the identifier of the record.
You need to delete the offending record first which is a leftover from some kind of rename? or operation that did not succeed successfully.