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:
# 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
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
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