Bpi and gateway with wire

if you use lan0 as wan and bridging lan1-3 why not using wan as management-interface with fixed address?

Hello I come back !

I think that’s I have not welding problems. I have try all lan and the wan in the network.

root@bpi-r2:~# cat /etc/network/interfaces
source-directory /etc/network/interfaces.d

auto eth1
iface eth1 inet manual
  pre-up ip link set $IFACE up
  post-down ip link set $IFACE down

auto eth0
iface eth0 inet manual
  pre-up ip link set $IFACE up
  post-down ip link set $IFACE down

auto wan
allow-hotplug wan
  iface wan inet dhcp
  pre-up ip link set $IFACE address 32:D1:55:7D:03:39 up

auto lan0
allow-hotplug lan0
  iface lan0 inet dhcp

auto lan1
allow-hotplug lan1
  iface lan1 inet dhcp

auto lan2
allow-hotplug lan2
  iface lan2 inet dhcp

auto lan3
allow-hotplug lan3

iface lan3 inet dhcp

All the lan0-3 have the same mac address ! I was connected in the bpi-r2 by the WiFi and try all the wired port : I my computer I test ping to wan. stop it. And in the bpi-r2, I do :

ifdown wan
ifdown lan0
ifup lan0

I deconnect the wire of wan and put it at lan0 and test ping with lan0.

--- 192.168.1.8 ping statistics ---
2705 packets transmitted, 2700 received, 0% packet loss, time 2768924ms
rtt min/avg/max/mdev = 0.250/0.325/0.515/0.033 ms

No problem I think.

DSA-User-ports (wan,lanx) getting mac-address from CPU-port (ethx). Currently i’m testing to set fixed mac (default is random) without compiling full kernel.

You have no more problem with pingdrops?

No problem with this test. But it’s not the config that I need.

You tested each port? If now all it’s ok you can move to your config step by step. But do not bridge wan+lan or ap0 with lan/wan

Before this hollyday, I have tested a bridge with lan0-3 only. It don’t work. I test no bridge (only lan0 zum bispiel) when I can.

I have try to have a DHCP in my bridge :

auto br0
  iface br0 inet dhcp
  pre-up ip link set $IFACE address 32:D1:55:7D:03:39 up
  bridge_ports lan0 lan1 lan2 lan3
  bridge_fd 5
  bridge_stp no
  up /etc/init.d/firewall start

It don’t work. The bridge need have a public address !

i don’t think this is possible, all your clients need a public ip too. why not connect your ISP to wan and your clients to lan-bridge? thats the normal setup and r2 can do what it is designed for…routing :slight_smile:

bridging your lan to public internet is a very bad idea

I think that’s I have do this with the BPI-R2 and ubuntu. The PBI-R2 has work als a swith.

Today I have a little time to test…

I don’t nothing understand. Before the test I have :

auto wan
  iface wan inet dhcp
  pre-up ip link set $IFACE address 32:D1:55:7D:03:39 up
  up /etc/init.d/firewall start

Before today I have never see problem with this. But today I have rbbot my BPI-R2 and after I have this :

--- 192.168.1.10 ping statistics ---
2260 packets transmitted, 2173 received, 3.84956% packet loss, time 2545ms
rtt min/avg/max/mdev = 0.347/0.484/0.587/0.044 ms

I have the problem I had with the bridge br0 :I can’t run vi with a big file.

I try it :

auto lan0
  iface lan0 inet dhcp
  pre-up ip link set $IFACE address 32:D1:55:7D:03:39 up
  up /etc/init.d/firewall start

and I have no problem.

--- 192.168.1.10 ping statistics ---
111 packets transmitted, 111 received, 0% packet loss, time 748ms
rtt min/avg/max/mdev = 0.349/0.487/0.607/0.052 ms

After this reboot I have a problem with the https server. It answers with https://192.168.1.10, but it don’t answers with a public name (I use ovh for my domaine). The name is good “ssh mein_mane” is good but it’s redirect to a other computer. When it’s redirect to the BPI-R2, it’s don’t run.
And I don’t see any problem in /var/log.

