Using a TL-MR3020 as DNS server for local addresses

Hi, I'm trying to use a TL-MR3020 with LEDE 17.01.5 only as a DNS server in my LAN, the purpose is to resolve local hostnames such as "service1.raspberrypi", "service2.raspberrypi", etc. (or meybe service1.lan, service2.lan? Is it possible?) corrisponding to services hosted on a raspberry pi each one binded on a port of it.

So, I set my router to look for primary DNS server to the local IP of the MR3020 and the secondary one to 1.1.1.1. On LEDE i set DHCP client on LAN interface (I disabled onboard wifi and removed the interface, i don't need it), uncheked Use "DNS servers advertised by peer" and added manually 1.1.1.1 and 1.0.0.1.

Then, according to https://openwrt.org/docs/guide-user/base-system/dns_configuration I set a domain for the raspberry and a SRV record for his service, but SRV seems to not work.

This is my /etc/config/dhcp

config dnsmasq
        option domainneeded '1'
        option boguspriv '1'
        option localise_queries '1'
        option rebind_protection '1'
        option rebind_localhost '1'
        option local '/lan/'
        option domain 'lan'
        option expandhosts '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases'
        option localservice '1'
        option nonwildcard '0'
        option serversfile '/tmp/adb_list.overall'
        option resolvfile '/tmp/resolv.conf.auto'

config dhcp 'lan'
        option interface 'lan'
        option start '100'
        option limit '150'
        option leasetime '12h'
        option dhcpv6 'server'
        option ra 'server'

config dhcp 'wan'
        option interface 'wan'
        option ignore '1'

config odhcpd 'odhcpd'
        option maindhcp '0'
        option leasefile '/tmp/hosts/odhcpd'
        option leasetrigger '/usr/sbin/odhcpd-update'

config 'domain'
        option name 'raspberrypi'
        option ip '192.168.1.100'

config 'srvhost'
        option srv  'plex.raspberrypi'
        option target 'raspberrypi'
        option port 32400
        option class 0
        option weight 10

Where I'm wrong?

You never described a problem.

Since you're posting, though, I assume it's because you have set:

Only have clients use the OpenWrt DNS server. Otherwise it could Round Robin and get a query from 1.1.1.1 (which doesn't have your hostname records).

Thank you for answering, I thought the second DNS intervenes in the case did not answer the first, for a redundancy purpose. However I've removed second DNS in my router but the problem persists. Using nslookup command I can see that the DNS responding server is the MR3020 local IP (not 1.1.1.1 or others), and I think that the problem is the SRV record that doesn't work, because using nslookup I can retrieve IP of my raspberry pi but searching for the srv type it doesn't find it. Probably it's wrong how i wrote the SRV record or it isn't usefull for my purpose.

nslookup raspberrypi
Server:         192.168.1.199
Address:        192.168.1.199#53

Name:   raspberrypi
Address: 192.168.1.100
-------------------------------------------------
nslookup -type=srv plex.raspberrypi
Server:         192.168.1.199
Address:        192.168.1.199#53

** server can't find plex.raspberrypi: NXDOMAIN

Yes, but in your config, it's a SOHO router, it should be up anyways. Dnsmasq assumes that. In addition, you cannot use a DNS server that doesn't have the records you want. That simple.

Did you clear the client's cache?

You do not have an A Record in place for plex.raspberrypi (which would still be needed to reference a device by hostname); and you haven't explained why you are attempting to make a SVR Record.

Yes, i cleared cache. I've defined an SRV record because reading the page that i linked before it seemed to me that defining an SRV record was right for defining a subdomain (e.g. "plex.") of "raspberrypi" corrisponding to a service on the raspberry pi on a defined port (32400 in plex case). I've already defined an A record for the raspberry pi IP, but it alone can't bind a service or another hosted on the raspberry, the IP address is the same for all of them. So i tried to define that SRV record, but evidently it isn't right. I want associate the various services of the raspberry pi to corrispective subdomain of "raspberrypi", each subdomain.hostname is basically binded to a ip:port. How can i do that?

What service??? SRV records are very specialized DNS records. They are usually utilized by the client or server they were created for...so again...

What service???

  • SIP?
  • Multicast streaming?
  • Minecraft?
  • Kerberos?
  • M$ Exchange Autodiscover?

See:

SRV records are not used for that purpose. You either:

  • make an A record for that [sub]domain
  • create a sub-zone and add the A Record; or
  • delegate the zone to another DNS server

So, please provide more detail, it doesn't seem that a SRV record will solve whatever issue you're having.

I'm sorry, I try to explain me better. Services involved are a Plex server (multimedia streaming), a client torrent (transmission) and others. Each of those is a service onto the raspberry pi, accessible via their own web page typing "ip address of raspberry":port. For instance: 192.168.1.100:32400 is for Plex, 192.168.1.100:9091 for Transmission client torrent, and so on.

My purpose is to basically write into the browser "plex.raspberrypi", "transmission.raspberrypi" for rispectively plex and transmission instead for host:ip.

I've altready define an A record for binding the ip address 192.168.1.100 to hostname "raspberrypi" (obviously IP address is static). How to define those subdomains?

Are you trying to delegate a zone (requires another DNS server), or simply make another A Record for a third-level domain?

If you are simply making an A Record for a third-level domain:

config 'domain'
        option name 'host1.example.foo'
        option ip '192.168.1.100'

config 'domain'
        option name 'host2.example.foo'
        option ip '192.168.1.101'

config 'domain'
        option name 'host3.example.foo'
        option ip '192.168.1.102'

Also, Dnsmasq entries must be FQDNs. You cannot have a hostname without a domain after the empty period (i.e. your raspberrypi DNS entry is invalid on OpenWrt).

Sorry for hijacking this thread.I understand what OP tries to accomplish and actually I have the same problem.
I want to type a specified hostname instead of a local ip in my local network and get 'redirected' to the webinterface for ie. of my Synology NAS or maybe to my plex running on the same NAS different port.

I read Documentation DNS, but it is only useful for people who already know what they are doing.

I am trying to keep it simple:
my domainname is: lan
my hostname is: chef
my IP is: 192.168.1.168

What I love to accomplish is: I open my browser type chef and get redirected to 192.168.1.168.

I'm not sure why you didn't make a new thread, or simply follow the above example:

config 'domain'
        option name 'chef.lan'
        option ip '192.168.1.168'

http://chef.lan will now direct as you desire.

In the future, please create a new thread.

I did. But I always get mixed results. I used luci to set hostnames and static leases.
i.e. chef.lan is resolving.
i.e. grub.lan is not resolving.
/etc/config/dhcp has all the necessary information. I read nowadays everything is written/configured in this file. I am not sure what else could be wrong in my set-up. (I cleared browser caches, tried it from different machines).