Skip to main content
2 of 9
Eleminated startup failure and handle hotplug of the ethernet cable
Ingo
  • 43.1k
  • 20
  • 87
  • 207

Proxy arp is a way to build a pseudo bridge that is working on OSI layer 3 but it behaves like a real layer 2 bridge. So it is a good way to workaround the lack of WDS support on Raspberry Pi. Here is a way to set it up. In general I followed the tutorial (2). Have a look at it for the background.

For reference I use Raspbian Stretch Lite 2018-06-27 updated with sudo apt update && sudo apt full-upgrade && sudo reboot.

I will use systemd-networkd for reasons so first we have to switch over to it.

Install helpers and setup systemd-networkd

For detailed information look at (1). Here only in short. Execute these commands:

# enable journaling rpi ~$ sudo -Es rpi ~# mkdir -p /var/log/journal rpi ~# systemd-tmpfiles --create --prefix /var/log/journal #ignore warnings (*) # install helpers rpi ~# apt install parprouted dhcp-helper rpi ~# systemctl stop dhcp-helper rpi ~# systemctl enable dhcp-helper # disable classic networking rpi ~# systemctl mask networking.service rpi ~# systemctl mask dhcpcd.service rpi ~# sudo mv /etc/network/interfaces /etc/network/interfaces~ rpi ~# sed -i '1i resolvconf=NO' /etc/resolvconf.conf # enable systemd-networkd rpi ~# systemctl enable systemd-networkd.service rpi ~# systemctl enable systemd-resolved.service rpi ~# ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf 

(*) You will get one or two confusing warnings "...Cannot set file attribute..." This are not errors and doesn't matter in this case.

Configure wpa_supplicant

To configure wpa_supplicant create this file with your settings for country=, ssid= and psk=. You can just copy and paste this in one block to your command line beginning with cat and including EOF (delimiter EOF will not get part of the file):

rpi ~# cat > /etc/wpa_supplicant/wpa_supplicant-wlan0.conf <<EOF country=DE ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="[email protected]" psk="verySecretPassword" } EOF rpi ~# chmod 600 /etc/wpa_supplicant/wpa_supplicant-wlan0.conf rpi ~# systemctl disable wpa_supplicant.service rpi ~# systemctl enable [email protected] 

To configure the wlan0 interface create this file:

rpi ~# cat > /etc/systemd/network/08-wlan0.network <<EOF [Match] Name=wlan0 [Network] DHCP=yes IPForward=yes EOF 

Setup helpers

We have installed dhcp-helper, a proxy to get ip addresses from the wifi network, and parprouted that manages proxy arp.

Enable DHCP relay in /etc/default/dhcp-helper:

# relay dhcp requests as broadcast to wlan0 DHCPHELPER_OPTS="-b wlan0" 

Edit /etc/avahi/avahi-daemon.conf to enable mDNS relaying:

[reflector] enable-reflector=yes 

Raspberry Pi seems to be a bit buggy because proxy arp with it only works if promiscous mode is enabled on its wifi interface. Normaly it is not needed and has no theoretical background and is nowhere else documented. I have verified proxy arp on my laptop without promiscous mode. Maybe they will fix it in the future.

parprouted runs as a daemon but has no systemd unit installed. So we will make it and enable also promiscous mode:

rpi ~# systemctl edit --force parprouted.service 

In the empty editor insert these statements, save them and quit the editor:

[Unit] Description=proxy arp routing service Documentation=https://raspberrypi.stackexchange.com/q/88954/79866 [Service] Type=forking # Restart until wlan0 gained carrier Restart=on-failure RestartSec=5 TimeoutStartSec=30 ExecStartPre=/lib/systemd/systemd-networkd-wait-online --interface=wlan0 --timeout=6 --quiet ExecStartPre=/bin/echo 'systemd-networkd-wait-online: wlan0 is online' # clone the dhcp-allocated IP to eth0 so dhcp-helper will relay for the correct subnet ExecStartPre=/bin/bash -c '/sbin/ip addr add $(/sbin/ip -4 -br addr show wlan0 | /bin/grep -Po "\\d+\\.\\d+\\.\\d+\\.\\d+")/32 dev eth0' ExecStartPre=/sbin/ip link set dev eth0 up ExecStartPre=/sbin/ip link set wlan0 promisc on # v minus sign ExecStart=-/usr/sbin/parprouted eth0 wlan0 ExecStopPost=/sbin/ip link set wlan0 promisc off ExecStopPost=/sbin/ip link set dev eth0 down ExecStopPost=/bin/bash -c '/sbin/ip addr del $(/sbin/ip -4 -br addr show eth0 | /bin/grep -Po "\\d+\\.\\d+\\.\\d+\\.\\d+")/32 dev eth0' [Install] [email protected] 

Enable the service:

rpi ~# systemctl enable parprouted.service 

Reboot.
That's it.


references:
[1] Howto migrate from networking to systemd-networkd with dynamic failover
[2] Bridging Network Connections with Proxy ARP

Ingo
  • 43.1k
  • 20
  • 87
  • 207