Score:0

local DNS with dnsmasq not working for client

cz flag

I'm trying to setup my raspberry Pi, running with Ubuntu server 20.04, as a wireless router so I can create a local network behind my raspberry pi.

I'm using hostapd to create a Wifi Access Point and dnsmasq to have a local DNS and DHCP server. The DHCP server seems to work fine: when a client connect (my macbook for instance), it get an IP in the range defined by the DHCP.

But I have issue with the DNS server for local domain name defined in the /etc/hosts. It works fine on the Rasp Pi but not for the client: when I try nslookup gw.wlan from the client shell I got:

Server:     1.1.1.1
Address:    1.1.1.1#53

** server can't find gw.wlan: NXDOMAIN

gw.wlan is defined in the /etc/hosts of the rasp Pi (see below)

Any idea why dnsmask doesn't read the /etc/hosts file ?

It works fine for internet domain name. If I run ping google.fr in the client shell it pings google just fine. Only local domain name are not resolved.


Here are my configuration files:

  • /etc/dnsmasq.conf:
# Listening interface
interface=wlan0

# Pool of IP addresses served via DHCP
dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h

# Local wireless DNS domain
domain=wlan

# Alias for this router
address=/gw.wlan/192.168.4.1

# Fix ip for a client
dhcp-host=98:01:a7:95:63:13,192.168.4.2

# Route
dhcp-option=3,192.168.4.1
listen-address=127.0.0.1,192.168.4.1
localise-queries
local=/wlan/
  • /etc/netplan/01-netcfg.yaml:
network:
  version: 2
  renderer: networkd
  ethernets:
    wlan0:
      dhcp4: false
      addresses:
        - 192.168.4.1/24
  • /etc/hosts :
127.0.0.1 localhost ubuntu
192.168.4.1 gw.wlan
192.168.4.2 jjmac.wlan

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
  • /etc/resolv.conf :
domain wlan
search wlan
nameserver 192.168.4.1
nameserver 8.8.8.8
nameserver 1.1.1.1
  • /etc/systemd/resolved.conf :
DNSStubListener=no
waltinator avatar
it flag
Eliminate the last 2 `nameserver` lines. Those servers will know nothing about `.wlan`. Also, in `dnsmasq.conf`, there's an inconsistency between `dhcp-address=` and `listen=`. Why an IPv6 address only in one?
cylon86 avatar
cz flag
@waltinator thx for your reply, the last two nameserver (8.8.8.8 and 1.1.1.1) are there so I can have internet access from the server. I don't see the inconsistency in the addresses, where do see a `dhcp-address` ? maybe the line `dhcp-host=98:01:a7:95:63:13,192.168.4.2` is confusing but it actually define the ip of the client with the defined mac address, not the ip of the host
cylon86 avatar
cz flag
I also edit my initial post. I added ip masquerade so now internet domain name are well resolved, only local domain name are not
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.