3

I'm trying to connect 3 subnets on 3 different NIC's together.

In the schematic below I tried to show the connection diagram. I'm going to connect an android phone via USB to a RPi4 and tether it's 4G/5G connection over this connection.

On the RPi4 is running a DHCP server for the network connected to the Ethernet port (Range 192.168.5.0/24).

I'll also connect another android phone by USB tethering, but without data connection.

As Android USB tethering runs it's own DHCP service etc., it's not possible to directly bridge all connections. (I think)

I'm able to direct traffic from the 192.168.5.0/24 network to the internet over the tethered connection.

So my question now is, is it possible to setup the Pi in such a way, that both android phones can connect straight to devices on the 192.168.5.0/24 subnet? Without the different DHCP servers interfering?

I'd like to not use Wlan as I'll be using this setup in a public space, where I'm not sure about the wireless interference and I don't want to broadcast this network, if not necessary.

┌───────────────────┐
│  Android Phone 1  │
│  USB Tether       │        USB
│  4G/5G            │◄───────────────────────┐
│                   │                        │
│  192.168.216.1    │                        │
└───────────────────┘                        │
                                             ▼
┌───────────────────┐                       ┌───────────────────────┐
│ Android Phone 2   │                       │  RPi 4                │
│ USB Tether        │        USB            │                       │
│ No Connection     │◄─────────────────────►│  Usb0: 192.168.216.21 │
│                   │                       │  Usb1: 192.168.42.15  │
│ 192.168.42.1      │                       │  Eth0: 192.168.5.1    │
└───────────────────┘                       │    DHCP: 192.168.5.1  │
                                            │                       │
┌───────────────────┐                       └───────────────────────┘
│ Ethernet Switch   │        Ethernet        ▲
│                   │◄───────────────────────┘
│ 192.168.5.0/24    │
└───────────────────┘
  ▲  ▲  ▲     ▲
  │  │  │     │
  │  │  │     │Ethernet
  │  │  │     │
  ▼  ▼  ▼     ▼
           ┌─────────────────┐
           │  PC 1           │
           │                 │
           │  192.168.5.100  │
           │                 │
           └─────────────────┘

If you need any more information, feel free to ask!

Thanks in advance!

Laurens

3
  • This will work as long as you don't require each device to see each other. It gets more complicated if they do have to see each other, and in that case it is much more simple to just put everything in the same subnet or use a router/switch capable of doing VLANs.
    – LPChip
    Commented Feb 9, 2022 at 20:38
  • Can you clarify the part about "both android phones can connect straight to devices on the 192.168.5.0/24 subnet"? Do you just mean literally, apps running on the phone being able to contact 192.168.5.x, or do you actually want to merge the 3 subnets outright? Commented Feb 9, 2022 at 20:47
  • I'd like to connect some camera's to the 192.168.5.0/24 network and control them using and app on the android smartphones. Commented Feb 9, 2022 at 20:51

1 Answer 1

1

So my question now is, is it possible to setup the Pi in such a way, that both android phones can connect straight to devices on the 192.168.5.0/24 subnet? Without the different DHCP servers interfering?

Likely not. The only mechanism to advertise routes (towards the Android subnets) that the Pi has, that even has a chance of working with regular devices, is DHCP. But as both phones act as DHCP servers on those interfaces, this implies they are not acting as DHCP clients, and therefore not going to pull any routes from the Pi that way (neither "default gateway" nor "classless static routes"). Their routing tables aren't going to point any destination through the USB interface except for its local subnet.

Probably the closest you can get is to set up a DNAT iptables rule (aka "port forwarding") on the Pi, so that Android phones could connect to the Pi (which they do have a route to) and it would translate the connection to one of your cameras. (For example, phone #1 connects to 192.168.216.21 port 20554, and the Pi DNATs it to 192.168.5.100 port 554 or something like that.)

(If neccessary, you could set up extra 192.168.216.x IP addresses on the Pi, where it would DNAT all ports to a specific 192.168.5.x device.)

1
  • Thanks for your reply! I've now got some more pointers to try and figure this out. Commented Feb 10, 2022 at 19:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .