Static DHCP Leases where stored?

Hi!

Anybody knows where IPfire stores its static DHCP leases?

Additionally, where are the hosts entries saved to?

I know the hosts from UI are saved to an intermediate file before they are written into the final host file upon saving. So I’m after this intermediate file.

Do you mean /var/ipfire/dhcp/fixleases ?

No they aren’t. They are stored into a variable in the perl code and when you press the add button then the hosts file is updated.

Same way if you press the waste bin icon for a host entry then it is removed from the perl variable and then immediately removed from the hosts file.

Exactly, thanks!

1 Like

Sure?

I’ve digged in my documentation and found the file where IPFire stores the hosts before they go into the final place, the real hosts file.

The intermediate file is /var/ipfire/main/hosts

Since I’ve got many hosts, manually added to IPFire, modifying a single of them them in the UI is really a PITA, I’ve done modifications in above file and fired those commands afterwards.

/usr/local/bin/rebuildhosts

/usr/local/bin/unboundctrl restart

As far as I remember, I had once had a quick look into the coding, the logic was to alaways execute one or both of those commands for each entry while looping through the above file. This happens when pressing the save button in UI.

This action lasts really, really long, believe me, and the UI is unresponsive during that time, too. In my case 5 minutes are normal at the moment.

The fixed leases from the UI are held in an IPFire file.
The definition <MAC,IP> is used to generate a fixed definition in dhcp.conf.
<MAC,IP,remark> generates an entry in hosts file, if the remark matches the requirement given in the wiki.

1 Like

From what I understand

IPFire uses Unbound by default, it manages the local DNS.

Static addresses declared by hosts.cgi in the /var/ipfire/main/hosts file
DHCP fixed lease addresses are declared by dhcp.cgi in /var/ipfire/dhcp/fixleases

Then
Dynamic addresses assigned by DHCP are recorded in /var/state/dhcp/dhcpd.leases

Unbound performs its updates in the local DNS :

1 - Saves the static addresses from the /var/ipfire/main/hosts file to /etc/unbound/hosts.conf
2 - Saves the assigned DHCP addresses from the /var/state/dhcp/dhcpd.leases file to /etc/unbound/dhcp-leases.conf
3 - Saves the addresses from the /var/ipfire/dhcp/fixleases file to /etc/unbound/dhcp-leases.conf if it is not already declared static in /etc/unbound/hosts.conf

What static definitions do we talk about?

There are two flavors of ‘static IPs’ in IPFire.

1) fixed IPs for devices using DHCP

  • Fixed leases are the definitions <MAC, IP> in DHCP server. They demand which IP should be given to a certain MAC.
  • Host names define an name for a certain IP. This is used by the DNS server.
  • The ‘DHCP server’ WUI page gets <MAC,IP> definitions and write these to the config file of dhcpd. Further you can give a remark for this lease. If it conforms to the form given in the wiki, an information <name,IP> for the DNS server is generated also.

2) devices that have IPs defined in their own network config.

  • the information for the DNS namespace must be defined in the Edit Hosts WUI page. This information is saved in the hosts file.

‘Static IPs’ must not be out of the set of dynamic IPs (start address … end address) and the IPs used for fixed leases.
As stated multiple times the sets dynamic_leases, fixed_leases and static_IPs must be disjunct.

DHCP fixed leases are not static IP addresses.
Static IP addresses are defined by the CLIENT.
You can declare a fixed lease to a MAC address, but it’s the connecting device that decides.
If the device declares an other static IP address, it won’t use the fixed lease address.

Edit : In my opinion (which is not shared here)
Only static IP addresses should be declared in the hosts file (via host.cgi)

The hosts file declares associations between name and IPs for namespace of DNS ( unbound ).
Fixed leases define associations between MACs and IPs for the IP set of DHCP.

The dhcp.cgi tries to define host definitions for DNS. But this isn’t the only way to define a name for a LAN device ide.ntified by an unique MAC.
If you know the IP ( defined as fixed, f.e. ) you also add entry with host.cgi. Or the device ( DHCP client ) can give his name in the DHCP transaction.

IMO, multiple distinct definitions of a name for a device may result in unpredictable behaviour. Maybe we can examine this case some day together. Many discussions in the community about this didn’t give enough information.

1 Like

I tried but I hit a wall

1 Like