The problem with https redirection was due to the interfaces file
Now, I test the ping.

Have you a good configuration for a bridge ?

The ping :

--- 192.168.1.10 ping statistics ---
1146 packets transmitted, 1144 received, 0.17452% packet loss, time 1681ms
rtt min/avg/max/mdev = 0.329/0.422/0.558/0.053 ms

This morning I have do a test

br0 with lan0-3. A computer (A) in lan0 and a other computer (B) in lan1.

when A ping B or B ping A : 0% lost,
rtt min/avg/max/mdev = 0.171/0.365/.509/.0052

when A or B ping the BPI-R2 :

--- 192.168.2.1 ping statistics ---
2686 packets transmitted, 2433 received, 9.41921% packet loss, time 3221ms
rtt min/avg/max/mdev = 0.277/0.424/0.547/0.049 ms

for info :

root@bpi-r2:/var/log# ifconfig 
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 2e:26:e2:1f:af:af brd ff:ff:ff:ff:ff:ff
    inet6 fe80::2c26:e2ff:fe1f:afaf/64 scope link 
       valid_lft forever preferred_lft forever
3: wan@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 32:d1:55:7d:03:39 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.10/24 brd 192.168.1.255 scope global wan
       valid_lft forever preferred_lft forever
    inet6 2a01:cb14:aba:d900:30d1:55ff:fe7d:339/64 scope global mngtmpaddr dynamic 
       valid_lft 1780sec preferred_lft 580sec
    inet6 fe80::30d1:55ff:fe7d:339/64 scope link 
       valid_lft forever preferred_lft forever
4: lan0@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master br0 state LOWERLAYERDOWN group default qlen 1000
    link/ether 32:d1:55:7d:03:30 brd ff:ff:ff:ff:ff:ff
5: lan1@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br0 state UP group default qlen 1000
    link/ether 32:d1:55:7d:03:31 brd ff:ff:ff:ff:ff:ff
6: lan2@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master br0 state LOWERLAYERDOWN group default qlen 1000
    link/ether 32:d1:55:7d:03:32 brd ff:ff:ff:ff:ff:ff
7: lan3@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br0 state UP group default qlen 1000
    link/ether 32:d1:55:7d:03:33 brd ff:ff:ff:ff:ff:ff
8: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 32:d1:55:7d:03:30 brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.1/24 brd 192.168.2.255 scope global br0
       valid_lft forever preferred_lft forever
    inet6 fe80::30d1:55ff:fe7d:330/64 scope link 
       valid_lft forever preferred_lft forever
9: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 00:08:22:bc:ed:fb brd ff:ff:ff:ff:ff:ff
10: ap0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 02:08:22:bc:ed:fb brd ff:ff:ff:ff:ff:ff
    inet 192.168.3.1/24 scope global ap0
       valid_lft forever preferred_lft forever
    inet6 fe80::8:22ff:febc:edfb/64 scope link 
       valid_lft forever preferred_lft forever

Why I have not eth1 in ifconfig ?

The beginning of /etc/network/interfaces is :

root@bpi-r2:~# cat /etc/network/interfaces
# 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
  pre-up ip link set $IFACE up
  post-down ip link set $IFACE down

auto eth1
iface eth1 inet manual
  pre-up ip link set $IFACE up
  post-down ip link set $IFACE down

I test :

 root@bpi-r2:~# grep eth1 /var/log/syslog
Jan 20 08:55:53 bpi-r2 ifup[705]: Cannot find device "eth1"
Jan 20 08:55:53 bpi-r2 ifup[705]: ifup: failed to bring up eth1
Jan 20 09:15:42 bpi-r2 ifup[704]: Cannot find device "eth1"
Jan 20 09:15:42 bpi-r2 ifup[704]: ifup: failed to bring up eth1
Jan 20 11:08:17 bpi-r2 ifup[717]: Cannot find device "eth1"
Jan 20 11:08:17 bpi-r2 ifup[717]: ifup: failed to bring up eth1

second gmac is only available in 4.14.53+ or 4.19.14+

