my current configuration is as follows:

I recieve Internet from the house I live in. It comes via Ethernet and has a DHCP running. The Problem is, that it is MAC-Adress limited to one device. Therefore I got my RPi 3B v1.2 configured as Wifi Router, wich is working fine. So the configuration is:

House-Internet --eth0--> Pi --wlan0--> Laptop

IP Ranges are:

eth0 172.x.x.x

wlan0 192.168.1.x

Here is a link to my interfaces-configuration: https://bit.ly/2DZ6DgX

DHCP for wlan0 is made by dnsmasq with standard settings.


What I want to do: I want to configure a second ethernet-adapter to use the same network as wlan0. The eth1 dongle is a generic usb ethernet adapter. So the internet (coming from eth0 and the same network/iprange as wlan0).

I tried creating a bridge between eth1 and wlan0 with brctl. As soon as I plugin a device on eth1, I won't get internet connection on both wlan0 and eth1.

Hope you can help me.

EDIT /etc/interfaces/:

# Localhost
auto lo
iface lo inet loopback

# Ethernet
auto eth0
allow-hotplug eth0
iface eth0 inet manual

auto eth1
allow-hotplug eth1
iface eth1 inet static

auto br0
iface br0 inet dhcp
bridge_ports eth1 wlan0
bridge_fd 0
bridge_stp off

# WLAN-Interface
auto wlan0
allow-hotplug wlan0
iface wlan0 inet static

# NAT und Masquerading aktivieren
up /sbin/iptables -A FORWARD -o eth0 -i wlan0 -m conntrack --ctstate NEW -j ACCEPT
up /sbin/iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
up /sbin/iptables -t nat -F POSTROUTING
up /sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

# IP-Forwarding aktivieren
up sysctl -w net.ipv4.ip_forward=1
up sysctl -w net.ipv6.conf.all.forwarding=1

# hostapd und dnsmasq neu starten
up service hostapd restart
up service dnsmasq restart

  • Please paste the interfaces-configuration into the question. I have an idea how to route a bridge but only with modern systemd-networkd. I don't use classic networking since years anymore. – Ingo May 12 at 22:42
  • Does using systemd-networkd is an option for you? – Ingo May 13 at 7:49
  • Hi Ingo, thanks for your answer. I am open to any solutions (including using systems-networkd ; But I personally have no experience with it) I updated the Interfaces in the Post – Marek P May 13 at 9:15
  • OK, what Raspberry Pi you are using? Is it a RPi 3B+? I assume you will add an USB/wired ethernet dongle as second interface eth1? – Ingo May 13 at 9:26
  • Its a RPi 3B v1.2. The eth1 dongle is a generic usb ethernet adapter. – Marek P May 13 at 13:58

I will show a solution in two steps using systemd-networkd. First I create an access point (wlan0) and bridge it with the wired connection (eth0). Then I configure routing between the bridge (br0) and the up-link (eth1).

For reference I use Raspbian Stretch Lite 2019-04-08 updated with sudo apt update && sudo apt full-upgrade && sudo reboot on 2019-05-13.

Example for this setup:
to be compatible with other examples from me I'm using different ip addresses. But it should not be a problem to replace them with yours.

          (dhcp)         bridge
           ╱    wifi    ┌───────┐
mobile-phone <~.~.~.~.> │(wlan0)│            wired           wan
                        │    br0│RPi(eth1) <───────> router <───> INTERNET
      laptop <────────> |(eth0) │╲      ╲            ╱
           ╲    wired   └───────┘╱     (dhcp)

♦ Setting up an access point (wlan0) and bridge it with wired ethernet (eth0)

Follow the instructions given in section "General setup" of Setting up a Raspberry Pi as an access point - the easy way.

Then create the following four files to configure interfaces.

rpi ~# cat > /etc/systemd/network/02-br0.netdev <<EOF

rpi ~# cat > /etc/systemd/network/08-wlan0.network <<EOF

rpi ~# cat > /etc/systemd/network/12-br0_add-eth0.network <<EOF

rpi ~# cat > /etc/systemd/network/16-br0_up.network <<EOF

Now we have to tell wpa_supplicant 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:

ExecStartPre=/sbin/iw dev %i set type __ap
ExecStartPre=/bin/ip link set %i master br0

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 and check if the bridge works. The mobile phone and the laptop should have an ip address from subnet and you should be able to ping the mobile phone from the laptop and vice versa.

♦ Configure routing between up-link eth1 and the bridge br0

Plug in the USB/ethernet dongle if not already done. You should have then an interface eth1. Now create this file to configure eth1:

rpi ~$ sudo -Es
rpi ~# cat > /etc/systemd/network/04-eth1.network <<EOF

Because the internet router only serves one device we have to use NAT (network address translation). To configure NAT you have to extend the wpa_supplicant service with:

rpi ~# systemctl edit wpa_supplicant@wlan0.service

In the editor with the entries we have done before add these statements to the [Service] section, save them and quit the editor. You can sort them to the other entries for good looking but the order doesn't matter.

ExecStartPre=/sbin/iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
ExecStopPost=-/sbin/iptables -t nat -D POSTROUTING -o eth1 -j MASQUERADE

That's it.

  • Thank you so much! I will try this and come back to report! – Marek P May 14 at 20:55

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.