You removed the country code from the configuration file /etc/hostapd/hostapd.conf to get an ip address from your wifi router. I mean it is better to use your country code. As you see the router checks the country code and without it you may have a minimal common setup. It is possible that your router gives you better and more specific settings for your country.
The other issue that the DHCP server does not send you the ip address from your custom DNS server is a real problem. I haven't seen it so far but I can confirm this bug.
In man systemd.network section [DHCPServer] you found the settings to configure it in a /etc/systemd/network/*.network
file. Setting only EmitDNS=
will get the option for the DNS server from the "uplink". For my understanding it means: for the RasPi itself you get an ip address and options (e.g. DNS server ip address) from your wifi router. That is what they mean with "uplink". This settings are taken and sent by the access point to the stations. With an additional entry DNS=
this ip address is sent.
I have made some extensive tests to find what's going wrong. First I setup a simple stand alone access point with wpa_supplicant using the interface wlan0 as shown in Setting up a Raspberry Pi as an access point - the easy way. For /etc/systemd/network/12-ap.network
I use:
[Match]
Name=wlan0
[Network]
Address=192.168.4.1/24
DHCPServer=yes
[DHCPServer]
EmitDNS=yes
DNS=192.168.10.254
This works, means the station gets the DNS ip address 192.168.10.254 into /etc/resolv.conf
from the DHCP server, if we have a Debian like station. Next I setup a stand alone access point with hostapd also using only interface wlan0. I have taken a modified setup from Access point as WiFi repeater, optional with bridge. This also works by getting the right entry in /etc/resolv.conf
. Next I setup the access point with interface ap0 and the wifi client connection with interface wlan0 as described. It does not work. The local resolver does not modify resolv.conf for the right DNS server ip address. So the problem is the virtual interface ap0, as you already guessed.
wlan0 and ap0 have both the same mac address by default. I tried to give ap0 its own mac address and set the interface to promiscuous mode, for example:
rpi ~$ sudo ip link set ap0 address b8:27:eb:06:e8:8c
rpi ~$ sudo ip link set ap0 promisc on
It does not help.
Another idea was to use interface wlan0 for the access point and the virtual interface for the client connection to the wifi router. For this we have to set wlan0 to type ap
and then add the virtual interface with type managed
:
rpi ~$ sudo iw dev wlan0 set type __ap
rpi ~$ sudo iw dev wlan0 interface add sta0 type managed
command failed: Operation not supported (-95)
rpi ~$
Does not work.
To workaround this with dnsmasq look at Access point as WiFi repeater, optional with bridge, section Troubleshooting.
Raspbian Stretch comes with systemd version 232. I will use a test environment with the latest stable version but at least version 239. If it also does not work I file a bug report to systemd.
I will report next.
/etc/resolv.conf
works. Maybe we need different mac addresses on ap0 and wlan0? Next step: verify AP with hostpad on interface wlan0./etc/resolv.conf
. Seems hostapd is the problem. Will see ...