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.
iptables
. It might work if you add some rule like:sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
||sudo iptables -A FORWARD -i wlan0 -o eth1 -j ACCEPT
dhcpcd.conf
. If I list both interfaces in this config file, only the one works, which is written lower in the fileeth0
in DHCP client mode because it would get ip address fromwlan0
DHCP server. It could work if you add suitable rule toiptables
.