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.
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.
No,official lede/openwrt-repo is bases on kernel 4.9 which has also dsa-ports (lanx,wan).
Maybe you can use 4.4 from ubuntu in openwrt,but i don’t know how to link it into build-process…imho 4.4 is not compilable with newer gcc-versions (4.5+)
For now, in my application, I am binding the interfaces(lanx) with the socket with socket option SO_BINDTODEVICE to make sure packet transfer happens though all lan ports are configured on the same subnet. Which is working fine for now:)
But, with all BPI-R2 lan ports (lan0-lan3) set on the same subnet IP, ping is failing from host though ARP entries are created. Is there a way to achieve this.
As I’ve shown you earlier it is possible to have more than a single IP/subnet assigned to the same interface in linux. So I second @frank-w and my earlier posts in this topic: your best bet would be to have all dsa ports in a bridge and have all 4 IP addresses assigned to this bridge. You will need to bind your sockets to the particular source IP instead of binding to a particular device.
P.S. And regarding physical connections: it is required and sufficient to have a single cable connected to your R2 into one of lanX ports. Do not connect two or more cables to the same network unless you set up some kind of a bond - it will create a network topology loop otherwise.
your best bet would be to have all dsa ports in a bridge and have all 4 IP addresses assigned to this bridge. You will need to bind your sockets to the particular source IP instead of binding to a particular device.
Yes, I am doing in the same way socket communication also happening.
From R2 I can ping to Host with ‘ping -I’ option. But from host, I am failing to ping R2(when Ips are configured on the same subnet), though arp entries are created. Is there something else I missing here?
One more generic query, today I connected usb-ethernet card to my Ubuntu PC(eth1 is created )and assigned same subnet IP as of eth0 and when I tried to ping from other PC to my Ubuntu PC its not working. May I know why ? and any solution if there are any.
Yep, exactly this. It is possible to have setup like this to be made into a functional state but it is not a trivial task. Read about sysctl (https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt) parameters like rp_filter, arp_filter, arp_ignore and so on. Get familiar with how to use “ip ru” and “ip ro * ta X”. It won’t be a smooth ride to administer a config like this. If you’ve got an option consider changing your network topology or application architecture. It might be a good idea to use docker here or at least split your application into several threads/processes and isolate network namespace for each of them.