[CentOS] Erratic local hostname resolution with Dnsmasq

Nicolas Kovacs

info at microlinux.fr
Wed Jan 2 15:09:51 UTC 2019


Hi,

My local server is running CentOS 7. The machine has two NICs and is
acting as a gateway. For DHCP and DNS, I'm using Dnsmasq. I have a
strange little problem with local hostname resolution. Before going into
more details, here's my configuration.

[root at nestor:~] # ifconfig
enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.2  netmask 255.255.255.0  broadcast 192.168.0.255
        ether 2c:27:d7:15:54:a1  txqueuelen 1000  (Ethernet)
        RX packets 17122  bytes 17596130 (16.7 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 13426  bytes 2144915 (2.0 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 18  memory 0xfe8e0000-fe900000

enp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.1  netmask 255.255.255.0  broadcast 192.168.2.255
        ether 00:22:64:8a:4c:c2  txqueuelen 1000  (Ethernet)
        RX packets 6597320  bytes 9692134059 (9.0 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 534283  bytes 57365155 (54.7 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16  memory 0xfe9e0000-fea00000

[root at nestor:~] # cat /etc/hostname
nestor

[root at nestor:~] # cat /etc/hosts
# /etc/hosts
127.0.0.1     localhost.localdomain localhost
192.168.2.1   nestor.microlinux.lan nestor
192.168.2.252 hp-officejet.microlinux.lan hp-officejet
192.168.2.253 nas.microlinux.lan nas
192.168.2.254 wifi.microlinux.lan wifi

[root at nestor:~] # cat /etc/resolv.conf
# /etc/resolv.conf
nameserver 127.0.0.1

[root at nestor:~] # cat /etc/dnsmasq.conf
# /etc/dnsmasq.conf
domain-needed
bogus-priv
interface=enp3s0
dhcp-range=192.168.2.100,192.168.2.200,24h
local=/microlinux.lan/
domain=microlinux.lan
expand-hosts
# Cloudflare
server=1.1.1.1
server=1.0.0.1
# Google
#server=8.8.8.8
#server=8.8.4.4
no-resolv
# Google
dhcp-host=D4:85:64:B2:B2:1B,alphamule,192.168.2.2
dhcp-host=00:1E:C9:43:A7:BF,bernadette,192.168.2.3
dhcp-host=00:1D:09:15:4A:D8,raymonde,192.168.2.4
dhcp-host=00:1E:C9:42:84:7B,amandine,192.168.2.5
dhcp-host=B8:CA:3A:D6:5A:43,1C:3E:84:32:7E:87,buzz,192.168.2.6
dhcp-host=90:E6:BA:CF:04:8F,64:70:02:9A:AC:93,balthazar,192.168.2.7
dhcp-host=08:00:27:00:00:01,centosbox,192.168.2.10
dhcp-host=08:00:27:00:00:02,susebox,192.168.2.11
dhcp-host=10:62:E5:D4:95:60,hp-officejet,192.168.2.252
dhcp-host=00:11:32:26:63:A5,nas,192.168.2.253

Now here's the problem. Some of the hostname are correctly resolved,
while others are not. Here's what it looks like when invoked from the
server.

[root at nestor:~] # host alphamule
alphamule has address 192.168.2.2
[root at nestor:~] # host bernadette
bernadette has address 192.168.2.3
[root at nestor:~] # host raymonde
Host raymonde not found: 3(NXDOMAIN)
[root at nestor:~] # host amandine
Host amandine not found: 3(NXDOMAIN)
[root at nestor:~] # host buzz
[root at nestor:~] # host balthazar
balthazar has address 192.168.2.7
[root at nestor:~] # host centosbox
Host centosbox not found: 3(NXDOMAIN)
[root at nestor:~] # host susebox
Host susebox not found: 3(NXDOMAIN)
[root at nestor:~] # host hp-officejet
hp-officejet has address 192.168.2.252
[root at nestor:~] # host nas
nas has address 192.168.2.253

Of course I could add all these hosts to /etc/hosts, but as far as I
understand, this *should* work with the hosts appearing only in
/etc/dnsmasq.conf. Or have I overlooked something ? Any suggestions ?

Cheers & happy new year,

Niki

-- 
Microlinux - Solutions informatiques durables
7, place de l'église - 30730 Montpezat
Site : https://www.microlinux.fr
Blog : https://blog.microlinux.fr
Mail : info at microlinux.fr
Tél. : 04 66 63 10 32


More information about the CentOS mailing list