1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

HOWTO: iPhone internet connection sharing via USB

Discussion in 'Howtos and FAQs (Moderated)' started by Zare, Dec 7, 2010.

  1. Zare

    Zare Member

    Thanks Received:
    This will probably also work for iPod/iPad also, but i don't have those.

    Enable "tethering" (don't you just love these web2.0 yuppie words? pfff...) in your device. Go to settings, network, internet tethering, and activate it.

    1. Kernel iPhone USB ethernet support

    There's a kernel module if_ipheth.ko in FreeBSD 8-STABLE (8.2-PRERELEASE as of writing this text), i'm not sure about earlier versions. I had the file in 8.1-RELEASE, but i can't say would it work because i haven't completed the whole procedure under 8.1-RELEASE.

    So just kldload that file and/or include it in your /boot/loader.conf

    2. USB libraries needed for communication

    We'll need libimobiledevice, libplist, usbmuxd and ipheth_pair. usbmuxd will establish connection to iPhone, and it needs libimobiledevice as a main dependency. libplist comes as libimobiledevice dependency. ipheth_pair will do actual pairing, communicating with device via usbmuxd. Before that happens we can't use iPhone as gateway.

    $ wget --no-check-certificate http://github.com/downloads/JonathanBec ... .3.tar.bz2
    $ tar xvfj libplist-1.3.tar.bz2 && cd libplist-1.3
    $ mkdir build && cd build && cmake ..
    $ su
    # make install

    $ http://www.libimobiledevice.org/downloads/libimobiledevice-1.0.4.tar.bz2
    $ tar xvfj libimobiledevice-1.0.4.tar.bz2 && cd libimobiledevice-1.0.4
    $ ./configure LDFLAGS="-L/usr/local/lib/"
    $ su
    # make install

    $ wget http://marcansoft.com/uploads/usbmuxd/u ... .6.tar.bz2
    $ tar xvfj usbmuxd-1.0.6.tar.bz2 && cd usbmuxd-1.0.6
    $ mkdir build && cd build && cmake ..
    $ su
    # make install

    If all goes ok, you'll have a functioning usbmuxd under /usr/local/sbin/usbmuxd. Now we need to take care of pairing program;

    $ git clone git://github.com/dgiagio/ipheth.git
    $ cd ipheth/ipheth-pair

    Forget the Makefile and just run this;

    $ cc -Wall -O2 ipheth-pair.c -o ipheth-pair -L/usr/local/lib -I/usr/local/include -limobiledevice

    3. Running / testing procedure

    Hook up your iPhone to USB port, and you should see something like this from your kernel output;

    ugen7.2: <Apple Inc.> at usbus7

    Now, run usbmuxd as root in foreground mode, so we see it's output

    # /usr/local/sbin/usbmuxd -U root -f

    This output indicates that communication to device has been established;

    [14:33:13.113][3] usbmuxd v1.0.6 starting up
    [14:33:13.119][3] Could not check kernel ownership of interface 0 for device 7-2: -99
    [14:33:13.170][3] Connecting to new device on location 0x70002 as ID 1
    [14:33:13.170][3] Initialization complete
    [14:33:13.171][3] Connected to v1.0 device 1 on location 0x70002 with serial number 37edfec09f8b80ea839ddbf01cf44030d942551b

    OK, let's now recheck kernel output via dmesg, kernel driver should now be able to create an ethernet device for iPhone's gateway connection;

    ipheth0: <Apple Inc. iPhone, class 0/0, rev 2.00/0.01, addr 2> on usbus7
    ue0: <USB Ethernet> on ipheth0
    ue0: Ethernet address: 78:ca:39:75:f8:ab

    So the device ue0 is created, but until we pair we won't have connectivity. Go back to the directory where you compiled ipheth-pair and run it. If all goes well it'll just drop you back to prompt without error message, and the blue title "Internet Tethering" will start blinking below the status bar of your iPhone.

    Just poll the device via DHCP and you're good to go.

    # dhclient ue0

    Note : for some reason, DHCP client does not push default gateway to my routing table and DNS server entry into resolv.conf. Default gw is the address you'll get your lease from (in my case, but the DNS server isn't, in my case it's (note it's still private scope). I had to connect my phone to Windows machine to see what kind of address USB<->ETH adapter over there gets.

    I haven't had time to check stability of this mechanism.
    vermaden thanks for this.
  2. vermaden

    vermaden Well-Known Member

    Thanks Received:
    Does it work for ANY iPhone, or only for older ones, or only for lates ones?
    Does it work for hacked/jailbroken iPhones?
  3. Zare

    Zare Member

    Thanks Received:
    I have iPhone 3GS. It should work with 3G and 4 also. And author of ipheth driver says it should work on 2G's with some patches. Since this mechanism is using Apple's protocol (you have same functionality in Windows or OSX), your phone doesn't have to be jailbroken.

    I'm sorry, you asked does it work for jailbroken phones? Yes it does, my phone is jailbroken. Because jailed iPhone is really a dumb brick.

    Keep in mind that jailbreaking doesn't modify system software, which recent cases against Apple proved. On the other hand, unlocking modifies system baseband code and i'm not sure would it work. There's no sane reason why it shouldn't but my phone isn't unlocked so i can't be 100% sure.