大网数据广告活动
服务器运维问答

How to get multiple Ethernet-Ports (NICs) working simultaneously on a linux device

· 52CE 我爱测

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 o…

问题原文

原帖链接 · H123321 · CC BY-SA 4.0

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.

已采纳解答

原帖链接 · wurtel · CC BY-SA 4.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-04-02)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。