Iphone Backup Internet

Ive had some issues every now and then when working from home, that my internet is down, so in order for my place to still function as a hole and not just my computer on a tether. I had to come up with a solution and for me that was creating a backup internet using an old iPhone for tethering by the router.

So my approach was to use a vm on my proxmox host to solve this as I can turn it on when I need, but this approach should be suitable to any kind of host, eg raspberry pi or something else.

Anyway so here is a brief setup you can do preemptively.

  1. Create an Ubuntu VM in Proxmox.
  • Give the vm a known ip adress, eg in this example 192.168.0.249
  1. Install the necessary packages: The ipheth-utils package is required for tethering iPhones. Install it along with other necessary utilities by running:

    apt install ipheth-utils net-tools libimobiledevice6 htop tcpdump iptables dnsmasq -y
    apt list --installed | grep "ipheth-utils\|mobiledevice"
    
  2. Check iPhone Connection: Make sure the iPhone is visible to the VM:

    lsusb
    dmesg|grep iPhone
    
Tethering the iPhone
  1. Enable USB Tethering on the iPhone: Go to Settings > Cellular > Set Up Personal Hotspot, and turn on USB Tethering.

  2. Configure the Network Interface: This will create a new network interface with an IP (e.g., 172.20.10.1).

    ip route delete default
    ip route add default via 172.20.10.1 dev enx82XXXXXXXXXX
    ip route add 192.168.0.0/16 via 192.168.0.1 dev ens18
    ip link set enx82XXXXXXXXXX up
    
  3. Set up IP Forwarding and NAT:

    iptables -t nat -I POSTROUTING -s 192.168.0.0/16 -j MASQUERADE
    iptables -I FORWARD -s 192.168.0.0/16 -j ACCEPT
    iptables -I INPUT -j ACCEPT
    sysctl -w net.ipv4.ip_forward=1
    vim /etc/sysctl.conf  # Make the change permanent
    
  4. Create a Network Configuration for Tethered Interface:

    # For networkd
    /etc/systemd/network/30-tethering.network
    [Match]
    Name=enx82XXXXXXXXXX
    [Network]
    DHCP=yes
    
    # For /etc/network/interfaces
    vim /etc/network/interfaces
    allow-hotplug enx82XXXXXXXXXX
    iface enx82XXXXXXXXXX inet dhcp
    

    Activate the interface:

    ip link set enx82XXXXXXXXXX up
    ifup enx82XXXXXXXXXX
    
  5. ** Configure Your Router **

    Create a new gateway for the internet on your router:

    route gateway 0.0.0.0/0 next-hop 192.168.0.249 eth1
    

And that it!

Now when the internet goes out, plug in that iphone, pass through that usb to the vm, enable your redirect and you are game. (offcourse you could automate all the steps or do a more robust solution but this is on my home so its good enough for me).



Buy Me a Coffee