Installing dnsmasq on FreeBSD Latest

Dnsmasq is a lightweight, easy-to-configure DNS server that also provides DHCP and TFTP services. In this tutorial, we will go through the steps to install dnsmasq on FreeBSD Latest.

Prerequisites

Before proceeding with the installation, you should have the following:

  • A FreeBSD Latest system up and running
  • Root privileges or sudo access
  • A basic understanding of the command-line interface

Step 1: Update the System

First, update the FreeBSD packages and ports system to the latest version using the following command:

sudo pkg update && sudo pkg upgrade

Step 2: Install dnsmasq

Next, install dnsmasq from the FreeBSD ports collection by running the following command:

sudo make -C /usr/ports/dns/dnsmasq install clean

This will download the required packages, compile and install dnsmasq on your system.

Step 3: Configure dnsmasq

After installing dnsmasq, you need to configure it to suit your needs. The configuration file for dnsmasq is located at /usr/local/etc/dnsmasq.conf. Edit this file to suit your requirements.

Some common configuration options are:

  • listen-address: The IP address on which dnsmasq will listen for DNS queries.
  • domain-needed and bogus-priv: These options prevent dnsmasq from answering DNS queries from non-existent or private domains.
  • dhcp-range: Range of IP addresses that will be assigned by dnsmasq through DHCP.

For example, to configure dnsmasq to listen for DNS queries on IP address 192.168.0.1 and assign IP addresses in the range 192.168.0.50-192.168.0.100, add the following lines to /usr/local/etc/dnsmasq.conf:

listen-address=192.168.0.1
dhcp-range=192.168.0.50,192.168.0.100,12h

Save and exit the file.

Step 4: Start and enable dnsmasq

Finally, start the dnsmasq service using the following command:

sudo service dnsmasq start

To ensure that dnsmasq starts automatically on system boot, enable the service using the following command:

sudo sysrc "dnsmasq_enable=YES"

Conclusion

In this tutorial, we have gone through the steps to install and configure dnsmasq on FreeBSD Latest. With dnsmasq, you can run a lightweight DNS/DHCP/TFTP server on your FreeBSD system.