0

I have a MacBook, a home network, five mobile hotspots, and five Raspberry Pis.

Each Pi is connected simultaneously to one mobile hotspot via wireless network, and to my home network via ethernet cable.

My MacBook is connected to the home network. From my MacBook, how can I send requests through the local network to the Pi, and then through the mobile hotspot, so that it appears like I'm making the request through the hotspot, rather than my home network?

NOTE: The point is to use the five hotspots as a pool of proxies that I can switch between programmatically, so simply connecting to the hotspot from my MacBook won't work.

If this question is off-topic or too vague, please let me know how and I can improve it.

1 Answer 1

0

Change your MacBook's default gateway IP address to the LAN IP address of whichever Raspberry Pi you want to use as your current gateway to the Internet.

Your Raspberry Pis will each need to be doing IP forwarding or NAT gatewaying, and they will each need to have their link to their mobile hotspot set as their default route.

4
  • Sweet. IP forwarding and NAT gatewaying were the keywords I needed for the Raspberry Pi setup. As for changing my MacBook's default gateway IP address, if I do that, will I still be able to receive requests from external users via my home network?
    – user1152976
    Commented Mar 24, 2020 at 5:26
  • Also, would it be possible for a Raspberry Pi to receive external requests, process them, and then send them along through the hotspot (rather than just blindly forwarding them)?
    – user1152976
    Commented Mar 24, 2020 at 6:06
  • @LisaBaier Your Mac knows the routes for the IP address ranges of the networks it's directly attached to, and beyond that it generally needs a single route for "everything else". It uses the default gateway for its highest-ranked, currently active network interface as its default route. If there were known, fixed, non-overlapping sets of IP addresses you wanted to reach via RPi, and you know for sure you won't need to access them over your home network's main Internet connection, then you could add static routes to you Mac's routing table. But I doubt that's your situation.
    – Spiff
    Commented Mar 24, 2020 at 17:05
  • @LisaBaier If your RPi is running, say, an HTTP server, and if the RPi is set to use its mobile hotspot as its default route, then yes, it could receive an HTTP request from the Internet (coming in through the mobile hotspot), process it with its HTTP server, and it would naturally reply back through its mobile hotspot. The trickiest part would be putting a port forwarding rule into the mobile hotspot's NAT gateway (assuming it's doing NAT), and making sure the mobile hotspot is not behind the mobile carrier's Carrier-Grade NAT (if the carrier does CGNAT).
    – Spiff
    Commented Mar 24, 2020 at 19:05

You must log in to answer this question.