What you want to do isn't possible with the current dnsmasq. There's an "expand-hosts" option which adds the domain the bare names in /etc/hosts, but it doesn't apply to CNAMES or anything else.

On most unix systems there's an option in /etc/resolv.conf called ndots, which is set to zero avoids a query for a bare name being expanded with the host's domain. I don't know if that option or its equivalent exists in MacOS.


Simon.


On 06/02/2022 18:03, Ken Gillett via Dnsmasq-discuss wrote:
The problem is that I have set up several CNAMEs that work when I simply use 
the 'host' command, but fail when I use 'ping' to that same name. The actual 
responses I outlined in my original question.

To be clear I understand what the manual page is stating, but it does NOT 
mention (that I can find) how to deal with domains. I was able to set this up 
using bind (as used in MacOS server), but not in dnsmasq.

This is all just on the local network. Various hosts have their A record which 
works whether simply testing to resolve the name (I use 'host' as it's simple) 
or actually addressing that dns name with an application/program (e.g. 'ping'). 
I just want to be able to use alternate names for that host. Alias if you like, 
or CNAME in dnsland.

I have in fact been able to make it work in dnsmasq by adding the domain name 
to every cname entry (but not the target), but that makes little sense to me 
and requires that domain name to be 'hard coded' in the dnsmasq set up, 
multiple times for every cname entry (i.e. for every actual cname being 
declared). This is quite the opposite of how bind is configured and in any 
case, I would really like to be able to configure dnsmasq cnames without 
reference to the domain. If I have a host called e.g. host1 and I set up cnames 
to that as e.g. host2 and host3 etc, I would like that to operate in any domain 
name I choose. So if I try and access host2, it will always mean i access 
host1, no matter what overall domain I decide to use for this subnet.

So anywhere host2 (or host3 etc) is used, just swap that with host1. 
Irrespective of any domain name in current use.


Ken  G i l l e t t

_/_/_/_/_/_/_/_/



On 6 Feb 2022, at 16:51, Geert Stappers via Dnsmasq-discuss 
<dnsmasq-discuss@lists.thekelleys.org.uk> wrote:

On Sun, Feb 06, 2022 at 04:02:40PM +0000, Ken Gillett wrote:
On 4 Feb 2022, at 20:46, Ken Gillett wrote:

I have several CNAMEs set up in DNSmasq on my Mac server that I
thought were working. If I use the 'host' command to check a CNAME
e.g :-

        host thecname

it returns:-

        thecname is an alias for thetarget.
        thetarget has address xx.xx.xx.xxx

So looks good, but…

I now realise that all is not well. If I instead:-

        ping thecname

it returns:-

        ping: cannot resolve thecname: Unknown host

Which is apparent nonsense as it has just resolved that exact CNAME.
The problem appears to be that the client Mac performing the query
adds the domain name, so DNSmasq needs to resolve thecname.thedomain
(which is not cofigured), as if I use:-

        ping thecname.

It works.

Previously I used MacOS Server's DNS (BIND) and a CNAME is listed as:-

        thecname IN  CNAME thetarget.thedomain.

Which works perfectly. However, if I try something similar in DNSmasq, it 
simply fails.

If instead I create the DNSmasq cname as:-

        cname=thecname.thedomain,thetarget

That seems to work. But

Apart from being the inverse of how BIND configures CNAMEs, how can
I configure DNSmasq CNAMEs to work without having to add thedomain
to every cname in every CNAME record in DNSmasq? I don't like to
hard code things like that as it could change. Is there any way to
make DNSmasq deal with this appropriately?


Quote from https://dnsmasq.org/docs/dnsmasq-man.html

--cname=<cname>,[<cname>,]<target>[,<TTL>]
     Return a CNAME record which indicates that <cname> is really
     <target>. There is a significant limitation on the target; it must
     be a DNS record which is known to dnsmasq and NOT a DNS record
     which comes from an upstream server. The cname must be unique,
     but it is permissible to have more than one cname pointing to the
     same target. Indeed it's possible to declare multiple cnames to a
     target in a single line, like so: --cname=cname1,cname2,target

     If the time-to-live is given, it overrides the default, which is
     zero or the value of --local-ttl. The value is a positive integer
     and gives the time-to-live in seconds.


Any help with the CNAME problem?


Answering that as

} Could I please get some help with what I call  "the CNAME problem"?

In manual pages are square brackets used to indicate what is optional.
Optional meaning "can left out" so
--cname=<cname>,[<cname>,]<target>[,<TTL>]
becomes
--cname=<cname>,<target>
and that matches
} }     cname=thecname.thedomain,thetarget.thedomain

Back to the "the CNAME problem".
Please elaborate it.  ( Because I don't get the "problem". )


Groeten
Geert Stappers
--
Silence is hard to parse

_______________________________________________
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss


_______________________________________________
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss

_______________________________________________
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss

Reply via email to