if A pings B (or opposite direction) through bridge, r2 does not touch Traffic, i guess it’s not running over CPU-Port (ethx), means directly in switch from port lanX to lanY

Hello

I think it’s besser with the last kernel :

[code]root@bpi-r2:~# uname -r
4.19.16-bpi-r2-main[/code]

I do a test with this :

source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual
  pre-up ip link set $IFACE up
  post-down ip link set $IFACE down

auto eth1
iface eth1 inet manual
  pre-up ip link set $IFACE up
  post-down ip link set $IFACE down


auto wan
  iface wan inet dhcp
  pre-up ip link set $IFACE address 32:D1:55:7D:03:39 up
  up /etc/init.d/firewall start

auto lan1 
allow-hotplug lan1
iface lan1 inet manual
  pre-up ip link set $IFACE address 32:D1:55:7D:03:31 up
   pre-up   ifconfig  up
   pre-down ifconfig  down

auto lan2
allow-hotplug lan2
iface lan2 inet manual
  pre-up ip link set $IFACE address 32:D1:55:7D:03:32 up
   pre-up   ifconfig  up
   pre-down ifconfig  down


auto lan3
allow-hotplug lan3
iface lan3 inet manual
  pre-up ip link set $IFACE address 32:D1:55:7D:03:33 up
   pre-up   ifconfig  up
   pre-down ifconfig  down

auto lan0
allow-hotplug lan0
iface lan0 inet manual
  pre-up ip link set $IFACE address 32:D1:55:7D:03:30 up
   pre-up   ifconfig  up
   pre-down ifconfig  down

auto br0
iface br0 inet static
  address 192.168.2.1
  network 192.168.2.0
  bridge_ports lan0 lan1 lan2 lan3 
  bridge_fd 5
  bridge_stp no
  up /etc/init.d/firewall start

No packet lost…

I remove the mac address of lan and make a new test. The bridge don’t when I remove the mac address of the lan.

I don’t remenber who, but I have see that’s in a bridge the order of the interfaces is important : ascending order of mac address.

It’s not good, it’s only besser.

When it’s only 1 computer in lan0 or lan1 : it’s good. But, When I put 2 computers, it’s not good :frowning:

Now I have do a bridge with all lan and wan.

The bridge have a ip from my home network : 192.168.2.1

auto br0
iface br0 inet static
   address 192.168.1.10
  gateway 192.168.1.1
  bridge_ports lan0 lan1 lan2 lan3 wan
  bridge_fd 5
  bridge_stp no
  up /etc/init.d/firewall start

The BPI-R work all a switch. But, I have a big problem when I ping the BPI-R2 :

--- 192.168.1.1 ping statistics ---
106 packets transmitted, 106 received, 0% packet loss, time 597ms
rtt min/avg/max/mdev = 0.563/0.728/1.772/0.115 ms

But when I ping the box there is no problem. There is My PC <->LanX The BPI-R2 brige WAN <->2 swith <-> the box or internet

--- 192.168.1.1 ping statistics ---
106 packets transmitted, 106 received, 0% packet loss, time 597ms
rtt min/avg/max/mdev = 0.563/0.728/1.772/0.115 ms

--- www.google.fr ping statistics ---
161 packets transmitted, 161 received, 0% packet loss, time 421ms
rtt min/avg/max/mdev = 11.148/11.611/16.937/0.535 ms

I try with : My PC <->LanX The BPI-R2 brige WAN <->2 swith <-> the box. The https server works when I aks it with a public name (the call come from the box), but the same server don’t answer when I use 192.168.1.10 (the call come from lanX). I reverse the two wire, the public name don’t answer and 192.168.1.10 answer : only “wan” answer.

nb : I have use http://www.fw-web.de/dokuwiki/doku.php?id=en:bpi-r2:debug-uart I think you must indicate how to connect with the wires. I know TX<=>RX, but not everyone knows.

R2 and usb2serial have both tx and rx…tx have to be on rx of the other (sender to receiver).

