Dnsmasq .lan domain while still using knot resolver

Ok I set them both to “home.lan” and it kinda works.

  1. It does not work from the turris itself, is this expected behaviour?

  2. From the LAN workstations, I also get two additional replies with not found:

    $ host turris.home.lan 192.168.1.1
    Using domain server:
    Name: 192.168.1.1
    Address: 192.168.1.1#53
    Aliases:

    turris.home.lan has address 192.168.1.1
    Host turris.home.lan not found: 3(NXDOMAIN)
    Host turris.home.lan not found: 3(NXDOMAIN)

Strange, digging in the dnsmasq man:

Also permitted is a -S flag which gives a domain but no IP address; this tells dnsmasq that a domain is local
and it may answer queries from /etc/hosts or DHCP but should never forward queries on that domain to any
upstream servers. local is a synonym for server to make configuration files clearer in this case.

So I think “home.lan” and “/home.lan/” are both correct settings, but it still getting forwarded somewhere.

Oh it might be IPv6, but I disabled that. Let me check this.

Adding this to the custom config file:

policy.add(policy.suffix(policy.FORWARD('127.0.0.1@54'), policy.todnames({'lan'})))

doesn’t seem to allow lookups to .lan hostnames, but using the old init_header() fix does:

difference between the broken and working files:

--- /tmp/kresd.config.broken    2016-12-09 09:27:42.108117000 -0500
+++ /tmp/kresd.config.working   2016-12-09 09:23:57.358117000 -0500
@@ -8,6 +8,7 @@
       , period = 24*(60/30) -- track last 24 hours
   }
 }
+policy.add(policy.suffix(policy.FORWARD('127.0.0.1@54'),  policy.todnames({'lan'})))
 hints.config('/etc/hosts')
 net.bufsize(4096)
 net.ipv4=true
@@ -19,4 +20,3 @@

 --- Included custom configuration file from: ---
 --- /etc/kresd/custom.conf
-policy.add(policy.suffix(policy.FORWARD('127.0.0.1@54'),  policy.todnames({'lan'})))

The full working file:

--Automatically generated file; DO NOT EDIT
modules = {
    'hints'
  , 'policy'
  , 'stats'
  , predict = {
        window = 30 -- 30 minutes sampling window
      , period = 24*(60/30) -- track last 24 hours
  }
}
policy.add(policy.suffix(policy.FORWARD('127.0.0.1@54'),  policy.todnames({'lan'})))
hints.config('/etc/hosts')
net.bufsize(4096)
net.ipv4=true
net.ipv6=true
cache.open(20*MB)
cache.clear()
policy:add(policy.all(policy.FORWARD('71.242.0.12')))
policy:add(policy.all(policy.FORWARD('71.250.0.12')))

--- Included custom configuration file from: ---
--- /etc/kresd/custom.conf

I suspect it is because the custom policies get added after the policy.all statements

I don’t think so, for me adding it to kresd.custom.conf works…

Hmm seems to be working kind of… I can now ping using the names on the network with .lan attached… however, none of the browsers open web gui if I point it to omnia.lan ( my router ) which can be pinged just fine:

C:\Users\Vlado>ping omnia.lan

Pinging omnia.lan [127.0.0.1] with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128

Ping statistics for 127.0.0.1:
    Packets: Sent = 2, Received = 2, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

Also If I try connect samba share using the name of the router it will not accept my password, if I change it to IP it accept it just fine… something is missing :-/

Also ssh from the same machine that pinged it ok will not work it will not recognize it :frowning:

From the client machine it looks kid of ok:

Wireless LAN adapter WiFi:

   Connection-specific DNS Suffix  . : lan
   IPv4 Address. . . . . . . . . . . : 192.168.1.106
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.1.1

No idea why it doesn’t resolve properly :frowning:

Looks like the DNS resolving is working for everything but omnia it self… I made anoter lxc with ssh open and used ssh server.lan and no issue… thinning directed at omnia.lan is not working though… :frowning: not ssh, not samba not browser… its frustrating

Well, since the name omnia.lan returns the loopback address, it cannot work over the network. Go to the place where you defined that name and change the address to 192.168.1.1.

Daaaaamn I’m a moron, you are right ! /etc/hosts was the issue I had for localhost added also Omnia and that was 127.0.0.1, I have added line with: 192.168.1.1 omnia.lan omnia, and BAM ! all is right with world, thanks !

The default configuration does not allow me to connect to 127.0.0.1:port or localhost:port. What can I do to make it work and why this is not working ouf of the box?

I believe you are right.
In: /etc/init.d/kresd

I moved:
# include custom kresd config
include_custom_config

Up before:
config_get_bool do_forward “$section” forward_upstream 1
if [ “$do_forward” = “1” ] ; then

And now local resolution for non static hosts seams to work.

1 Like

@gclawes and @larsollen are you sure that this is necessary?

I’m asking as @Etz stated that simply adding the line (as explained by @glyphin) to the kresd.custom.conf worked for him to make it update-persistent. (As also reported by @kukulin, albeit he had to create the custom files first) .

I am willing to test as well, but I’ll have to wait for the next update for a definitive answer.

In some cases it is necessary because some of the kresd configuration options are order dependant.

I tried with just the custom file first, but that did not seam to work, then i changed the order and after that it worked, but did not verify it extensively. So cannot say for sure :wink:

1 Like

I worked around the policy rule ordering problem by putting in /etc/kresd/custom.conf

local lan_rule = policy.add(policy.suffix(policy.FORWARD(‘127.0.0.1@54’), policy.todnames({‘lan’, ‘42.30.172.in-addr.arpa’})))
policy.del(lan_rule.id)
table.insert(policy.rules, 1, lan_rule)

Using this method, the init file doesn’t need to be modified.

5 Likes

In this configuration of using dnsmasq for local domain and knot for everything else, is there a way to enable something like dnsmasq’s option to expand hosts? For example, if I do a lookup on a host with no suffix, it should add my local domain to it, like server becomes server.localdomain?

I tried adding a custom rule to forward requests using pattern matching where there is no dot in the qname but couldn’t get the syntax quite right. I suspect there’s a way to use a lua if statement to easily do it but I am not familiar enough with it to figure it out.

The testing I did seemed to indicate that, I was testing by starting kresd directly without the init script using the 2 files from that diff.

1 Like

So does that mean we have to move the include_custom_config up in /etc/init.d/kresd or is that superfluous?

I can confirm that using the custom config file (having moved that include) the reverse DNS for dynimac DHCP hostnames indeed works (no update of kresd yet though. But I join you in suspecting it will persist an upgrade).

@gclawes you still reckon we have to follow @larsollen’s instruction?

I updated the first post with new config instructions. These shouldn’t be overwritten by package updates now. Thanks to @eman for figuring out the lua needed to do this.

1 Like

@eman 's solution is still necessary for me in 3.5. @miska is this some kind of bug?

Same thing for me! I still have to change /etc/init.d/kresd