3

I have a Raspberry Pi 3B+ unit that I'd like to use as a "travel router" to attach multiple networks to the Internet via any one of a few different tetherable phones a la the following diagram via both USB and wireless:

diagram

I'd like to run DHCPD on the Rasp. Pi so that the "router" will pull an IP and then of course simply pull an IP from the phone devices via DHCP as well. It would also be nice if the Raspberry PI USB would charge the phone, but I could connect a powered USB hub for that if necessary.

How could this be set up on a Raspberry PI?

NOTE: "wireless tether" is 802.11 (n in my iOS case).

ylluminate
  • 131
  • 4

1 Answers1

2

You have to configure the RasPi as a simple router. With tethering you should always get an ethernet interface. For example with USB-Tethering you get the interface usb0 out of the box with Raspbian. You can use this interface like any other network interface. I use systemd-networkd to configure networking because it makes things easier.

Just follow to Use systemd-networkd for general networking. You can use section "♦ Quick Step". Then come back here.

Now configure interfaces with these files. Be sure that you do not use the same subnet than from your tethered connection. In this example I use subnet 192.168.4.0/24 for the local network. The subnet of your tethered interface must be different from this.

rpi ~# cat > /etc/systemd/network/04-wired.network <<EOF
[Match]
Name=eth0
[Network]
Address=192.168.4.1/24
IPMasquerade=yes
DHCPServer=yes
[DHCPServer]
DNS=84.200.69.80 1.1.1.1
EOF

rpi ~# cat > /etc/systemd/network/08-uplink.network <<EOF
[Match]
Name=usb*
[Network]
DHCP=yes
EOF

Reboot, and it should do.

As you see, you can use wildcards to [Match] an interface name. If you get other interface names from tethering, just add them to the Name= line, e.g. Name=usb* wlan*.

Ingo
  • 42,961
  • 20
  • 87
  • 207