Score:0

Ubuntu 20.04 with two NIC, but only one works

jp flag

As the title says, I have a system running Ubuntu 20.04 with two NICs.One NIC (ens9) is connected to the cameras (via a switch) and the other (ens4) is connected to a LiDAR. I am running a DHCP server on only one of the port (ens9), and that works ok. My problem, is that only one of the ports work a given time. Its most properly the one that's connected first.

Here is my configuration for the interface from file /etc/netplan/01-network-manager-all.yaml

# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager
  ethernets: 
    ens9: 
      dhcp4: no 
      addresses: [192.168.1.100/24] 
      gateway4: 192.168.1.1 
      nameservers: 
        addresses: [8.8.8.8,8.8.4.4]
      
      mtu: 9000
    
    ens4: 
      dhcp4: no 
      addresses: [192.168.1.101/24] 
      nameservers: 
        addresses: [8.8.8.8,8.8.4.4]

      mtu: 9000

I am not sure what I am doing wrong. Any help is greatly appreciated.

Score:0
br flag

The address settings you described are most likely incorrect. Since you have 2 interfaces, at least two usage scenarios are possible. Please post which one you are using.

A) The same network

Both interfaces are connected to the same physical network, e.g. to a single switch or across multiple switches, and can "see" each other. In this case, a second interface with a different address is unnecessary and will cause complications. Two interfaces only make sense when you use them in a team for higher speed or for redundancy in case one of them fails.

B) Two separated networks

The two interfaces are connected to separate network segments and packets from one interface cannot reach the other in any way. In this case, your IP addresses are completely wrong. Each interface must have an address from a different network. You cannot use the same network 192.168.1.0/24 for two different interfaces connected to two different network segments on the same machine (device). The system will get confused and not know whether to route packets to the 192.168.1.0/24 network via ens9 or ens4.

Solution

Addresses:

I assume that the network for LiDAR is an isolated segment used only for the connection between the PC and the LiDAR. This means that scenario B) applies. Then the solution is easy. Use another network and set the addresses as follows:

  • ens9: 192.168.1.100/24
  • ens4: 192.168.2.100/24
  • LiDAR: 192.168.2.5/24 (or use any other number from 1 to 254 except 100 instead of the last octet .5, since the address 100 will be on the ens4 interface).

Gateway:

It is correct that you only have the default gateway on one ens9 interface.

Nameservers:

Be sure to remove the nameserver definition from the ens4.

user3785280 avatar
jp flag
You are right, both my networks were independent. I initially didn't care if both the devices were on the same network or not. But your suggestion worked, its working for me. Thank you.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.