0

I'm posting here because this seems like a general Debian/Ubuntu issue, and not a Raspberry pi-specific issue.

I want to bridge my wlan0 and eth0 ports on my Raspberry Pi (Raspbian 10/Buster), so that I can share my internet via my raspberry pi to a portable device that can only receive internet via ethernet.

While I know that creating a bridge with wlan0 is technically impossible, I know that I can reach similar results.

Edit: What I've tried so far (as recommended on many pages, for example here and here):

sudo sysctl -w net.ipv4.ip_forward=1
sudo iptables -A FORWARD --in-interface eth0 -j ACCEPT
sudo iptables --table nat -A POSTROUTING --out-interface wlan0 -j MASQUERADE

iw dev wlan0 set 4addr on
brctl addbr mybridge
brctl addif mybridge eth0
brctl addif mybridge wlan0

This does not work or help.

The only thing that does help is installing network-manager-gnome and activating the Shared to other computers-setting. This is very simple and works like a charm. However - I want my device (that I connected to the RPi with an ethernet cable) to also have an IP-address in the same network/subnet as the wlan0-interface is, so that other devices on the network will be able to reach it. Right now, it's getting addresses in the 10.42.0.1-range (which, according to this is a built-in feature..).

I've tried setting static IP-addresses on the Pi and the device, but that didn't help (they could only reach each other).

What is the best solution to this?

Oleg
  • 131
  • 7
  • Seems like you want to "bridge" wlan0 and eth0. – muru Feb 18 '20 at 09:31
  • Does this answer your question? [How do I configure a network interface bridge from WiFi to Ethernet with Debian?](https://unix.stackexchange.com/questions/363332/how-do-i-configure-a-network-interface-bridge-from-wifi-to-ethernet-with-debian) – muru Feb 18 '20 at 09:31
  • Hi @muru, this does not work. As pointed out in a comment by the user Ingo, Since kernel >=2.6.33 you cannot add wifi to a bridge: https://web.archive.org/web/20110925231256/http://kerneltrap.org/mailarchive/linux-ath5k-devel/2010/3/21/6871733 – Oleg Feb 18 '20 at 09:34
  • Ah. In that case, I think that in addition to the existing rules, you also need to have have wlan0 accept traffic intended for the device and forward it out via eth0. Then you'll have to tell the devices on the wlan0 that your device's IP can be reached via your wlan0 (so you'd need to add routes to all of them, or to their default gateway). – muru Feb 18 '20 at 09:43
  • @muru that sounds great. Do you have instructions for this that actually work? Because once again, I couldn't get it to work at all, unless I use `network-manager-gnome`, which in its own turn takes over network management and starts to give out DHCP addresses in a subnet. – Oleg Feb 18 '20 at 09:46
  • I think you can do it at a higher level that IP Tables. I think you just need to configure the routes / gateway. Also IP tables is now old, use NF Tables (it is more powerful), but setting the routing tables will do it for you, is less prone to error, and will be easier to understand. – ctrl-alt-delor Feb 18 '20 at 10:32
  • @ctrl-alt-delor should I do that with or without NetworkManager? – Oleg Feb 18 '20 at 10:35
  • The question shows there's an attempt at mixing routing and bridging. Bridging will fail (no provision for 4 address mode also made on the AP is ever reported). The bridging part should be removed and routing+NAT done. – A.B Feb 16 '22 at 07:01

0 Answers0