IPhone USB 테더링

Ubuntu Korea Community Wiki
둘러보기로 이동 검색으로 이동
  • 본 문서는 우분투에서 iPhone USB 테더링을 사용하는 방법을 서술 하고 있습니다.
  • 기존의 탈옥폰에서 SSH 터널링을 이용하는 방법은 아닙니다
  • Ubuntu 10.04 버전에 관련 라이브러리가 기본으로 포함된 기념으로 작성했습니다.
  • Ubuntu 16.04 버전에서의 사용법을 추가했습니다. (by 공작명왕)

준비물[편집]

  • iPhone (설정→네트워크→테더링을 활성화 해둔 상태)
  • 커널 드라이버 컴파일 환경 (linux-headers-현재커널버전 패키지 및 build-essential 설치된 상태)
  • git 관련
  • libimobiledevice
  • ipheth 프로젝트 파일

우분투에서 사전작업[편집]

먼저 git 관련 패키지가 있는지 확인하고 없으면 아래의 명령으로 설치합니다.

{{#ifeq: msg|user|~|{{#ifeq: misc|user|~  sudo apt-get install git-core|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}}  sudo apt-get install git-core}}}}

libimobiledevice 관련 라이브러리와 개발패키지를 설치합니다. (10.04에는 리포지토리에 기본으로 있습니다)

{{#ifeq: msg|user|~|{{#ifeq: misc|user|~  sudo apt-get install libimobiledevice0 libimobiledevice-dev|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}}  sudo apt-get install libimobiledevice0 libimobiledevice-dev}}}}

ipheth 프로젝트 패키지를 다운로드 합니다.

{{#ifeq: msg|user|~|{{#ifeq: misc|user|~  git clone git://github.com/dgiagio/ipheth.git|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}}  git clone git://github.com/dgiagio/ipheth.git}}}}

ipheth 디렉토리에 ipheth-driver와 ipheth-pair 디렉토리가 존재하는지 확인합니다

ipheth-pair 디렉토리에서 컴파일 후 설치합니다

{{#ifeq: msg|user|~|{{#ifeq: misc|user|~  cd ipheth-pair|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}}  cd ipheth-pair}}}}
{{#ifeq: msg|user|ipheth-pair|{{#ifeq: misc|user|ipheth-pair  make|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ipheth-pair {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}}  make}}}}
{{#ifeq: msg|user|ipheth-pair|{{#ifeq: misc|user|ipheth-pair  sudo make install|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ipheth-pair {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}}  sudo make install}}}}

ipheth-driver 디렉토리에서 커널 드라이버 모듈을 빌드하고 설치합니다.

{{#ifeq: msg|user|~|{{#ifeq: misc|user|~  cd ipheth-driver|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}}  cd ipheth-driver}}}}
{{#ifeq: msg|user|ipheth-driver|{{#ifeq: misc|user|ipheth-driver  make|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ipheth-driver {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}}  make}}}}
{{#ifeq: msg|user|ipheth-driver|{{#ifeq: misc|user|ipheth-driver  sudo make install|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ipheth-driver {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}}  sudo make install}}}}
{{#ifeq: msg|user|ipheth-driver|{{#ifeq: misc|user|ipheth-driver  depmod -a|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ipheth-driver {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}}  depmod -a}}}}

위 과정을 거치면 테더링용 USB 드라이버가 설치됩니다.

테더링 사용[편집]

먼저 ipheth 커널 드라이버 모듈을 불러옵니다

{{#ifeq: msg|user|~|{{#ifeq: misc|user|~  sudo modprobe ipheth|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}}  sudo modprobe ipheth}}}}
{{#ifeq: msg|user|~|{{#ifeq: misc|user|~  lsmod | grep ipheth|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}}  lsmod | grep ipheth}}}}

정상적으로 불러왔다면 lsmod 명령 결과에 나타납니다.

dmesg 명령으로 정상적으로 불러왔는지 확인합니다

{{#ifeq: msg|user|~|{{#ifeq: misc|user|~  dmesg | grep ipheth|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}}  dmesg | grep ipheth}}}}
{{#ifeq: msg|msg|usbcore: registered new interface driver ipheth|{{#ifeq: misc|msg|usbcore: registered new interface driver ipheth  {{{2}}}|{{#ifeq: root|msg|ubuntu-korea|{{#ifeq: user|msg|user@ubuntu-korea|(undefined)}}}} usbcore: registered new interface driver ipheth {{#ifeq: root|msg|#|{{#ifeq: user|msg|$|$}}}}  {{{2}}}}}}}

이제 아이폰을 USB케이블로 연결하고 제대로 연결했는지 아래 명령을 실행하여 확인합니다.

{{#ifeq: msg|user|~|{{#ifeq: misc|user|~  dmesg | grep iPhone|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}}  dmesg | grep iPhone}}}}
{{#ifeq: msg|msg|ipheth 2-1:4.2: Apple iPhone USB Ethernet device attached|{{#ifeq: misc|msg|ipheth 2-1:4.2: Apple iPhone USB Ethernet device attached  {{{2}}}|{{#ifeq: root|msg|ubuntu-korea|{{#ifeq: user|msg|user@ubuntu-korea|(undefined)}}}} ipheth 2-1:4.2: Apple iPhone USB Ethernet device attached {{#ifeq: root|msg|#|{{#ifeq: user|msg|$|$}}}}  {{{2}}}}}}}

잠시 기다리면 알림 메시지로 새로운 네트워크 장치 등록을 알립니다. 네트워크 관리 프로그램에서 새로운 장치(보통 auto eth1)등록이 확인됩니다.

이제 잘 사용하시면 됩니다 :)

Ubuntu 16.04[편집]

2016년 7월 5일 (화) 00:30 (KST)

Ubuntu Desktop 16.04 LTS 에서 동작하지 않습니다.


[ 2076.177925] ipheth 1-2:4.2: ipheth_rcvbulk_callback: urb status: -71
[ 2076.178859] usb 1-2: USB disconnect, device number 5
[ 2076.207090] ipheth 1-2:4.2: Apple iPhone USB Ethernet now disconnected
[ 2081.003543] usb 1-2: new high-speed USB device number 6 using xhci_hcd
[ 2081.191066] usb 1-2: New USB device found, idVendor=05ac, idProduct=12a8
[ 2081.191078] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 2081.191086] usb 1-2: Product: iPhone
[ 2081.191092] usb 1-2: Manufacturer: Apple Inc.
[ 2081.191098] usb 1-2: SerialNumber: 818c7f5caf2933151a3a6743c2d4eef25795a9af
[ 2081.193152] usb 1-2: ep 0x2 - rounding interval to 8 microframes, ep desc says 10 microframes
[ 2081.193172] usb 1-2: ep 0x81 - rounding interval to 8 microframes, ep desc says 10 microframes
[ 2081.273577] usb 1-2: ep 0x2 - rounding interval to 8 microframes, ep desc says 10 microframes
[ 2081.273583] usb 1-2: ep 0x81 - rounding interval to 8 microframes, ep desc says 10 microframes
[ 2081.281212] ipheth 1-2:4.2: Apple iPhone USB Ethernet device attached
[ 2081.287431] ipheth 1-2:4.2 enp0s20f0u2c4i2: renamed from eth0
[ 2081.311786] IPv6: ADDRCONF(NETDEV_UP): enp0s20f0u2c4i2: link is not ready
[ 2081.312346] IPv6: ADDRCONF(NETDEV_UP): enp0s20f0u2c4i2: link is not ready

$ ifconfig
enp0s20f0u2c4i2 Link encap:Ethernet  HWaddr 1e:5c:f2:52:44:b4  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:4 errors:0 dropped:1 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:380 (380.0 B)  TX bytes:0 (0.0 B)

아이폰은 파란 막대바가 표시되고 hotspot이 동작중이라고 나오나 리눅스에서는 IP를 받아오질 못하고 인터넷 연결이 안됩니다.

github 에서 소스를 받아다 설치하려 했는데...

git clone git://github.com/dgiagio/ipheth.git

ipheth-pair은 컴파일이 잘되나 ipheth-driver는 안되네요.

~/temp/ipheth/ipheth-driver$ make
make -C /lib/modules/4.4.0-28-generic/build M=/home/temp/ipheth/ipheth-driver modules
make[1]: Entering directory '/usr/src/linux-headers-4.4.0-28-generic'
  CC [M]  /home/temp/ipheth/ipheth-driver/ipheth.o
/home/temp/ipheth/ipheth-driver/ipheth.c: In function ‘ipheth_probe’:
/home/temp/ipheth/ipheth-driver/ipheth.c:575:2: error: implicit declaration of function ‘SET_ETHTOOL_OPS’ [-Werror=implicit-function-declaration]
  SET_ETHTOOL_OPS(netdev, &ops);
  ^
cc1: some warnings being treated as errors
scripts/Makefile.build:264: recipe for target '/home/temp/ipheth/ipheth-driver/ipheth.o' failed
make[2]: *** [/home/temp/ipheth/ipheth-driver/ipheth.o] Error 1
Makefile:1403: recipe for target '_module_/home/temp/ipheth/ipheth-driver' failed
make[1]: *** [_module_/home/temp/ipheth/ipheth-driver] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.4.0-28-generic'
Makefile:11: recipe for target 'all' failed
make: *** [all] Error 2

2016년 8월 10일 (수) 14:03 (KST)

컴파일은 포기하고 다음과 같이 했더니 일단 테더링은 잘 된다.

현재 커널 버전 확인

{{#ifeq: msg|user|~|{{#ifeq: misc|user|~  uname -a|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}}  uname -a}}}}
{{#ifeq: msg|msg|Linux ubuntu-korea 4.4.0-31-generic #50-Ubuntu SMP Wed Jul 13 00:07:12 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux|{{#ifeq: misc|msg|Linux ubuntu-korea 4.4.0-31-generic #50-Ubuntu SMP Wed Jul 13 00:07:12 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux  {{{2}}}|{{#ifeq: root|msg|ubuntu-korea|{{#ifeq: user|msg|user@ubuntu-korea|(undefined)}}}} Linux ubuntu-korea 4.4.0-31-generic #50-Ubuntu SMP Wed Jul 13 00:07:12 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux {{#ifeq: root|msg|#|{{#ifeq: user|msg|$|$}}}}  {{{2}}}}}}}


라이브러리 패키지 설치

{{#ifeq: msg|user|~|{{#ifeq: misc|user|~  sudo apt-get install libimobiledevice4 libimobiledevice-dev|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}}  sudo apt-get install libimobiledevice4 libimobiledevice-dev}}}}

Install USB tethering driver support utilities for the iPhone

{{#ifeq: msg|user|~|{{#ifeq: misc|user|~  sudo apt-get install ipheth-utils|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}}  sudo apt-get install ipheth-utils}}}}

이제 위의 테더링 사용을 참조하여 확인하고 사용하면 됩니다.

이제 아이폰을 USB케이블로 연결하고 제대로 연결했는지 아래 명령을 실행하여 확인합니다.

{{#ifeq: msg|user|~|{{#ifeq: misc|user|~  dmesg | grep iPhone|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}}  dmesg | grep iPhone}}}}
{{#ifeq: msg|msg|[78036.128123] usb 1-2: Product: iPhone|{{#ifeq: misc|msg|[78036.128123] usb 1-2: Product: iPhone  {{{2}}}|{{#ifeq: root|msg|ubuntu-korea|{{#ifeq: user|msg|user@ubuntu-korea|(undefined)}}}} [78036.128123] usb 1-2: Product: iPhone {{#ifeq: root|msg|#|{{#ifeq: user|msg|$|$}}}}  {{{2}}}}}}}}
{{#ifeq: msg|msg|[78036.215919] ipheth 1-2:4.2: Apple iPhone USB Ethernet device attached|{{#ifeq: misc|msg|[78036.215919] ipheth 1-2:4.2: Apple iPhone USB Ethernet device attached  {{{2}}}|{{#ifeq: root|msg|ubuntu-korea|{{#ifeq: user|msg|user@ubuntu-korea|(undefined)}}}} [78036.215919] ipheth 1-2:4.2: Apple iPhone USB Ethernet device attached {{#ifeq: root|msg|#|{{#ifeq: user|msg|$|$}}}}  {{{2}}}}}}}