linux routing linux-networking ethernet raspbian – How to Get Multiple Ethernet Ports Working on Linux

ethernetlinuxlinux-networkingraspbianrouting

I'm new to routing and networking so I hope some of you can help me to understand the issue and how to fix it.

Current Situation:

I have a linux server (raspbian/ubuntu). This server has two ethernet ports (each of them has its own MAC and fixed IP address). Please refer to the picture below in order to view the intended connections and the assigned IPs etc. (please click link below).

-> Please click for picture of current setup

To this linux server a microcontroller (µC) with a fixed IP address is connected on one ethernet port. This µC is sending data to the server that is then saved into a database on the linux server. The second ethernet port of the linux server is connected to a router. This router has access to the internet.
My computer (IP is dynamically assigned) is also connected to this router.

Problem:

When both ethernet ports on the linux server are connected they do not work as intended. The µC can send data to the linux server and I can connect to the internet from the linux server. However, if I want to connect to the linux server from my computer (filezilla, ftp, ssh etc.) I always get a timeout. It is not possible to connect to the server once both ethernet ports are active.
As soon as I disable one ethernet port (sudo ip link set eth0 down, or simply disconnect the enthernet cable from it), it is no problem to connect to the linux server from my computer.

I already tried a lot of stuff (adding custom routing tables, rules etc.) but I could not get it running the way I wish so far.
But at the same time I think I'm overthinking this as this really seems like it shouldnt be too much effort to get this setup working.

Most solutions I have tried so far go in this direction:
https://kindlund.wordpress.com/2007/11/19/configuring-multiple-default-routes-in-linux/

I hope some of you can tell me some obvious stuff I'm currently not seeing.
I appreciate every hint and attempt to help, thank you very much.

Best Answer

The problem you are having is that you have the same network configured on both network interfaces. This is not something you generally want.

Ideally you will have e.g. 192.168.1.0/24 on your microcontroller network, and 192.168.2.0/24 on your other connection. You can have only one connection to a given network. If you have a good reason to put the microcontroller in the same IP range as the other network, why not simply connect the microcontroller to that other network and forget about the second interface?

Another solution could be to put the two interfaces into a bridge, so that they are effectively on the same network. Unless the microcontroller is generating huge amounts of data (effectively saturating the network interface), this has no real advantage over simply using one interface.