Discussion:
[Dnsmasq-discuss] resolving server's hostname
Carl Karsten
2017-02-17 08:06:16 UTC
Permalink
***@dc10b:~$ host dc10b
dc10b has address 127.0.1.1

It should be 10.20.1.3

How do I make that happen?
Albert ARIBAUD
2017-02-18 12:15:12 UTC
Permalink
Hi Carl,

Le Fri, 17 Feb 2017 02:06:16 -0600
Post by Carl Karsten
dc10b has address 127.0.1.1
It should be 10.20.1.3
How do I make that happen?
Hmm... Can you elaborate on the context of your problem? This does not
happen to me -- my machine even has an entry in its own /etc/hosts with
its name tied to 127.0.0.1 but a host or dig will return its LAN
address.

Amicalement,
--
Albert.
Carl Karsten
2017-02-18 15:31:19 UTC
Permalink
dc10b is the dnsmasq server

I am using a modified version of this:
https://anonscm.debian.org/git/debconf-video/ansible.git/tree/roles/dhcp-server

I haven't checked in the mods yet because things are still a little wonky.
git diff ... skimmed, don't see anything that would affect dnsmasq.

***@dc10b:~$ cat /etc/dnsmasq.d/local.conf
## Ansible managed

interface=eth-local
domain=lca2017.lan
dhcp-range=10.20.1.10,10.20.1.254,6h
dhcp-option-force=210,/srv/tftp/
dhcp-boot=pxelinux.0
dhcp-authoritative
enable-tftp
tftp-root=/srv/tftp


Hmm, on an openwtt ap running dnsmasq:

***@tpap:~# cat /etc/resolv.conf
search lan
nameserver 127.0.0.1

***@tpap:~# cat /etc/hosts
127.0.0.1 localhost

***@tpap:~# nslookup tpap
Server: 127.0.0.1
Address 1: 127.0.0.1 localhost
Name: tpap
Address 1: 192.168.1.2 tpap.lan
Post by Albert ARIBAUD
Hi Carl,
Le Fri, 17 Feb 2017 02:06:16 -0600
Post by Carl Karsten
dc10b has address 127.0.1.1
It should be 10.20.1.3
How do I make that happen?
Hmm... Can you elaborate on the context of your problem? This does not
happen to me -- my machine even has an entry in its own /etc/hosts with
its name tied to 127.0.0.1 but a host or dig will return its LAN
address.
Amicalement,
--
Albert.
Albert ARIBAUD
2017-02-18 18:06:45 UTC
Permalink
Hi Carl,

Le Sat, 18 Feb 2017 09:31:19 -0600
Post by Carl Karsten
dc10b is the dnsmasq server
Ok; and I assume that you are running 'host' on another machine, right?
Post by Carl Karsten
https://anonscm.debian.org/git/debconf-video/ansible.git/tree/roles/dhcp-server
Can't say it tells me much. :)
Post by Carl Karsten
I haven't checked in the mods yet because things are still a little
wonky. git diff ... skimmed, don't see anything that would affect
dnsmasq.
## Ansible managed
interface=eth-local
domain=lca2017.lan
dhcp-range=10.20.1.10,10.20.1.254,6h
dhcp-option-force=210,/srv/tftp/
dhcp-boot=pxelinux.0
dhcp-authoritative
enable-tftp
tftp-root=/srv/tftp
And what's the /etc/hosts?
Post by Carl Karsten
search lan
nameserver 127.0.0.1
127.0.0.1 localhost
Server: 127.0.0.1
Address 1: 127.0.0.1 localhost
Name: tpap
Address 1: 192.168.1.2 tpap.lan
What's 'tpap' supposed to be?

Anyway, my guess: your dnsmasq server has its own name listed in
its /etc/hosts with 127.0.1.1 as the matching IP, and your dnsmasq
config does not contain option no-hosts, so your dnsmasq uses
its /etc/hosts when resolving a name; ergo, it resolves its own name to
127.0.1.1.

Amicalement,
--
Albert.
Carl Karsten
2017-02-19 03:53:52 UTC
Permalink
Post by Albert ARIBAUD
Hi Carl,
Le Sat, 18 Feb 2017 09:31:19 -0600
Post by Carl Karsten
dc10b is the dnsmasq server
Ok; and I assume that you are running 'host' on another machine, right?
yes.
also running it on dc10b.
Post by Albert ARIBAUD
Post by Carl Karsten
https://anonscm.debian.org/git/debconf-video/ansible.git/
tree/roles/dhcp-server
Can't say it tells me much. :)
Post by Carl Karsten
I haven't checked in the mods yet because things are still a little
wonky. git diff ... skimmed, don't see anything that would affect
dnsmasq.
## Ansible managed
interface=eth-local
domain=lca2017.lan
dhcp-range=10.20.1.10,10.20.1.254,6h
dhcp-option-force=210,/srv/tftp/
dhcp-boot=pxelinux.0
dhcp-authoritative
enable-tftp
tftp-root=/srv/tftp
And what's the /etc/hosts?
***@dc10b:~$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 dc10b

# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Note: that is current. I have been changing the dc10b line, but it should
be clear in my posts what it is when I show test results.
Post by Albert ARIBAUD
Post by Carl Karsten
search lan
nameserver 127.0.0.1
127.0.0.1 localhost
Server: 127.0.0.1
Address 1: 127.0.0.1 localhost
Name: tpap
Address 1: 192.168.1.2 tpap.lan
What's 'tpap' supposed to be?
192.168.1.2

so this install does what I would expect.
Post by Albert ARIBAUD
Anyway, my guess: your dnsmasq server has its own name listed in
its /etc/hosts with 127.0.1.1 as the matching IP,
correct
Post by Albert ARIBAUD
and your dnsmasq
config does not contain option no-hosts,
correct
Post by Albert ARIBAUD
so your dnsmasq uses
its /etc/hosts when resolving a name; ergo, it resolves its own name to
127.0.1.1.
correct


so if I set no-hosts, how does dnsmaq figure out how to resolve dc10b?

ore really, what should I be doing so that 'things work as I expect' ?
Post by Albert ARIBAUD
Amicalement,
--
Albert.
Albert ARIBAUD
2017-02-19 08:59:45 UTC
Permalink
Hi Carl,

Le Sat, 18 Feb 2017 21:53:52 -0600
Post by Carl Karsten
[...]
so if I set no-hosts, how does dnsmaq figure out how to resolve
Post by Carl Karsten
dc10b?
Just the same way it does any other machine; the fact that a machine is
a name server does not make its name(s) or IP address(es) any special
in the *content* of the zone it serves.

For instance:

- some zone admins will want the local DHCP and DNS server(s) to not
have any entry in the local zone, because no machine in the LAN is
supposed to need refering them by name.

- some zone admins will want to give the DHCP server the name "dhcp"
and the DNS server the name "dns" because they want to be able to
not remember the actual IP address for them.

- some zone admins will want every machine on the LAN to have a name
which describes the make and model of the machine, e.g. "rpi-1234",
and they want this to apply to servers too.

- etc.

So, really, as far as the zone contents is concerned, dnsmasq does not
care whether an entry in it is the DNS server, DHCP server, or neither.
If you want the local machines to know that dc10b is 10.20.1.3, then
you should have an entry in the zone for it. Whether you do that with
an /etc/hosts line, or you use no-hosts and put a host-record option in
your dnsmasq configuration file is up to you. Either method works.
Post by Carl Karsten
ore really, what should I be doing so that 'things work as I expect' ?
What you should do is define what you expect :) -- i.e. decide how you
want to manage the content of your LAN zone.

For instance, in my case I want the the host running my dnsmasq known
by both a 'given name' and several functional names, and I want *all*
LAN host names in a single file different from he dnsmasq configuration
file, so I use addn-hosts to point dnsmasq to this file, which contains
among others the 'given' and functional names of the dnsmasq server
itself.

But how /you/ do it is really for /you/ to decide; the way /I/ do may
not fit your needs.

Amicalement,
--
Albert.
Carl Karsten
2017-02-19 14:59:37 UTC
Permalink
Thanks. I thought maybe I should just define it like all other machines,
but wasn't sure if the server's name was a special case.
Post by Albert ARIBAUD
Hi Carl,
Le Sat, 18 Feb 2017 21:53:52 -0600
Post by Carl Karsten
[...]
so if I set no-hosts, how does dnsmaq figure out how to resolve
Post by Carl Karsten
dc10b?
Just the same way it does any other machine; the fact that a machine is
a name server does not make its name(s) or IP address(es) any special
in the *content* of the zone it serves.
- some zone admins will want the local DHCP and DNS server(s) to not
have any entry in the local zone, because no machine in the LAN is
supposed to need refering them by name.
- some zone admins will want to give the DHCP server the name "dhcp"
and the DNS server the name "dns" because they want to be able to
not remember the actual IP address for them.
- some zone admins will want every machine on the LAN to have a name
which describes the make and model of the machine, e.g. "rpi-1234",
and they want this to apply to servers too.
- etc.
So, really, as far as the zone contents is concerned, dnsmasq does not
care whether an entry in it is the DNS server, DHCP server, or neither.
If you want the local machines to know that dc10b is 10.20.1.3, then
you should have an entry in the zone for it. Whether you do that with
an /etc/hosts line, or you use no-hosts and put a host-record option in
your dnsmasq configuration file is up to you. Either method works.
Post by Carl Karsten
ore really, what should I be doing so that 'things work as I expect' ?
What you should do is define what you expect :) -- i.e. decide how you
want to manage the content of your LAN zone.
For instance, in my case I want the the host running my dnsmasq known
by both a 'given name' and several functional names, and I want *all*
LAN host names in a single file different from he dnsmasq configuration
file, so I use addn-hosts to point dnsmasq to this file, which contains
among others the 'given' and functional names of the dnsmasq server
itself.
But how /you/ do it is really for /you/ to decide; the way /I/ do may
not fit your needs.
Amicalement,
--
Albert.
Continue reading on narkive:
Loading...