Static DHCP Reservation in Packetfence

Is it possible to add DHCP Reservation in packetfence? Yes, let's see how to configure it.

It is not possible to configure any DHCP Reservation in Packetfence (my packetfence is version 6.4.0) using the web interface, but it is possible to do it editing configuration file in the server.

What we want to do is assign the same IP to a host via DHCP without configuring it manually on the host, obviously knowing the host’s MAC address.

First of all configure or verify dhcp configuration from web interface: Configuration > Interface and Network > here define a routed network and define a DHCP dynamic range

dhcp packet fence

In our example the network is 192.168.1.0/24 and the DHCP dinamic range we have 192.168.1.100-200, in this case our Dhcp reservation must be into the network, but outside the range (to avoid overlap).

Open an ssh session with packetfence server, the DHCP configuration is stored in these two files:
/usr/local/pf/conf/dhcpd.conf -> configuration template
/usr/local/pf/var/conf/dhcpd.conf -> configuration in use

In /usr/local/pf/var/conf/dhcpd.conf you can find the configuration that is in use by packetfence but you DO NOT have to edit this file because packetfence overwrite it any time you reboot dhcp service. This file is generated by /usr/local/pf/conf/dhcpd.conf and by the configuration you did on web interface, so basically, your “DHCP Reservation” o “DHCP Static Binding” must be configured here.

[ostrich@pfserver ~]# cat /usr/local/pf/conf/dhcpd.conf
# dhcpd configuration
# This file is manipulated on PacketFence's startup before being given to dhcpd
authoritative;
ddns-update-style none;
ignore client-updates;
log-facility local5;


# Captive-Portal DHCP option (RFC7710)
option captive-portal-rfc7710 code 160 = string;

#CONFIGURATION TAKEN FROM WEB INTERFACES
%%omapi%%

%%active%%

%%networks%%

%%parking%%

#MY CUSTOMIZATION
host static_01 {
hardware ethernet AA:11:BB:22:CC:33;
fixed-address 192.168.1.91;
}

host static_02 {
hardware ethernet AA:11:BB:22:CC:44;
fixed-address 192.168.1.92;
}

Now Restart DHCP server

After restarting DHCP server you should find changes in your configuration file “in use” /usr/local/pf/var/conf/dhcpd.conf

[ostrich@pfserver ~]# cat /usr/local/pf/var/conf/dhcpd.conf
# This file is generated from a template at /usr/local/pf/conf/dhcpd.conf
# Any changes made to this file will be lost on restart

# dhcpd configuration
# This file is manipulated on PacketFence's startup before being given to dhcpd
authoritative;
ddns-update-style none;
ignore client-updates;
log-facility local5;


# Captive-Portal DHCP option (RFC7710)
option captive-portal-rfc7710 code 160 = string;

# OMAPI for IP <-> MAC lookup
omapi-port 7911;
key pf_omapi_key {
algorithm HMAC-MD5;
secret "XXXXXXXXXXXXX";
};
omapi-key pf_omapi_key;

subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.1;
option subnet-mask 255.255.255.0;
option domain-name "dhcp-pf.ostrich";
option domain-name-servers 8.8.8.8;
option captive-portal-rfc7710 "https://wifi.ostrich";
range 192.168.1.100 192.168.1.200;
default-lease-time 86400;
max-lease-time 86400;
}

# parking feature
group parking {
default-lease-time 3600;
max-lease-time 3600;
}

host static_01 {
hardware ethernet AA:11:BB:22:CC:33;
fixed-address 192.168.1.91;
}

host static_02 {
hardware ethernet AA:11:BB:22:CC:44;
fixed-address 192.168.1.92;
}