I'm struggling with my configuration of my Raspberry Pi. My Raspberry Pi 3 is connected to the Router via Wifi (wlan0). I created an access point with the Pi (wlan1) but I also want to be able to connect via ethernet (eth0) to the internet.

Everything just works fine, except if I want to use both at the same time. The moment I plug in the ethernet cable into a device, the devices connected to the access point have no internet anymore. Only the device connected over ethernet to the Pi has access to the internet. If e.g. my PC is connected via ethernet, then my phone can't access the internet (but it is connected to the access point and has an IP) until I unplug the PC from the Ethernet. It seems like the Ethernet gets prioritized over the access point and my Pi denies all data from the access point.

So basically i want to share the Internet (Wifi) of the router with my Raspberry Pi Access Point and my Raspberry Pi Ethernet.

Im running the latest Raspbian Stretch Desktop version. I don't have access to the router itself.

This is my setup:

hostapd.conf

interface=wlan1
driver=nl80211
hw_mode=g
channel=11
ieee80211n=1
wmm_enabled=1
macaddr_acl=0
ignore_broadcast_ssid=0
auth_algs=1
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
ssid=XXXX
wpa_passphrase=XXXXXXXX

/etc/dhcpcd.conf

interface wlan1
static ip_address=192.168.220.1/24

interface eth0
static ip_address=192.168.220.2/24

/etc/dnsmasq.d/dnsmasq-wlan1.conf

interface=wlan1
listen-address=192.168.220.1
bind-dynamic
server=8.8.8.8
domain-needed
bogus-priv
dhcp-range=192.168.220.50,192.168.220.150,12h

/etc/dnsmasq.d/dnsmasq-eth0.conf

interface=eth0
listen-address=192.168.220.2
bind-dynamic
server=8.8.8.8
domain-needed
bogus-priv
dhcp-range=192.168.220.50,192.168.220.150,12h

/etc/iptables.ipv4.nat (starting at boot)

*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A FORWARD -i wlan0 -o wlan1 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i wlan1 -o wlan0 -j ACCEPT
COMMIT
*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -o wlan0 -j MASQUERADE
COMMIT

/etc/network/interfaces.d/interfaces-wlan0 (see comments)

  • Just a guess, try different dhcp ranges for wlan1 and eth0. Maybe the two devices connected get both the address 192.168.220.50. – Janka Feb 23 at 20:34
  • @Janka I got the ip 192.168.220.139 over wifi and 192.168.220.68 over ethernet – Yakuhzi Feb 23 at 21:45
  • @Fabian I don't have access to the router, only to the RasPi. The network im connected with is a mixed IPv4 and IPv6 network, but my raspberry pi access point is IPv4 only – Yakuhzi Feb 23 at 21:45
  • Including dhcp in /etc/network/interface causes dhcpcd to disable itself, so this has no chance of working. See How to set up networking/WiFi – Milliways Feb 23 at 23:25
  • @Milliways removing the interfaces files sadly had no effect on my problem – Yakuhzi Feb 24 at 0:31

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.