Don't crete br-lan and lan0-lan3

OS: OpenWRT board: BPI-R2

I don’t want to create a bridge interface(br-lan), I am just looking to bring up only eth0(lan) and eth1(wan) interfaces, not lan0-lan3, br-lan and wan ports.

Here for an application, I need to create virtual interfaces on eth0 interface, ifconfig eth0:0 … ifconfig eth0:3. To do so I think switch functionality needs to be disable. For this I compiled kernel by configuring mt7530 as a module. With this only eth0 and eth1 interfaces are created but after doing ifconfig eth0 xxx.xxx.xxx.xxx up, I am not able ping to back-back connected PC(though connected back-back on PC it showing unplugged) and if insert mt7530.ko switch functionality bus coming up by creating br-lan, lan0-lan1, wan.

With the Ubuntu image, only eth0 and eth1 are created. Please let me know how same can be achieved with OpenWRT

Any points on this will be really helpful

Thanks.

Please help me here.

Which kernel version does your Ubuntu image use? Have it got mt7530 module loaded? Are there any references to mt7530 in Ubintu’s dmesg?

mt7530 kernel module has nothing to do with br-lan. It presents switch chip user ports to linux userspace in a way so each physical port on the box is visible as a separate interface in linux. This approach is calles DSA, google for it if you’d like to know more. With DSA switch chip configuration is derived from the linux bridge config. Without bridge switch port is configured in a way so there’s no switching between lanX ports. Default openwrt config in /etc/config/network have got a bridge definition for br-lan - this is the place where you need to do changes to get rid of bridge autocreation. Nevertheless why do you thing you need to remove bridge in order to create interface aliases? Here is an example from my R2:

root@lx2bpir2:/tmp# ifconfig lan0:1 192.168.5.1
root@lx2bpir2:/tmp# ifconfig br-lan:31 192.168.55.1
root@lx2bpir2:/tmp# ifconfig | grep 'lan'
br-lan    Link encap:Ethernet  HWaddr DE:A1:B3:87:A4:60
br-lan:31 Link encap:Ethernet  HWaddr DE:A1:B3:87:A4:60
lan0      Link encap:Ethernet  HWaddr DE:A1:B3:87:A4:62
lan0:1    Link encap:Ethernet  HWaddr DE:A1:B3:87:A4:62
lan1      Link encap:Ethernet  HWaddr DE:A1:B3:87:A4:63
lan2      Link encap:Ethernet  HWaddr DE:A1:B3:87:A4:64
lan3      Link encap:Ethernet  HWaddr DE:A1:B3:87:A4:65

Two alias interfaces were created and assigned their own IPs. I need to know more about the specifics of your task to be able to help you further.

Thanks Alexey.

Which kernel version does your Ubuntu image use? Have it got mt7530 module loaded? Are there any references to mt7530 in Ubintu’s dmesg?

Yes in ubuntu mt7530 module is not loaded. Only eth0 and eth1 are created and I can create eth0 aliases on same subnet and its working fine.

why do you thing you need to remove bridge in order to create interface aliases?

As I mentioned earlier yes I want to create aliases on eth0(on same subnet).

With switch functionality, lan0-lan3 created are created and so I think I can’t set same subnet IP address on aall ports. If I set then ping happens only on one port.

root@LEDE:/# ifconfig br-lan down

root@LEDE:/# brctl delbr br-lan

[ 1052.495867] device lan3 left promiscuous mode

[ 1052.500302] br-lan: port 4(lan3) entered disabled state

[ 1052.506807] device lan2 left promiscuous mode

[ 1052.511193] br-lan: port 3(lan2) entered disabled state

[ 1052.517461] device lan1 left promiscuous mode

[ 1052.521834] br-lan: port 2(lan1) entered disabled state

[ 1052.527900] device lan0 left promiscuous mode

[ 1052.532219] device eth0 left promiscuous mode

