4

Please, I have problem with creating bridge from eth0 to eth1.

I make:

 sudo apt-get install bridge-utils
 sudo brctl addbr br0
 sudo brctl addif br0 eth0 eth1

This has 2 problems. It will help me out just until I reboot Pi. The second is that I will get crazy ip address on eth1.

But I need the bridge configure automatically when boot up.

Next problem is that I can't modify my /etc/network/interfaces -> when I do it, it works just until reboot. Then I can't connect to the internet and it will show me:

 connection to dhcpcd lost

My /etc/network/interfaces looks like:

 # interfaces(5) file used by ifup(8) and ifdown(8)

 # Please note that this file is written to be used with dhcpcd
 # For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

 # Include files from /etc/network/interfaces.d:
   source-directory /etc/network/interfaces.d

I set up static ip address and so my /etc/dhcpcd.conf look like:

 #static IP configuration

 interface eth0
 static ip_address=192.168.0.106
 static routers=192.168.0.1
 static domain_name_servers=8.8.8.8

I don't know what to do or like where should I put something I used to put in /etc/network/interfaces

2 Answers 2

4

I strongly suggest to test this on Raspbian Jessie, but not on Stretch, as Stretch is difficult to configure from my experience, with many things breaking in totally unexpected ways. One really annoying breakage is that MAC48-based so-called "stable" but unfortunately unpredictable network interface names are now enforced. This makes any configuration unique and as soon as you replace a network adapter, you need to update all configuration files. So safe ground here is Jessie, and I can tell from my own experience that running a bridge automatically works great. Getting the same done on Stretch is a nightmare and not worth the effort at this time.

Alas, you first need some basic understanding what using a Linux kernel bridge (or any other software bridge) means:

  1. the bridge (such as br0) itself has an interface to the Linux IPv4/IPv6 stack. It it this network interface ("the bridge") that you want to configure with an IPv4 address, etc. See below for the setup.

  2. the bridge ports, which are termed "enslaved interfaces" in Linux parlance, are normally left unconfigured. While it is possible to configure them, and I did it myself, you may easily end up with strange system behavior. So I heavily recommend to not IP-configure any enslaved device until you have gained more experience and have a need to do so. This applies to both IPv4 and IPv6. Especially as IPv6 autoconfiguration often kicks in unnoticed, this may cause some issues or unwanted behavior.

Alas, Debian documents how to set up a Linux kernel bridge using /etc/network/interfaces; in your /etc/network/interfaces:

# do NOT autoconfigure bridge ports/enslaved interfaces!
iface eth0 inet manual
iface eth0 inet6 manual
iface eth1 inet manual
iface eth1 inet6 manual

# autoconfigure bridge interface, add bridge ports
auto br0
iface br0 inet dhcp
  bridge_ports eth0 eth1

Now, you need to tell dhcpcd to keep its fingers off eth0 and eth1, and to use br0; so in /etc/dhcpcd.conf:

denyinterfaces eth0 eth1
interface br0
  static ip_address=...
  ...
1
  • How would this translate to Raspberry Pi OS (bullseye), the version that is installed today? Should I still edit the good old /etc/network/interfaces file or is there a replacement for it now? I never know, there are so many different flavours of network configuration in Linux...
    – ygoe
    Dec 8, 2021 at 16:12
0

On my Pi3 running Raspbian stretch I modified the information obtained here to bridge eth1 and wlan0 being my internal network as a gateway to eth0 which is the internet side adapter. I'm also running hostapd and dnsmasq. This worked for me although feels like there ought to be a way to do this solely through dhcpcd.conf? Anyone?

I ended up with: /etc/network/interfaces:

# do NOT autoconfigure bridge ports/enslaved interfaces!
iface eth1 inet manual
iface eth1 inet6 manual
iface wlan0 inet manual
iface wlan0 inet6 manual

# autoconfigure bridge interface, add bridge ports. Note wlan0 is also added
# to the bridge within /etc/hostapd/hostapd.conf. If not also added here an
# an IPv6 address attaches to the adapter it seems.
auto br0
iface br0 inet manual
  bridge_ports eth1 wlan0

and at the bottom of /etc/dhcpcd.conf:

denyinterfaces eth1 wlan0
interface br0
    static ip_address=192.168.20.114/24
    static domain_name_servers=192.168.10.253 8.8.8.8

and at the bottom of /etc/hostapd/hostapd.conf to add wlan0 to br0:

# This line ask hostapd to add wlan0 to the bridge br0
bridge=br0
1
  • I think I am trying to do exactly the same, but I can't get it to work with my setup. Could you add your whole hostapd, dnsmasq, interfaces config files? Feb 1, 2020 at 22:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.