How to Set Up a DHCP Server with `isc-dhcp44-server` on FreeBSD
isc-dhcp44-server
on FreeBSD.Categories:
3 minute read
Introduction
Dynamic Host Configuration Protocol (DHCP) is essential for managing network configurations by automatically assigning IP addresses to clients. On FreeBSD, the isc-dhcp44-server
package provides a reliable and flexible DHCP server implementation. This guide will walk you through installing, configuring, and managing a DHCP server using isc-dhcp44-server
on FreeBSD.
Prerequisites
Before starting, ensure you have:
- A FreeBSD system with root or sudo access
- A static IP address configured on the network interface
- A basic understanding of networking concepts
Step 1: Installing isc-dhcp44-server
FreeBSD provides the isc-dhcp44-server
package via the ports collection and binary package system. You can install it using either method.
Using pkg
(Binary Package)
sudo pkg install isc-dhcp44-server
Using Ports Collection
If you prefer to build from source, use the ports collection:
cd /usr/ports/net/isc-dhcp44-server
sudo make install clean
Once installed, verify the installation:
pkg info isc-dhcp44-server
Step 2: Configuring the DHCP Server
The main configuration file is located at /usr/local/etc/dhcpd.conf
. Open it using a text editor:
sudo vi /usr/local/etc/dhcpd.conf
Basic DHCP Configuration
Below is a simple DHCP configuration for a network 192.168.1.0/24
:
default-lease-time 600;
max-lease-time 7200;
option domain-name "example.com";
option domain-name-servers 8.8.8.8, 8.8.4.4;
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
option routers 192.168.1.1;
option broadcast-address 192.168.1.255;
}
Assigning Static IP Addresses
To assign a static IP to a specific device, add an entry like this:
host mydevice {
hardware ethernet AA:BB:CC:DD:EE:FF;
fixed-address 192.168.1.50;
}
Replace AA:BB:CC:DD:EE:FF
with the MAC address of the device.
Step 3: Configuring the DHCP Service
Specify the network interface that dhcpd
will listen on by editing /etc/rc.conf
:
sudo vi /etc/rc.conf
Add the following lines:
dhcpd_enable="YES"
dhcpd_ifaces="em0"
Replace em0
with your actual network interface. You can check available interfaces with:
ifconfig
Step 4: Starting and Managing the DHCP Service
Start the DHCP Server
sudo service isc-dhcpd start
Check Status
sudo service isc-dhcpd status
Enable DHCP Service at Boot
sudo sysrc dhcpd_enable=YES
Restart or Stop the Service
To restart:
sudo service isc-dhcpd restart
To stop:
sudo service isc-dhcpd stop
Step 5: Testing the DHCP Server
To test the server, connect a client device and check if it receives an IP address. You can verify DHCP leases on the server with:
cat /var/db/dhcpd.leases
For real-time logging:
tail -f /var/log/messages
Step 6: Troubleshooting Common Issues
DHCP Service Fails to Start
Ensure there are no syntax errors in
/usr/local/etc/dhcpd.conf
by running:sudo dhcpd -t -cf /usr/local/etc/dhcpd.conf
Confirm that the correct interface is set in
/etc/rc.conf
.Check logs for errors:
sudo tail -f /var/log/messages
Clients Are Not Receiving IP Addresses
Verify that the network interface has the correct IP configuration.
Restart the DHCP service:
sudo service isc-dhcpd restart
Confirm that no other DHCP servers are running on the network.
Step 7: Advanced Configurations
Configuring Dynamic DNS Updates
If you want to integrate DHCP with a DNS server for dynamic updates, add the following to dhcpd.conf
:
zone example.com. {
primary 192.168.1.1;
key DHCP_UPDATE_KEY;
}
You also need to configure the DNS server to accept updates from the DHCP server.
Configuring Multiple Subnets
For multiple subnets, define each subnet separately:
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
option routers 192.168.1.1;
}
subnet 10.0.0.0 netmask 255.255.255.0 {
range 10.0.0.100 10.0.0.200;
option routers 10.0.0.1;
}
Conclusion
Setting up a DHCP server on FreeBSD using isc-dhcp44-server
is a straightforward process. By following this guide, you should have a fully functional DHCP server that automatically assigns IP addresses to clients in your network. Regularly monitor logs and update configurations as needed to ensure optimal performance.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.