[ 1052.536610] br-lan: port 1(lan0) entered disabled state

root@LEDE:/# ifconfig lan0 192.168.2.10

root@LEDE:/# ifconfig lan1 192.168.2.20

root@LEDE:/# ifconfig lan2 192.168.2.30

root@LEDE:/# ifconfig lan3 192.168.2.40

root@LEDE:/# route -n

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 lan0

192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 lan1

192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 lan2

192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 lan3

I compiled the kernel with mt7530 as a module, with this image eth0 and eth1 are created but somehow link itself is not up. when I connect PC and the board(wan/lan any ports) PC failing to detect link itself.

For my appliation(OpenWRT), I need to initialize all lan ports on same subnet. Can you please help me in achieving this on OpenWRT.

Thanks, Ashok.

If I understood what you’d like to achieve you need to have several IPs from the same subnet assigned to the box. Why don’t you do it like this:

# ifconfig br-lan:1 192.168.2.10
# ifconfig br-lan:2 192.168.2.20
# ifconfig br-lan:3 192.168.2.30
# ifconfig br-lan:4 192.168.2.40

And that’s it. In case you had compiled your OpenWRT image with iprote2 ip utility (or had installed it using opkg) then following is a better way to achieve the same result:

# ip ad ad dev br-lan 192.168.2.10/24
# ip ad ad dev br-lan 192.168.2.20/24
# ip ad ad dev br-lan 192.168.2.30/24
# ip ad ad dev br-lan 192.168.2.40/24

I.e. when DSA is active you should treat br-lan the same way you are treating eth0 on Ubuntu.

Its working. Thanks Alexey.

Just one more query, May I know when lan0-lan3 are initialized with same subnet IP, ping won’t happen on all port. is there a way to make it work.

Thanks, Ashok.

What do you mean by “ping won’t happen”? Hosts on the network are unable to ping R2? Or R2 unable to ping other hosts?

sorry, I mean when I run below commands, root@LEDE:/# ifconfig br-lan down

root@LEDE:/# brctl delbr br-lan

[ 1052.495867] device lan3 left promiscuous mode

[ 1052.500302] br-lan: port 4(lan3) entered disabled state

[ 1052.506807] device lan2 left promiscuous mode

[ 1052.511193] br-lan: port 3(lan2) entered disabled state

[ 1052.517461] device lan1 left promiscuous mode

[ 1052.521834] br-lan: port 2(lan1) entered disabled state

[ 1052.527900] device lan0 left promiscuous mode

[ 1052.532219] device eth0 left promiscuous mode

[ 1052.536610] br-lan: port 1(lan0) entered disabled state

root@LEDE:/# ifconfig lan0 192.168.2.10

root@LEDE:/# ifconfig lan1 192.168.2.20

root@LEDE:/# ifconfig lan2 192.168.2.30

root@LEDE:/# ifconfig lan3 192.168.2.40

ping is not happening on all the ports with Host.

root@LEDE:/# route -n

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 lan0

192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 lan1

192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 lan2

192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 lan3

Only kernel 4.4 shows only eth0/1 without dsa-ports (lanx/wan) because of missing dsa-driver.

I don’t know hoe to accomplish this in newer kernels

Generic query,

  1. if we have two interfaces created(driver level) on single nic, can we assign the same subnet IPs?
  2. if we have two different nic and two different interfaces, then can we assign same subnet IPs?

1 interface => 1 subnet

If you want multiple interfaces in 1 subnet you have to create a bridge and assign your config to this bridge

If you want multiple interfaces in 1 subnet you have to create a bridge and assign your config to this bridge

May I know how to do this, Please provide any link/steps.

As mentioned earlier, I have lan0,lan1lan2 and lan3 interfaces created for the switch(BPI-R2) and I want to assign same subnet IP for all the 4 ports.

I am looking for a solution where I can configure all the interfaces(lan0-lan3) on the same subnet.

