Ubuntu 使用 iPhone 藍芽和 USB 上網分享

前晚在版圖遊戲聚會時拿出 ThinkPad T400s 來上網時,才發現沒在這台電腦的 Ubuntu 9.10 上,預先設定透用 iPhone 藍芽作 tethering。

跟著昨晚回家後便開始設定了,以下 Five Minutes: Tethering iPhone 3.0 to Ubuntu 9.04 提供的方法是以往我所用的。

下載 bluez-compat:
$ apt-get install bluez-compat

在 /etc/default/bluetooth 內加入以下兩行,然後重新啟動 /etc/init.d/bluetooth:
PAND_ENABLED=1
PAND_OPTIONS=”–role=PANU”

在 /etc/network/interfaces 內加入以下一行:
iface bnep0 inet dhcp

在 GNOME 的 Bluetooth applet 跟 iPhone 的藍芽 pair,right click 可以作設定。為了方便設定,Ubuntu 的 Bluetooth 最好是設定在可被搜尋的,以便在 Bluetooth applet 指定設定 iPhone 時,iPhone 彈出確認由 Ubuntu 發出的 PIN 訊息。

完成設定後,每次連接時只需輸入藍芽地址:
(假設 00:aa:bb:cc:dd:ee 是 iPhone
$ sudo pand –connect 00:aa:bb:cc:dd:ee -n
$ sudo ifup bnep0

中斷連結時:
$ sudo ifdown bnep0
$ sudo pand -K

昨晚我也發現了另一個網站 Ubuntu Geek – iPhone Tethering on Ubuntu 9.10 (Karmic) 提到,已有用戶貢獻的 PPA repository 提供更簡便的安裝方法。而且剛發現 Linux 社群已有經 USB 使用 iPhone Tethering 的方法了,以前 iPhone Tethering 剛出時,Linux 暫未能辨別和使用 iPhone 的 USB tethering 作 network device。所以我也在 ThinkPad 上試裝了 iPhone USB tethering 方法。

$ sudo add-apt-repository ppa:pmcenery/ppa
$ sudo apt-get update
$ sudo apt-get install gvfs ipheth-utils

在裝好了 packages 和插入 USB 來連接 iPhone 後,Network Manager 應該可以自動使用新的 ethernet 裝置,並自動取得 IP 地址,但我需要 reboot 一次 Ubuntu 才成。

About Sammy Fung

Sammy Fung 是開放源碼倡導者,Python Software Foundation Fellow,創辦 Open Source Hong Kong、香港開源年會及 PyCon HK,曾任 GNOME Foundation 董事,現為開發者關係專家,致力推廣開源軟件、開放數據與開源 AI。