DNSMasq in a FreeNAS Jail – A better approach

Intended Audience

This post will be of interest if you use DNSMasq in FreeNAS and would like to keep the configuration file outside the jail.

Background 

The main issue of building a standard DNSMasq installation in a FreeNAS jail or using the DNSMasq community plugin, is that the configuration file /usr/local/etc/dnsmas.conf is stored within the jail. This has to be considered whenever the jail is destroyed and rebuilt.

At the time of writing this, I am working with FreeNAS 11.3-U1 and DNSMasq 2.80_4.

Overview

In this build, I move the configuration file outside the jail. This simplifies restoration in case the jail is hosed. If you have a prepared version of the dnsmasq.conf make sure you save a copy of it outside the jail and destroy or rename the old jail before proceeding. If you’re starting from scratch with dnsmasq.conf, refer to the post DHCP/DNS Server on FreeNAS for some tips of what to include in it.

The key steps for the setup are:

  1. Create the jail
  2. Install the required packages
  3. Set up the external configuration location
  4. Configure DNSMasq to use the new configuration location

Step 1: Create the jail

Jails ⇒ Add

screenshot.214.png

screenshot.215.png

screenshot.216.png

Step 2: Install the required packages

Start the jail.

Jails ⇒ dnsmasq ⇒ Start

Shell into the jail.

Jails ⇒ dnsmasq ⇒ Shell

Install required packages.

pkg install dnsmasq nano

Step 3: Set up the external configuration location 

Create the location for storing configuration files in the jail.

mkdir /config

Stop the jail.

Jails ⇒ dnsmasq ⇒ Stop

Map the configuration location in the jail to an external location.

Jails ⇒ dnsmasq ⇒ Mount Points ⇒ Actions ⇒ Add.

For example:

screenshot.217.png

Step 4: Configure DNSMasq to use the new configuration location

Start the jail.

Jails ⇒ dnsmasq ⇒ Start

Shell into the jail.

Jails ⇒ dnsmasq ⇒ Shell

Start DNSMasq when the jail is started.

sysrc dnsmasq_enable="YES"

Use the configuration file in the new location.

sysrc dnsmasq_conf="/config/dnsmasq.conf"

If you have a pre-prepared dnsmasq.conf, place in the new location. If not, place a copy of the sample configuration file there and begin tailoring dnsmasq.conf in the new location.

cp /usr/local/etc/dnsmasq.conf.sample /config/dnsmasq.conf

Now if the jail is destroyed and rebuilt, configuration changes will not be lost.

References

  1. DHCP/DNS Server on FreeNAS

 

Keep Reading

PreviousNext

Comments

Leave a Reply