Trying to setup dnsmasq in jail

Status
Not open for further replies.

tslw

Dabbler
Joined
Jun 17, 2011
Messages
39
I am trying to setup dnsmasq in a jail so I can have a DNS server for local name resolution.

E.g. to see web page of the printer I want to be able to do http://printer in my web browser instead of the IP address.

I am running freenas 9.2. I have setup a standard jail and have done the following setup in the jail (the jail IP is 192.168.1.240):

Code:
pkg install dnsmasq
edit /usr/local/etc/dnsmasq.conf
 
This file has the following contents:
local=/mydomain.local/
listen-address=192.168.1.240
resolv-file=/etc/resolv.conf
# I just want a DNS server, no dhcp
no-dhcp-interface=
# If you want it to read another file, as well as /etc/hosts, use this.
addn-hosts=/etc/banner_add_hosts
 
edit /etc/banner_add_hosts and added the contents:
192.168.1.163 printer
192.168.1.164 freenas
 
edit /etc/rc.conf and added
dnsmasq_enable="YES"
 


dnsmasq is running (checked with sockstat and ps):
Code:
 # sockstat -4 -p 53
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS
nobody   dnsmasq    72269 3  udp4   192.168.178.240:53    *:*
nobody   dnsmasq    72269 4  tcp4   192.168.178.240:53    *:*

Internet hosts are still recognized in the jail (e.g. I get an answer from ping www.microsoft.com).
When I do ping printer, the error message "ping: cannot resolve printer: Unknown host" is returned.
I also tried to resolve names outside the jail but in that case I get a timeout.
Can somebody point me in the right direction?
 
D

dlavigne

Guest
Is that host in the /etc/hosts of the jail? From the dnsmasq website, it looks like it uses the contents of /etc/hosts rather than a zone file:

Dnsmasq will serve names from the /etc/hosts file on the firewall machine: If the names of local machines are there, then they can all be addressed without having to maintain /etc/hosts on each machine.
 

tslw

Dabbler
Joined
Jun 17, 2011
Messages
39
The contents of the hosts file in jail (jail is called tools) is:

Code:
::1                    localhost localhost.localdomain
127.0.0.1              localhost localhost.localdomain tools
192.168.178.240        tools
 
192.168.178.164        printer2


The hosts file in my initial post is additional hosts file that is specified in dnsmasq.conf

I can ping printer2 inside the jail (but not outside because I do not get a DNS response).
 

Dusan

Guru
Joined
Jan 29, 2013
Messages
1,165
Did you change the DNS/resolver configuration on the other machines (and also in the jail) to use your dnsmasq?
 

tslw

Dabbler
Joined
Jun 17, 2011
Messages
39
On the other machines I did.

I expected that running dnsmasq would be enough to make it work in the jail. o_O
I am probably way too optimistic.
Should I change resolve.conf to point to localhost first?

Edit:
I added nameserver 127.0.0.1 to resolv.conf but it does not help.
 

Dusan

Guru
Joined
Jan 29, 2013
Messages
1,165
Yes, you need to change the jail resolv.conf for the system/jail to use the dnsmasq.
Btw. is your jail's IP pingable from your network?
 
Status
Not open for further replies.
Top