Share iPhone internet connection with entire network through router

I want to share my iPhone's cellular internet connection over wifi to a router, and have clients be able to connect to the router using either wifi or ethernet and get internet access transparently.

The network also has to work reliably when the phone isn't present.


I'm no network engineer, but I found that this could most easily be accomplished with two routers. One that can be configured as a repeater, which will connect to the iPhone's wifi access point, and another that will just treat the first router as "the internet":

Internet --(3G/4G)--> iPhone --(Wifi)--> Router 1 in repeater mode --(Ethernet)-->[WAN socket] Router 2 ==(Ethernet, Wifi)==> Additional devices
  1. Connect to your iPhone's wifi as usual with your computer, and write down the gateway address and subnet mask that your computer's wifi connection gets assigned (e.g. in advanced wifi settings on macOS). In my case it was 172.20.10.1/255.255.255.240 -- the iPhone's own address.

  2. Configure router 1 as a repeater, which includes providing it the iPhone's wifi name and password that it should use to connect, as well as the IP address and subnetmask it should use on the iPhone's own wifi network. My subnet mask ends in 240 meaning I can choose from addresses 172.20.10.0-172.20.10.15. After excluding the special case 15 I chose 172.20.10.14 so as to minimize the chance of a collision with addresses that the iPhone might assign to new devices on the network.

    The iPhone's shared network should now be extended to router 1's ethernet ports, with the iPhone acting as the DHCP server and gateway.

  3. Since the network on router 1 now depends on the iPhone for dynamic assignment of addresses, I needed another router in order to create a stable LAN if I want to avoid having to manually configure the address of every single device in the network when the iPhone is not connected. Router 2 just operates as usual, creating its own LAN and providing DHCP on it.

    The iPhone will act as the ISP and assign router 2 an "external" IP (in my case 172.20.10.10) as soon as router 1 connects to the WAN socket of router 2.