dnsmasq in jail - DNS works, DHCP doesn't

Status
Not open for further replies.

tatonka

Dabbler
Joined
Jul 19, 2013
Messages
12
Hi,

i am trying to install a dnsmasq in a jail. I have deselected NAT and VIMAGE option for the jail and installed it.

I have bind it to the jail's IP address, and it currently resolves the DNS queries quite well. But it still does not serve DHCP.

I am assuming that the jail network mechanism works on TCP layer 4, so maybe DHCP is not forwarded to the jail by the host? Was the deselection of VIMAGE a good idea then?

Do you know how to configure the jail and the dnsmasq so it can work as a DHCP server too? Maybe i have to enable VIMAGE, but i don't know how to do this after the creation of the jail.

Or is it because i did not explicitly specify a MAC for the jail?

Please help.

EDIT: When writing this post, the dnsmasq seems to have gotten a DHCP request, and served it quite well. I still don't know why some machines in my network are successful with DHCP request and some are not.
 

titan_rw

Guru
Joined
Sep 1, 2012
Messages
586
I did get dhcpd working in an 8.3 jail. If I remember right I did have to allow the jail access to the bpf through devfs. I don't know how the new jail options relate vs how 8.3 jails worked.
 

bitsandnumbers

Dabbler
Joined
Apr 8, 2013
Messages
39
I thought I had the same issue until I realized I misconfigrued dnsmasq.conf and hosts file.

Thing is, I wanted to have dnsmasq acting as a dhcp server instead of my router. But when I deactivated the router's dhcp and rebooted the server, freenas was unable to reach the jail with dnsmasq in it: obviously it was not launched yet^^

So I had to let my router's dhcp on, and setup all my devices to reach dnsmasq dns (the ip from the dnsmasq jail) first, with the router as fallback. The dhcp autodiscovery depends really on devices. My laptop for instance discovers the server first, then the router as fallback. My tablet and my phone find the router first and have no 2nd dns option as fallback, so I have to set them up manually (but only for my home wifi network, so that when in other places they will use the default dns from those places).

The second issue (with dnsmasq.conf and hosts file) was that I was unable to have my remote domain name reach my server IP's. In fact, for it to work you have to populate the "address" section of dnsmasq (i.e: "address=/sub.domain.tld/192.168.1.32") for each domain and subdomain, and the hosts file itself (i.e: "192.168.1.32 sub1.domain.tld sub2.domain.tld..."). You restart dnsmasq and it work.

Hope it will help you out :)

In the meantime, if someone has a solution to get my router's dhcp down and have the jail handle dhcp properly, I'm open. For now, freenas tries to detect dhcp before the jail is up (obviously) during boot. I must find a way to tell freenas to launch the jail even it doesn't find a suitable dhcp server and use the jail's dhcp then for instance. Don't know if it's possible though... It did work on 8.3 though, but I can't remember how I did it...
 

alexmc

Dabbler
Joined
Sep 21, 2013
Messages
10
I too wish to run a dnsmasq server on my FreeNAS box - and have it be the sole DHCP server (and authoritative DNS server) on my network. I currently have this on a separate machine which I would like to switch off. Is there an install guide which lists what you did to get it working?

I dont know when to install stuff in a jail, and when to install into the FreeNAS operating system itself.

Any advice to achieve this?
 

bitsandnumbers

Dabbler
Joined
Apr 8, 2013
Messages
39
@alexmc : I did setup my dns server myself, so I don't know of any good tutorial. But the good news is: in Freenas 9 you don't need to link /dev/bpf to the dns jail anymore, it's done by freenas. In freenas 8, you had to edit the jail's rules to open the bpf interface. Otherwise, setting up dnsmasq is pretty straight forward from what I recall. If you read the dnsmasq.conf carefully, you should be able to handle it yourself (you need to understand at least a bit of how a network work of course). Just make sure you populate your hosts file correctly if you want to access websites on your server remotely.

From what I understood, you should (almost) never have to touch the freenas main install. You can do everything within jails while setting them up inside Freenas web UI. I don't even know if change in files are kept after reboot in the Freenas main install, apart from the /conf/base folder (the only place where I edit files if really needed) or /root.

But I don't understand why you would switch off the other machine that has dns server already setup. If it work, it's better than in a freenas jail, since you need a dhcp server already in place during freenas boot, otherwise jails won't even load. At least, that's the main issue I have right now...
 
Status
Not open for further replies.
Top