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

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,961
  • 20
  • 87
  • 207
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