2

I followed the answer to this question:

Access point as WiFi router/repeater with additional WiFi-dongle

To have my 3 B+ act as a WiFi hotspot where wlan1 connects to the internet (WAN) and the pi acts as a router with devices connecting to wlan0 on the LAN side.

That works great but I also want to connect a LAN device to eth0

I think I just need to bridge eth0 and wlan0 but haven’t been able to make it work.

  • I will extend the setup you have used, with a bridge with wlan0 and eth0. Just a moment please. – Ingo Jun 25 at 8:20
  • An dhcp server must run on your AP for wireless clients private network (assume wlan0) and on Ethernet (assume eth0) for wire clients private network. I cannot help you because I'm not familiarized with the default dhcp server but if you use dnsmasq , then I can help you. But the steps are the same : 1) assign an ip address to wlan0 (10.17.1.1/24) and eth0 (10.17.0.1/24) interfaces. 2) Bind your dhcp server on this precise addresses and configure the 'client network' scope in configuration file. 3) start the DHCP daemon(s ?). – Ephemeral Jun 25 at 20:21
  • For dnsmasq I use two instance (yes two dhcp and dns server listening on two different network) for that. I exclude necessary interfaces in dnsmasq.conf for dhcp and dns, bind the interfaces on specific assigned ip addr .... and It's work for me. – Ephemeral Jun 25 at 20:22
  • @lngo - that would be very much appreciated. – William Meyer Jun 26 at 15:43
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.