1

I have attempted to set-up a Wifi repeater on a Raspberry pi zero W using this very good tutorial : Access point as WiFi repeater, optional with bridge

Meanwhile i have 2 problems :

  1. No IP address received from the wifi router.. I solved it by removing the line "country_code=DE" in file /etc/hostapd/hostapd.conf.

  2. No DNS server address provided by DHCPserver to Wifi AP clients. If i ping an ip address (ex : 8.8.8.8), i get the answers. If i use a name (ex: ping google.com), that dont work. This is also the case if i put a fixed DNS address in /etc/systemd/network/12-ap0.network. If i force a DNS address (8.8.8.8) inside the client, i get the full internet access (tested on my iphone) but this is not a solution

I have searched in the systemd.network man page in section dedicated to DHCPserver and more specifically the EmitDNS item. They speak about the propagation of the uplink DNS address. This should be the solution. But i dont find where this uplink data is taken from as they say this is not from /etc/resolv.conf. May be a problem linked to the fact the ap0 is on the same internal wifi adapter than wlan0 ?

Do you have an idea on how to fix this DNS problem ?

Best regards JeanMarc

JeanMarc78
  • 11
  • 1
  • 4
  • Hi JeanMarc78, I have tested the DNS nameserver settings with bridge setup and on the ethernet interface and it seems to work. But now I'm just looking at the simple AP setup and I also don't get the DNS server settings. Just a moment please. I'm looking what's going wrong. – Ingo Nov 09 '18 at 13:44
  • First step to a solution: after looking what could be wrong without success, I followed your guess that there could be a problem with the virtual interface ap0. I setup an AP with wpa_supplicant on interface wlan0 according to Setting up a Raspberry Pi as an access point - the easy way. With this, getting a DNS server in /etc/resolv.conf works. Maybe we need different mac addresses on ap0 and wlan0? Next step: verify AP with hostpad on interface wlan0. – Ingo Nov 09 '18 at 22:31
  • hostapd on interface wlan0 without ap0 does not work, means I do not get a DNS server in /etc/resolv.conf. Seems hostapd is the problem. Will see ... – Ingo Nov 09 '18 at 23:32
  • Thank you Ingo for your answers. With the settings,from yourtutorial, i also got a DNS address in /etc/resolv.conf but as indicated in the systemd-network man page, they dont use it. Yes it seems hosptapd is the problem or a problem setting ap0 before wlan0 as it is not very clear in the doc of hospapd EmitDNS which lease must be set before hostapd needs it – JeanMarc78 Nov 10 '18 at 10:36
  • Little error in my previous answer, EmitDNS is part of systemd-network man page, not hostapd one. This is DHCP server which should provide the DNS server address not hostapd. – JeanMarc78 Nov 10 '18 at 11:32
  • From man systemd.network - [DHCPServer]: "DNS server propagation does not take /etc/resolv.conf into account." That's only for sending DNS option by the DHCP server. The client definitely uses the entry in /etc/resolv.conf. I have verified it with tcpdump. Default DNS server (on the client) are defined in /etc/systemd/resolved.conf if you use systemd-resolved. So if you see your own DNS server in /etc/resolv.conf then propagation of the DNS server option by the DHCP server is working. That is not the case with hostapd. – Ingo Nov 10 '18 at 16:27
  • Interface ap0 doesn't matter. In my test environment I only use one interface wlan0 and propagation DNS server also does not work with hostapd. I'm just going to verify another resolver; the default one openresolv we have disabled with `resolvconf=NO' in /etc/resolvconf.conf. – Ingo Nov 10 '18 at 16:36

3 Answers3

2

I was redirected here from the excellent thread of Ingo because I'm trying to make my RPi3 to act as WiFi extender. Like you, I followed every steps and I noticed that a device connected to the extended WiFi network couldn't get any DNS address from the primary Wireless router.

Something draws my attention on Troubleshooting section. @Ingo explains that hacker should modify the /etc/systemd/network/08-wlan0.network file. But I think Ingo may have mixed the 08-wlan0.network and 12-ap0.network file.

Indeed, we should do :

rpi ~# cat > /etc/systemd/network/12-ap0.network <<EOF
[Match]
Name=ap0
[Network]
Address=192.168.4.1/24
DHCPServer=yes
[DHCPServer]
DNS=8.8.8.8 1.1.1.1
EOF

Once modified and rebooted, everything seems to work fine, no need to install and set up isc-dhcp-server package.

I would like to edit a comment or a reply on the original post, but my profile is too new for it. So, I use this one. Hope it helps ...

DioZ
  • 21
  • 2
0

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.

Ingo
  • 42,107
  • 20
  • 85
  • 197
0

I just made a test by removing the hostapd internal DHCPserver (DHCPserver=no in place of yes in /etc/systemd/network/12-ap0.network) and by installing the isc-dhcp-server package. And that is OK when i configure static DNS addresses in /etc/dhcp/dhcpd.conf. The wifi client connected to the ap0 AP now gets an IP address and the DNS server address. I still need to find how to set the dhcp.conf to propagate the DNS server address received on router side

JeanMarc78
  • 11
  • 1
  • 4
  • To propagate DNS server you have to set option domain-name-servers ip-address [, ip-address... ]; in /etc/dhcp/dhcpd.conf not in dhcp.conf. – Ingo Nov 25 '18 at 11:39