Score:0

Netplan bridge multiple networks, Ubuntu 20.04 server

us flag

I have a robot with an onboard computer, that communicates via Ethernet to the base station (by way of radio, but the interface on the robot's computer is Ethernet). The Robot has a particular sensor mounted, which i'm able to communicate with using the sensor's API, the sensor connects to the robot via USB and appears on the robots list of networks as USB0, presumably by way of some USB Ethernet gadget.

The Ip address of USB0 is provided by DHCP from the sensor, but the ethernet network must use a static ip address.

I'd like to bridge the Ethernet - Eth0 network and the USB0 networks so that I can access the sensors webserver from the base station.

I'm not sure how one goes about bridging a static ip to a dhcp one (the dhcp ip address is always the same), or even if a bridge is the appropriate solution.

Here's my current netplan config file -

network:
  version: 2
  renderer: NetworkManager
  ethernets:
    eth0:
      dhcp4: false
      addresses: [192.168.1.150/24]
      gateway4: 192.168.1.254
      nameservers:
        addresses: [8.8.8.8,8.8.4.4]
      optional: true
  wifis:
    wlan0:
      dhcp4: true
      optional: true
      access-points:
        "Robot-AP":
          password: "SomePassword"
          mode: ap

The IP address of the sensor is 192.168.42.1 and the IP address of USB0 is 192.168.42.2

Score:0
us flag

A bridge only has one IP address that would be used on both sides. It sounds like you probably want routing, not a bridge.

To enable routing (assuming you don't need NAT) it's sufficient to set /proc/sys/net/ipv4/ip_forward to 1. Your machines on both sides would then need to know that the route for the other network is via the local interface on your router. However, it may not be possible to configure the routing table on your sensor. In this case, you will want to use NAT, so that when your base station tries to connect to the web port on your robot's ethernet IP, the connection is forwarded to your sensor.

There are many howtos for NAT on the Internet. http://linux-ip.net/html/nat-dnat.html is one that describes how to forward a single port, which is what you would want here.

Ben Bird avatar
us flag
Any ideas on the syntax?
us flag
updated the answer with more details
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.