dnsmasq on FreeNAS

I recently put together a new NAS, using FreeNAS as the server software. As well as just serving up storage, I wanted it to also do DNS resolution and DHCP for the network it was serving storage for, using the jail functionality. FreeBSD — which FreeNAS is based on — jails allow you to effectively run another operating system, either FreeBSD or Linux, utilising the running kernel of the host.

It’s a form of virtualisation which is less heavyweight than full bare-metal virtualisation, since there’s only one OS kernel running. Given the modest performance of the hardware that I installed FreeNAS on, that was a better solution than virtualising the bare-metal.

To cut a long story short, if you want to run dnsmasq inside a FreeBSD jail to do DHCP, the jail needs to use the VIMAGE virtual network stack, rather than be passed in one of the native interfaces of the host. I don’t know exactly why, but all fingers point to jails somehow not being passed UDP broadcast packets correctly over a passed-in native interface. The VIMAGE virtual interface seems to have no such restrictions.

That took me a good couple of days to figure out, so I’m leaving this note here just in case someone else is stumbling over the same problem:

Use VIMAGE networking for your FreeBSD jail if you want to run dnsmasq inside it for DHCP.