4

I need a bridge interface for LXC networking to work. Normally I just do something like this in /etc/network/interfaces:

auto br0
iface br0 inet dhcp
  bridge_ports eth0

But Raspbian uses dhcpcd.

How do I create a bridge on an RPi?

I'm not sure how the internals of LXC work, but I know for a fact that LXC needs a bridge in order to work. I have tried LXC's NAT and couldn't get that to work, and I don't want a NAT layer anyway.

cat pants
  • 141
  • 1
  • 4
  • 1
    What do you want to bridge if there is only one interface eth0 on the bridge? – Ingo Jul 18 '18 at 19:16
  • I need to create a bridge for LXC to work. That's just what LXC requires. I'm guessing it bridges its virtual interfaces to br0, but I'm no LXC expert. It works fine on my x86 systems, but requires br0 for sure. – cat pants Jul 18 '18 at 19:40

2 Answers2

1

I have not done this but it should be possible.

See Using the Raspberry Pi as an access point to share an internet connection (bridge) in Access Point

See also Advanced dhcpcd Configuration in How to set up networking/WiFi in particular Prevent dhcpcd from configuring an interface

NOTE DO NOT include dhcp in interfaces - this will stop dhcpcd from working - use manual and let dhcpcd configure the interfaces. You need to tell dhcpcd which interfaces NOT to configure.

Milliways
  • 59,890
  • 31
  • 101
  • 209
0

Just successfully set up a Raspberry IPv6 bridge. Hope my experience may help.

Instead of editing /etc/network/interfaces, I use commands,like:

ifconfig eth0 down
ifconfig eth1 down 
brctl addbr br0
ifconfig br0 up 
brctl addif br0 eth0
brctl addif br0 eth1
ifconfig eth0 up
ifconfig eth1 up

During this process, on Raspberry Pi platform, you may encounter such error when performing brctl addbr br0:

add bridge failed: Package not installed

According to this question, bridge-utils "add bridge failed: Package not installed", this is because the kernel is not compiled with bridge support. so you have to either change an Raspbian iamge, or compile a kernel yourself. As far as I have tested, 2022-09-22-raspios-bullseye-armhf.img.xz doesn't have bridge support, 2022-09-22-raspios-bullseye-arm64-full.img.xz has bridge support. So I recommend you using 2022-09-22-raspios-bullseye-arm64-full.img.xz . Of course, if you like, you can test other images.

Greenonline
  • 2,740
  • 4
  • 23
  • 36
xelmirage
  • 11
  • 1