Can you ping local ip if https does not answer? Maybe it does not listen on all interfaces…netstat -tulpen shows listening ports…https should listen to 0.0.0.0:443

for the https : All the wire’s output are in the bridge. The https answer only when I ask it by the wan.

for the usb2serial : I know, but I thing it must be written on the page.

I have do a switch with all the port : ap0,wan, lan0, lan1, lan2 and lan3. It’s all in my /etc/init.d/wifi.sh.

For ip static :²

#!/bin/bash
set +e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/dev/null
NAME=wifi
DESC="Load MediaTek MT6625L firmware wifi & BT"

 if [[ ! -e /dev/wmtWifi ]];
then
  echo "wifidev does not exist...create it..."
  if [[ -x /usr/bin/wmt_loader ]];
  then
        /usr/bin/wmt_loader
        sleep 3
  else
        echo "Error, unable to find wmt_loader"
  fi

  if  [[ -c /dev/stpwmt ]];
  then
        /usr/bin/stp_uart_launcher -p /etc/firmware &
        sleep 5
  else
        echo "Error, device no created, /dev/stpwmt"
  fi
fi

if  [[ -c /dev/wmtWifi ]];
then
        if [[ -n $(ip a|grep ap0) ]];
        then
                echo "ap0 exists, reset it";
                echo 0 >/dev/wmtWifi
                sleep 5
        fi
        echo A >/dev/wmtWifi
        sleep 2
else
        echo "Error, wifi device no created, /dev/wmtWifi"
fi

ip addr show ap0
if [[ $? != "0" ]]
then
        echo "Error, device no available, ap0"
else
        echo "Done, all good, ready to lauch hostapd"
        sleep 2
        hostapd -dd /etc/hostapd/hostapd.conf &
        sleep 20


test=`ip -4 -o addr show | grep br0 | wc -l`
echo $test
while [[ $test == "0" ]]
do
        sleep 10;
        echo $test
        brctl addbr br0
        brctl addif br0 ap0 wan lan0 lan1 lan2 lan3
        ip link set dev br0 up
        ip addr add 192.168.1.10/24 dev br0
        ip route add default via 192.168.1.1
        test=`ip -4 -o addr show | grep br0 | wc -l`
done

fi

At the end I do the bridge. I wait that the bridge is up.

And the end for a up by a dhcpd server :

while [[ $test == "0" ]]
do
        sleep 10;
        echo $test
        brctl addbr br0
        brctl addif br0 ap0 wan lan0 lan1 lan2 lan3
        ip link set br0 address 32:D1:55:7D:03:39 up
        ip link set dev br0 up
        dhclient br0 
        test=`ip -4 -o addr show | grep br0 | wc -l`
done

My /etc/network/interfaces is :

source-directory /etc/network/interfaces.d

# The loopback network interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual
  pre-up ip link set $IFACE up
  post-down ip link set $IFACE down

auto eth1
iface eth1 inet manual
  pre-up ip link set $IFACE up
  post-down ip link set $IFACE down

auto wan 
allow-hotplug wan
iface wan inet manual
   pre-up ip link set $IFACE address 32:D1:55:7D:03:39 up
   pre-up   ifconfig  up
   pre-down ifconfig  down

auto lan1 
allow-hotplug lan1
iface lan1 inet manual
  pre-up ip link set $IFACE address 32:D1:55:7D:03:41 up
   pre-up   ifconfig  up
   pre-down ifconfig  down

auto lan2
allow-hotplug lan2
iface lan2 inet manual
  pre-up ip link set $IFACE address 32:D1:55:7D:03:42 up
   pre-up   ifconfig  up
   pre-down ifconfig  down


auto lan3
allow-hotplug lan3
iface lan3 inet manual
  pre-up ip link set $IFACE address 32:D1:55:7D:03:43 up
   pre-up   ifconfig  up
   pre-down ifconfig  down

auto lan0
allow-hotplug lan0
iface lan0 inet manual
  pre-up ip link set $IFACE address 32:D1:55:7D:03:40 up
   pre-up   ifconfig  up
   pre-down ifconfig  dow

Now I use the emmc.