Running openwrt-mt6000-4.8.2-op24-0903-1756864663
Using the new OP24 luci/admin/network/dhcp DNS Records and Static Leases functions
I’m trying to add two CNAME records for a NAS. I’ve added static leases for the NAS (and a couple other devices), added Host definitions, and added the CNAME definitions. As near as I can tell I’ve successfully added the required definitions … and it works … sometimes. It did not work initially - including after a reboot of the router. Then, out of the blue, it started working. It worked fine yesterday, even across a reboot of the router. Then, sometime last night it stopped working. This morning I’ve tried rebooting both the NAS and the router but neither helped.
Background:
I have a mail server running on a NAS and am mapping the name LanMail to the NAS. All my various backups (and similar stuff) write status emails to LanMail. I’ve been doing this for years using an ASUS router running the Merlin software but wanted to use a router where CNAME records could be added via native firmware functions. The GL-iNet / OpenWrt firmware seemed the ideal solution, but I can’t get it to work consistently.
I’ve attached a zipped .txt file containing my /etc/config/dhcp file (with MAC addrs obfuscated). I don’t see anything wrong except maybe the order of the statements. The NAS host name is “DS218_2” (and yes, that underscore gave me some problems with the LuCI GUI). The added name (as I said above) is “LanMail”.
I’d really appreciate it if someone can point out my error. I tried going back to my old ASUS router and it promptly died so I need to get this to work on the MT6000.
BTW, the NAS was also given an IPv6 unique local address. I don’t see why that would be interfering, but I kn ow very little about IPv6.
BTW #2: In another post someone mentioned /etc/dnsmasq.conf. I looked in it, but it’s all comments.
BTW #3: I had to zip the text file because this forum does not allow attaching text files - just various image files.
Hmm from what I learned from cnames because it never worked for me either long times ago for minecraft servers, cnames only are usefull to point a domain name to a other.
but if you don't have a second domain on one of the hosts then use a A record and AAAA for ipv6.
These A records give a ip to a domain, cnames only redirect you to the other domains ip.
Well, the pointing one domain to another was exactly what I want. My original thought was that I could move my mail server from one NAS to another and just change the CNAME record. But to make it work reliably (on my old ASUS router) I had to add the static lease. That made the idea of moving the mail server untenable. Still, the CNAME has worked reliably for many months. I assume that it should work just as reliably on the GL-iNet router … if I get all the pieces correctly in place.
I have no idea how the stuff in /etc/config/dhcp get given to dnsmasq - not via the /etc/dnsmasq.conf file since that seems to be just comments - but it’s dnsmasq that needs the CNAME record data.
With OpenWrt I had some issues with assigning a host in the static leases area.
I know in OP24 versions you have in luci just the ability to add records yourself including A records.
A config inside the /etc/config/dhcp looks like:
config domain
option name 'kvm2.lan'
option ip '10.46.214.101'
Can you try to define it like that and see if the cname records work?
Edit:
A bit technical, but the config is managed by uci, and probably a rpc script from the dnsmasq service translates it into configuration files dnsmasq can read, these are located in /tmp which is a folder what is mounted to memory, basicly wiped after restart.
Generally you don't want to touch /etc/dnsmasq.conf as it is prone to easy configuration mistakes, but this config will act as a global config, I think it will also override stuff, so use it only for domains (I do that for lancache).
My previous router - an ASUS router running the Merlin 3rd-party firmware - had a similar implementation where users could put dnsmasq records in a file in nonvolatile storage. These would get added to dnsmasq config file in /tmp before dnsmasq startup by some Merlin function.
The LuCI interface is much more user-friendly and the support is contained in the native GL-iNet firmware. That feels like a much safer implementation. Too bad I can’t get it to work consistently. Using a Host / A record definition rather than a CNAME record definition was the solution.
But I’d still like to know what I was doing wrong with the CNAME definition. I know dnsmasq can accurately handle them.
Give them both a A record first like my example in /etc/config/dhcp because the host field in the static leases are not reliable in luci the static ip remains functional, I found this myself as well.
Then add the cnames like you have been used to
That must be the trick.
Newer lucis in more recent OpenWrt actually get a full dns zone tab, the config stanza is taken from that rather than from the static leases, I guess in the static leases it only works as a pointer to name a device but not as a domain.
I’m not sure if the name you are showing is the “domain” name (as used in the LuCI CNAME definition panel) or the “target” name. If the target, then I’ve done that; it shows in the /etc/config/dhcp file). But if I give the “domain” host names A records (which I have now done) then there is no reason to supply CNAME records (so I’ve removed them).
I now have it working by giving all of real devices (the targets of the CNAME definitions) Host definitions tying a name and an IPv4 address to their MAC addresses) and giving the secondary names (the domain name of the CNAME definition) a Domain definition tying the name to one of the addresses defined in the HOST definitions.
I could try the CNAME definitions again but that makes little sense since I’ve hard coded all addresses.