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
    What is wireless tether? I do not have an iOS device, but on my Android 9 smartphone I find a WLAN-Hotspot, USB-Tethering and Bluetooth-Tethering. There is no wireless tethering. Do you mean that Bluetooth-Tethering as wireless? – Ingo May 14 '20 at 23:05
  • 1
    iOS generally uses 802.11n for tethering (sorry, I usually use wireless to indicate the 802.11* standard vs Bluetooth). – ylluminate May 14 '20 at 23:09
  • 1
    Tethering is tethering and all methods will give you an ethernet interface, maybe with different names, on the RasPi. So testing with e.g. USB-Tethering will also cover the other connections. Can you confirm this? – Ingo May 14 '20 at 23:20
  • 1
    I believe you're correct. I have tested this with a USB ethernet adapter and it showed up as eth1 for Ubuntu Server 20.04 on the RasPi. – ylluminate May 14 '20 at 23:24
  • 2
    OK, I will look for one solution with USB-Tethering with my android phone. Then you should be able to modify it for your other connections. But at my home its after midnight now. Will come back later. – Ingo May 14 '20 at 23:42

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,107
  • 20
  • 85
  • 197