BPI-R2 link all network ports as a switch

Hello,

first: I used the search-function, but i couldn’t find something - or i searched for the wrong words :wink:

i just got my first first BPI-R2 with Ubuntu 20.04.3 LTS. Nextcloud is running fine on it.

My Fritzbox is connected to the hardware WAN-Port for internet/network access. Now i would like to use the other 4 LAN-Ports as a switch. To connect other devices to my network. Is this possible? Do i have to change anything in the “interfaces” file? It’s looking this this at the moment:

# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

# The loopback network interface
auto lo
iface lo inet loopback

auto eth1
iface eth1 inet dhcp
hwaddress ether 0A:94:C3:AC:DA:57

important is, that the BPI keeps its MAC-address. Any idea anyone? Thanks in advance :slight_smile:

Hi,

which kernel do you use? i don’t think you have eth1, and eth0 (gmac where all ports connected in mainline kernel) is unconfigured in your case

for bridging here is the ifupdown way (/etc/network/interfaces)

https://www.fw-web.de/dokuwiki/doku.php?id=en:bpi-r2:network:start#netbridge

Hi Frank,

thanks for the quick reply. Kernel Version is 4.4.70.

when i run “ifconfig” i can see eth0 und eth1:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 ether 16:95:36:f6:b4:f1 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1304 bytes 252887 (252.8 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 71

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.2.125 netmask 255.255.255.0 broadcast 192.168.2.255 inet6 fe80::894:c3ff:feac:da57 prefixlen 64 scopeid 0x20 ether 0a:94:c3:ac:da:57 txqueuelen 1000 (Ethernet) RX packets 7489237 bytes 11235017348 (11.2 GB) RX errors 0 dropped 14 overruns 0 frame 0 TX packets 1001859 bytes 151863752 (151.8 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 71

I will try netbridge. Thanks for the hint!

ok, with 4.4 (vendor kernel), ports are already bridged (because no dsa-support which creates an own interface for each port)…you do not need a software-bridge

So with Kernel 4.4.70 all 5 ports should be already bridged? I connect my pc (DHCP on) to one of the ports of the R2 and i couldn’t get a connection to my fritzbox.

not all, only lan-ports, you want to bridge wan with lan together? then you need to bridge eth0 and eth1

Sorry for the stupid questions, i’m new to this one: How can i connect ETH0 and ETH1?

i don’t need the WAN-function, so would be great to have a 5 port switch instead.

see my link above, you just need to replace lan1/lan2 by eth0/eth1, but i’m not sure /etc/network/interfaces is used on your system. maybe network-config is somewhere else (systemd or netplan)

Thanks so far Frank. I set interfaces to this:

# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

# The loopback network interface
auto lo
    iface lo inet loopback

auto eth0
    iface eth0 inet manual
auto eth1
    iface eth1 inet manual

auto br0
    iface br0 inet dhcp
    hwaddress ether 0A:94:C3:AC:DA:57
    bridge_ports eth0 eth1
    bridge_fd 5

After reboot the bpi was still connected to the fritz box. When i connect my pc to one of the LAN-ports of the bpi, it got an ip-address from the fritz.box, but i couldn’t ping the fritzbox, and didn’t had internet access.

When i ping the BananaPi from my pc, i have an excellent ping. Is there anything wrong in the config? Or is the connection via the BPI just unuseable slow? I think network config is used from here, cause the BPI has the MAC-address from here.

maybe it is a bug in switch driver. 4.4 is really old

you could try it with mainline kernel, but bridging wan and lan is not as designed…maybe with dsa you have less problems as all ports go over eth0 and you bridge dsa-user-ports instead of soc gmac

i got it now: i’m not using the WAN-Port anymore, just the LAN-Ports. Changed everything in my config from ETH1 to ETH0:

auto eth0
iface eth0 inet dhcp
hwaddress ether 0A:94:C3:AC:DA:57

So now i can use the BPI as a 4-port-switch, which is enough for my case. Thanks Frank for your help!

ok, now i upgraded to Kernel 5.4.0 and the bridge i set seems not to work anymore.

@frank-w on your website: https://www.fw-web.de/dokuwiki/doku.php?id=en:bpi-r2:network:start#netbridge is just about the 4.x Kernel. It seems like this manual does not work for 5.x.

Any idea how to bridge the LAN-Ports?

# uname -a
Linux bpi-r2-emmc 5.10.76-bpi-r2-hnat #2 SMP Mon Nov 1 10:39:32 CET 2021 armv7l GNU/Linux
[19:41] [email protected]:~ (509)
# brctl show
bridge name	bridge id		STP enabled	interfaces
lanbr0		8000.080200000010	no		lan0
							lan1
							lan3

it is no kernel-problem…i guess a configuration problem, on my main-router i have configured it with /etc/network/interfaces. but it should be possible with systemd-networkd too, or via manual way (ip tool)

#uname -a
Linux bpi-nas 5.4.0-bpi-r2-main #16 SMP Mon Nov 25 11:04:39 CET 2019 armv7l armv7l armv7l GNU/Linux

#brctl show
bridge name     bridge id               STP enabled     interfaces
docker0         8000.02425c3a48d6       no

#/etc/network/interfaces
auto wan
iface wan inet dhcp
hwaddress ether 0A:94:C3:AC:DA:57

In “ifconfig” i can see that there is ETH0 and lan0-3.

ok so how i need to configure the interfaces to bridge all 5 LAN/WAN-Ports, use DHCP and have a fixed MAC-Address for the Pi? For now i’m using the wan-port again.

First you can try to do it manually:

brctl addbr br0
brctl addif br0 lan1
brctl addif br0 lan2
...
ip addr add 192.168.0.10/24 dev br0
ip link set br0 address 02:01:02:03:04:08 up

i tried for /etc/network/interfaces:

brctl addbr br0
brctl addif br0 lan0
brctl addif br0 lan1
brctl addif br0 lan2
brctl addif br0 lan3

ip addr add 192.168.0.10/24 dev br0
ip link set br0 address 0A:94:C3:AC:DA:57 up

but i have no connection, when i connect my network to one of the LAN-Ports. Is there anything wrong?

Try it like this:

Ip link set eth0 up
ip link add name br0 type bridge
ip link set br0 up
ip link set lan0 master br0
ip link set lan0 up

ip addr add 192.168.1.33/24 broadcast 192.168.1.255 dev br0
ip route add 192.168.1.0/24 dev br0                                             
ip route add default via 192.168.1.1                 

With 192.168.1.1 being the router it is connected to. Be sure that this part 192.168.1. matches with your router.

If this works, you can use systemd-netwirkd to set this configuration permanently. Same as (but you do not need the vlan filtering part)

https://github.com/ericwoud/buildR64ubuntu/tree/master/rootfs-arch/etc/systemd/network-AP

What does “ip a” show? Is eth0 up,are the connected lan-ports up? Does ip-address/subnet matches your connected net? There is no dhcp in my example (no server no client)

ok i tried:

ip link set eth0 up
ip link add name br0 type bridge
ip link set br0 up
ip link set lan0 master br0
ip link set lan0 up

ip addr add 192.168.2.33/24 broadcast 192.168.2.255 dev br0
ip route add 192.168.2.0/24 dev br0
ip route add default via 192.168.2.1

The R2 is getting an IP from the Router and i can connect to it. But it get’s a new IP after every reboot, cause the MAC-Adress is changing every time. I also tried

ip link set lan0 address 0A:94:C3:AC:DA:57 up

instead of

ip link set lan0 up

but it hasn’t used this MAC. Also other devices on the LAN-Ports can’t connect to the Router (in both cases).

Second try was:

brctl addbr br0
brctl addif br0 lan0
brctl addif br0 lan1
brctl addif br0 lan2
brctl addif br0 lan3

ip addr add 192.168.2.10/24 dev br0
ip link set br0 address 0A:94:C3:AC:DA:57 up

i don’t have any connection in this case.

“ip a” says:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 32:65:fe:3e:cd:a2 brd ff:ff:ff:ff:ff:ff
3: wan: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether ce:1a:37:d6:27:66 brd ff:ff:ff:ff:ff:ff
4: [email protected]: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
    link/sit 0.0.0.0 brd 0.0.0.0
5: [email protected]: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 32:65:fe:3e:cd:a2 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::1786:4f3a:de4a:9f05/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
6: [email protected]: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state LOWERLAYERDOWN group default qlen 1000
    link/ether 32:65:fe:3e:cd:a2 brd ff:ff:ff:ff:ff:ff
7: [email protected]: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state LOWERLAYERDOWN group default qlen 1000
    link/ether 32:65:fe:3e:cd:a2 brd ff:ff:ff:ff:ff:ff
8: [email protected]: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state LOWERLAYERDOWN group default qlen 1000
    link/ether 32:65:fe:3e:cd:a2 brd ff:ff:ff:ff:ff:ff
9: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 00:08:22:20:d5:fb brd ff:ff:ff:ff:ff:ff
10: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
    link/ether 02:42:b7:83:0f:a7 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 scope global docker0
       valid_lft forever preferred_lft forever

just to explain my setup:

I got the R2. I want to connect it to my Router, so that the router assign a IP to the R2. Also i want to use the other 3-4 ports as a network switch. So that i can connect any devices via this ports to the Router. I don’t need the WAN-function. Great would be to use it as an additional port for the network switch, but it’s not neccesary.

Thanks for your support so far!