3

My hardware setup is currently:

Router -> RPi (eth0) -> RPi (wlan0) -> subnet for my devices

My desired setup is:

Router -> RPi (eth0) -> RPi (wlan0 + eth1) -> subnet for my devices

My setup:

The RPi access point creates a new subnet with hostapd and dnsmasq. It distributes new IP addresses over wlan0, while getting its internet access over eth0. eth0 is the interface of the dedicated ethernet port on my RPi.

I connected a USB-Ethernet dongle to my RPi to provide a wired connection to some devices. It is detected as eth1. All devices connected to it (via a switch) need to live within the same new subnet and be able to find the devices connected over wlan0.

I used RaspAP for my initial setup, but manual steps might be necessary now I think.

Creating a second hostapd config for eth1 would just open a second subnet, as far I understand, so that's not what I want. I read something about installing a bridge for wlan0 and eth1 (or "bonding" them together), and then choose the newly created interface as the AP interface via RaspAP but I didn't get it to work correctly.

What is the correct/best way to establish a subnet which can be accessed simultaneously via wifi (wlan0) and the USB dongle (eth1) of the RPi?

Edit: My dhcpcd.conf looks like this:

interface wlan0
static ip_address=10.3.141.1/24
static routers=10.3.141.1
static domain_name_servers=1.1.1.1 1.0.0.1
interface eth1
static ip_address=10.3.141.1/24
static routers=10.3.141.1
static domain_name_servers=1.1.1.1 1.0.0.1
interface eth0
static ip_address=10.168.57.151/24
static routers=10.168.57.1
static domain_name_servers=10.168.57.1 8.8.8.8

Adding # to either the 4 eth1 or wlan0 rules makes the other work, but having both entries uncommented, only the lower one works. Maybe it has something to do with conflicting static IP addresses or the router IP address, but doesn't they need to be the same, if I want them to be in the same subnet?

UPDATE with info from comment:
I am using a Raspberry Pi 2 Model B Rev 1.1 with Raspbian GNU/Linux 9 (stretch) and the TP-Link TL WN823N RTL8192EU WiFi Dongle.

Ingo
  • 42,961
  • 20
  • 87
  • 207
Felix Bernhard
  • 133
  • 1
  • 7

2 Answers2

4

If you are open to use another modern all-in-one networking environment without needing additional helpers like hostapd, dnsmasq or bridge utils you can use systemd-networkd. It makes life easier. It is part of the default Raspbian image and you only have to enable and configure it. Here is a tested and working setup for what you want to do: Configuring Raspberry pi as Router, Wifi and Ethernet Bridge. The only difference is that it uses eth0 for the bridge and eth1 as uplink but it should not be a big issue to just swap the interfaces in the setup or just swap the ethernet cables on your RasPi ;-)

Seamus
  • 23,558
  • 5
  • 42
  • 83
Ingo
  • 42,961
  • 20
  • 87
  • 207
0

What you want is a bridge device. This would be "br0" instead of "wlan0" and "eth1".

Then I believe you list the bridged devices on a "bridge_ports" line in /etc/network/interfaces or equivalent.

In any case, you install bridge-utils, and the "brctl" command gets run automatically when you run ifup and ifdown.

You might read /usr/share/doc/ifupdown/examples/bridge

David G.
  • 225
  • 1
  • 2
  • 7