To bridge eth0 with wlan0 I will start with the setup you have already done with Access point as WiFi router/repeater with additional WiFi-dongle.
You will get this setup:
(dhcp
from RPi) bridge
╱ wifi ┌───────┐
mobile-phone <~.~.~.~.> │(wlan0)│ wifi wan
│ br0│RPi(wlan1) <.~.~.~.~> router <───> INTERNET
laptop <────────> | (eth0)│╲ ╲
╲ wired └───────┘╱ (dhcp
(dhcp 192.168.4.1 from router)
from RPi)
From the already done setup first rename 08-wlan0.network
:
rpi ~$ sudo -Es
rpi ~# mv /etc/systemd/network/08-wlan0.network /etc/systemd/network/16-br0_up.network
and change line Name=wlan0
into Name=br0
in /etc/systemd/network/16-br0_up.network
.
Then add these two files:
rpi ~# cat > /etc/systemd/network/02-br0.netdev <<EOF
[NetDev]
Name=br0
Kind=bridge
EOF
rpi ~# cat > /etc/systemd/network/04-br0_add-eth0.network <<EOF
[Match]
Name=eth0
[Network]
Bridge=br0
EOF
Now we have to tell wpa_supplicant for wlan0 to use a bridge. We do it by modifying its service with:
rpi ~# systemctl edit wpa_supplicant@wlan0.service
In the empty editor insert these statements, save them and quit the editor:
[Service]
ExecStartPre=/sbin/iw dev %i set type __ap
ExecStartPre=/bin/ip link set %i master br0
ExecStart=
ExecStart=/sbin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant-%I.conf -Dnl80211,wext -i%I -bbr0
ExecStopPost=-/bin/ip link set %i nomaster
ExecStopPost=-/sbin/iw dev %i set type managed
Reboot.
That's it.
Update in respect of a comment:
The interfaces are still wlan0 and wlan1 but on some boots the onboard is wlan0 and sometimes wlan1.
This is a classical use case for Predictable Network Interface Names. You should enable it and use the new interface names instead of wlan0 and wlan1. The new names, for example enp9s0 (wired) or wlxe894f61b0a92 (wireless), will never change. To enable predictable network interface names you can use sudo raspi-config
and select 2 Network Options -> N3 Network interface names
. If this doesn't help you can also append net.ifnames=1
to the line in /boot/cmdline.txt
.
assign an ip address
towlan0 (10.17.1.1/24)
andeth0 (10.17.0.1/24)
interfaces. 2)Bind
your dhcp server on this precise addresses andconfigure the 'client network' scope
in configuration file. 3) start the DHCP daemon(s ?). – Ephemeral Jun 25 '19 at 20:21