2

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.

H123321
  • 33
  • 1
  • 4
  • You do not want multiple default routes, that's only useful in a multi-homed system, i.e. a system with multiple connections to the internet. – wurtel Apr 02 '19 at 11:05
  • any suggestions on how to solve this issue? I'm kinda lost right now ... – H123321 Apr 02 '19 at 11:07

1 Answers1

4

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.

wurtel
  • 3,806
  • 12
  • 15
  • thank you for your answer. The microcontroller needs to have its own ethernet port. eth0 is used to receive data from the µC and eth1 is connected to the network so the data from the µC can be sent to a remote destination or that users can access the linux server as also a website runs on it. I can not change that. However, re-reading your solution it seems to me that this is not really a problem and I could just assign another IP to it (that belongs to another network)? – H123321 Apr 02 '19 at 11:14
  • What you want will still work if you simply disable the eth0 port and connect the microprocessor to the regular network, it's just like you're connecting to the server from your laptop. An issue might be that you don't want anything else on the network te be able to access the microprocessor. In that case choose another network for eth0, assign appropriate IP adresses on both the microprocessor and on eth0 and it should work. – wurtel Apr 02 '19 at 11:27
  • ok, so I could just assign a fixed IP in another subnet to the µC (e.g. 192.168.1.121 instead of 192.168.2.121) and another fixed IP in the same new subnet to eth0 (e.g. 192.168.1.120 instead of 192.168.2.120) to make this work? – H123321 Apr 02 '19 at 23:23
  • Yes, as long as the subnets are different. – wurtel Apr 03 '19 at 10:20
  • Do you see any potential issues with this approach, do I have to pay attention to certain things or can I just change the IP (subnet) like desribed above? (otherwise I would just check/ping the new IP to make sure it is free and not used and just change the IP/subnet). – H123321 Apr 04 '19 at 00:15
  • As long you're not using the subnet anywhere else in your network, then it should not be a problem. – wurtel Apr 04 '19 at 10:09