Please let me know how to achieve this if at all it is achievable.

Thanks, Ashok

one issue observing with this, when ethernet cables(more than one) removed and connected back, ping is failing. somethig link this,

  1. assign IPs,

ifconfig br-lan:1 192.168.2.10

ifconfig br-lan:2 192.168.2.20

ifconfig br-lan:3 192.168.2.30

ifconfig br-lan:4 192.168.2.40

  1. connect BPI-R2 any lan(say lan0) port to the switch, where host is also connected.
  2. ping from host and board, its working fine
  3. connect BPI-R2 one other more port(say lan1) to switch
  4. ping will be stoped.

Any idea why this happening and any fix here.

Please let me know a solution where I can configure all lan ports(lan0-lan3) of BPI-R2 board on the same subnet IP.

you cannot define multiple IPs in same subnet for different interfaces!

you can bridge ports and define 1 IP to the bridge

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

Thanks Frank/Alexey for all the information.

Nor really. It is more complicated as there’s a thing called “policy routing” and even without policy routing it is possible to achieve a lot of interesting and complicated setups using netfilter tables + iproute2. So the main question is the end goal, what does the user try to achieve and - most importantly - why. Linux network stack is very flexible and - as a consequence - is complicated. So to get an idea on how to do something from technical PoV one needs to define the top level “target state” beforehand.

This is plain wrong. You’re creating topology loop here which is bad idea. In case you have STP (spanning tree protocol) enabled in your subnet you might be able to get away with it. Feel free to google on “STP” and “spanning tree in linux bridge” keywords if you want to get familiar with this as this topic is too complicated to describe in a single forum post.

Why do you want to have two ports connected to the same network at a first place? If you’re looking for increased resilience then your best bet would be to use one of ethernet bonding variants here instead of using bridge. Documentation is here: https://www.kernel.org/doc/Documentation/networking/bonding.txt . Depending on your network infrastructure you’d either have to configure the switch your R2 is connected to by enabling “etherchannel” or “trunk group” (there are several marketing names for this kind of bonding depending on the brand name of the switch you use), or enabling LACP/802.3ad link aggregations on resp ports or sticking to using active-backup, balance-tlb or balance-alb bond mode on R2 side.

Upd. Ah, and in case you’re looking for increased throughput by using more than a single 1Gbps port - it won’t work. From the physical PoV R2 has two ethernet cards, one being “hardwired” to wan port of the built-in switch and second one left as a sole interface to exchange traffic with lanX ports. So you wan’t be able to ever get more then 1Gbps of bandwidth in total combined for all 4 lanX ports - this is a physical topology limitation of the board.

Note: Technically speaking wan port is not physically hardwired to eth1 but the default configuration is like this and AFAIK the way DSA is implemented is somewhat limited and do not allow more than one CPU port to be used as master port. So for you it means that the safe approach is to treat wan as a separate interface physically tied to “wan” port and be prepared that rest 4 lanX ports share a single bandwidth limit of 1Gbps.

Gmac connected to Lan-ports can run in trgmii-mode which should support 2.5gbit/s throughput

but i have not get more than 1gbit to cpu

I know policy routing but have not used on multiple lan-interfaces with same subnet. I guessed the thread opener will have an easy configuration :slight_smile:

Ah, so MAC<->PHY connection in R2 uses mediatek’s specific turbo reduced gigabit media interconnect interface? Then the theoretical max bandwidth should be higher, but still is not enough to provide full 1Gbps per each lanX port. Though looking at the bandwidth performance figures I get on my R2 there are big doubts that CPU is capable enough to be able to process anything higher than 1Gbps. Actually it seems to be struggling a lot trying to achieve mere 1Gpbs.

Sure, Alexey I will go through the bonding and try to get a solution. Thanks.

Also, in between just I want to build BPI-R2 openWRT images with openWRT with kernel-4.4? I tried a lot but unable to find any repository

Could you guys please help me on this as well:)