IPhone – Tethering an iPad / iPhone to a Raspberry Pi

ipadiphonetetheringusb

Questions

My concerns are focused on enabling USB tethering in an iDevice (iOS 12 iPhone X and iPad Air):

  1. What are the steps for tethering IOS 12 devices? Is it just one switch on the Android or iDevice's?
  2. Does the iDevice require configuring any other USB tethering settings?
  3. Is there a simple litmus test to confirm that tethering setting is working? (ping?)

Goal

I am interested in using an iOS12 device, instead of an Android device, to display VNC output from a Raspberry Pi (rPi) as described in the blog: Raspberry Pi Display over USB.

The goal is to be able to view / control rPi from iDevice (VNC or SSH) through USB-IP networking:

  • power up your rPi,
  • plug in your iDevice into the rPi via USB,
  • turn on USB tethering
  • connect iDevice to USB0 via VNC or SSH client app

Please indicate in replies if you have successful USB-IP networking experience (SSH VNC).

iDevice (phone \ tablet) configuration instructions:

  • VNC Viewer app to connect iDevice to tightvncserver over USB-IP connection
  • JuiceSSH app to SSH from iDevice to rPi over USB-IP connection
  • Turn on iDevice's USB tethering

rPI configuration instructions:

  1. sudo apt-get install tightvncserver
  2. assigning a static IP, 192.168.42.42 to the rPi's USB0 interface:

    sudo nano /etc/network/interfaces

Paste the following onto the bottom of the file, then save and exit (ctrl-X, Y):

iface usb0 inet static
address 192.168.42.42
netmask 255.255.255.0
network 192.168.42.0
broadcast 192.168.42.255

It is also possible to append or echo the settings to the target file:

echo "iface usb0 inet static" | sudo tee -a /etc/network/interfaces
echo "address 192.168.42.42" | sudo tee -a /etc/network/interfaces
echo "netmask 255.255.255.0" | sudo tee -a /etc/network/interfaces
echo "network 192.168.42.0" | sudo tee -a /etc/network/interfaces
echo "broadcast 192.168.42.255" | sudo tee -a /etc/network/interfaces

It would be nice if there was a command to test static IP assignment?

Details how to temporarily route rPi traffic through a WAN- connected Android Device:

  • use arp -a command to identify phone's IP address
  • use route add default gw 192.168.42.129 usb0

Best Answer

It's actual a very simple setup that is needed that doesn't involve "tethering" at all.

Basically what you need to do is to set up the Raspberry Pi for USB "gadget" - meaning that it makes an ethernet device available over USB. For the most easy setup, setup a DHCP server on the Raspberry Pi to automatically give out IPs.

On the iOS device - all you need to do to get it working is to plug it in, and then open a VNC app and enter the IP address and port number of the Raspberry Pi to open the connection.

If you do not install a DHCP server on the Raspberry Pi, but instead follow the instructions you've linked, then you need to set the IP address manually on the iOS device. You do that from Settings => Ethernet, and then set it manually to a not used address within the same subnet. If you follow the linked instructions the RPi will be available at 192.168.42.42, so set the IP address of the iOS device to 192.168.42.43 for example.

The tricky part in the above is not to do with the iOS device itself, but rather the configuration of the Raspberry Pi. There exists several types of USB "gadget" ethernet devices, and various variations of them. iOS does not support all of them (at all) - Android does not either. In addition there seem to be a difference between iOS devices, which I cannot comment on in your general case because you haven't said anything about which device you have. But for example the iPad Pro seems to be more forgiving than an iPhone in this respect.

You can get the exact same setup with having to configure the USB "gadget" interface by using a USB-ethernet dongle with the iOS device. If you plug that in to the iOS device and connect an ethernet cable from that to the ethernet port on the Raspberry Pi - you can achieve the same thing.

Update: I see in your update that you emphasized on the requirement to list experience with "USB-IP". I do have succesful experience with "USB-IP" as you call it (it's not really called that). However be wary that the hard part of the configuration is on the Linux side - not on the iOS side. Also note that even though your linked instructions detail a single method of enabling a usb0 interface - in reality it is quite complicated with two majorly different modes of configuration, and within each mode several different protocols, and for each protocol various setup options.