[Dnsmasq-discuss] Dynamic address config?

Geert Stappers stappers at stappers.nl
Thu Nov 24 18:18:29 UTC 2022


On Thu, Nov 24, 2022 at 08:47:28AM +0100, Matus UHLAR - fantomas wrote:
> On 24.11.22 10:10, Feng Shao wrote:
> > On Wed, Nov 23, 2022 at 5:28 PM Geert Stappers wrote:
> > > On Wed, Nov 23, 2022 at 01:47:27PM +0800, Feng Shao wrote:
> > > > There are a bunch of machines in our lab, and we normally don't have DNS
> > > > records configured for them, only accessing by IP. In order to ssh to them
> > > > with key auth, I have a config in my .ssh/config like
> > > >
> > > > Host *.mylab
> > > >   User root
> > > >   IdentityFile ~/.ssh/id_rsa.work
> > > >
> > > > and I have some "address=/123.123.123.123.mylab/123.123.123.123" line in
> > > > dnsmasq.conf. The problem here is I need to add an entry whenever a new IP
> > > > comes.
> > >
> > > So share with us a more representive sample set of such entries.
> > >
> > In dnsmasq.conf, I have lines like:
> > address=/123.123.123.123.mylab/123.123.123.123
> > address=/123.123.123.124.mylab/123.123.123.124
> > address=/123.123.123.125.mylab/123.123.123.125
> > address=/123.123.123.126.mylab/123.123.123.126

Strange hostnames.  Consider `nodeNNN.mylab` like

  address=/node123.mylab/123.123.123.123
  address=/node124.mylab/123.123.123.124
  address=/node125.mylab/123.123.123.125
  address=/node126.mylab/123.123.123.126 [1]


> > } } Can this configuration be dynamically? For example,
> > } } "address=/*.mylab/somecmd %1", where "somecmd" is a external command and %1
> > } } will be replaced by the name in A/AAAA request. So that for any DNS request
> > } } to *.mylab, dnsmasq invoke this external command and pass the name as
> > } } argument, the output of external command, which will be interpreted as
> > } } IPv4/IPv6 addr then responsed to client?
> > } 
> > } Advice:  Use an open question to start a discussion.
> > } 
> > 
> > The requirement is I want to ssh any host in my lab without password, I am
> > open to any other solution.
>
> configuring /etc/hosts and thus providing DNS for those hosts is easier than
> configuring those hosts in dnsmasq configuration.
>

Yes, that could work.  But for an untold reason[2] there was request
for "dynamically" or a feature request/advice.  As far as I known
nothing like such exists in dnsmasq. Here an idea, just an idea:

  server=/mylab/127.0.0.1#5354

And at port 5354 on localhost is an "Domain Name Server" that does
the requested dynamic address config / dynamic address translation.


Groeten
Geert Stappers

[1] Use 192.0.2.0/24 for documentation (
https://en.wikipedia.org/wiki/Reserved_IP_addresses )
[2] Maybe a XY-problem, explained at https://xyproblem.info/
-- 
Silence is hard to parse



More information about the Dnsmasq-discuss mailing list