Ubuntu連接到手機藍牙Modem上網
對大家推薦很好使用的Ubuntu連接系統,像讓大家對Ubuntu連接系統有所了解,然后對Ubuntu連接系統全面講解介紹,希望對大家有用本文記錄了我在Ubuntu連接中通過藍牙Nokia E71并通過E71作為Modem上網的過程。使用的硬件是安裝了Ubuntu 9.04 32位桌面版的IBM T60筆記本;裝載聯通WCDMA卡的Nokia E71港行(版本號是200開頭的)。參考網站:http://davesource.com/Solutions/20070520.T-Mobile-Nokia-E65-Ubuntu-Linux.html (懶得聽我廢話的直接看這個網站就行了)
聲明:這不是一篇技術翻譯,只是我自己參考其他站點的內容所實施實踐的一個記錄。
1、打開手機的藍牙,并通過Ubuntu連接到手機(這個時候只能瀏覽手機上的文件)。如果你的電腦有安裝藍牙設備,默認狀況下Ubuntu連接的桌面的右上方的通知欄里面會有藍牙的圖標,如果沒有顯示的話可以鍵入以下兩個命令確認安裝了相關的組件。并通過[系統]>[首選項]>[藍牙]的方式呼出連接菜單。
- # 安裝bluez-utils
- % apt-get install bluez-utils
- # 如果安裝過了的話apt會告知這個時候就直接跳到“安裝圖形配置工具”
- # 如果啟動了下載和安裝的話就說明原來沒有那就繼續執行下面的命令:
- % /etc/init.d/bluetooth restart
- % lsusb | grep -i bluetooth
- (should show the bluetooth device)
- % hcitool dev
- (also lists bluetooth devices) # 安裝圖形配置工具
% apt-get install bluez-gnome
2、使用sdptool命令確認你的手機的"Dialup Networking"服務,只要能夠找到這個服務基本就沒有問題。
- # browse后面的MAC地址換成你自己手機的
- # 如果不知道MAC地址的話在手機上輸入*#2820#
- % sdptool browse 11:22:BE:EF:44:33
- # 你會得到很多很多輸出
- ……省略……
- Service Name: Dial-Up Networking
- Service RecHandle: 0x10002
- Service Class ID List:
- "Dialup Networking" (0x1103) # 我們只關心這個服務
- Protocol Descriptor List:
- "L2CAP" (0x0100)
- "RFCOMM" (0x0003)
- Channel: 2 # 確認這個Channel,一般都是2
- Language Base Attr List:
- code_ISO639: 0x454e
- encoding: 0x6a
- base_offset: 0x100
- Profile Descriptor List:
- "Dialup Networking" (0x1103)
- Version: 0x0100
- ……省略……
3、利用rfcomm命令綁定設備
- # 將0后面的MAC地址換成你自己的(剛才用過了)
- # 最后一個數字就是剛才得到的Channel
- % rfcomm bind 0 11:22:BE:EF:44:33 2
- # 再用一次rfcomm命令確認一下綁定的結果
- % rfcomm
- rfcomm0: 11:22:BE:EF:44:33 channel 2 clean # 這種輸出就對了
- # 看一下dev下是不是有了一個rfcomm0的設備
- % ls /dev/rf*
- /dev/rfcomm0
4、Ubuntu連接編輯pppd的配置文件
- # 進入配置文件的存放目錄
- % cd /etc/ppp/peers
- # 通過ls命令可以看到一個名為provider的配置文件模板
- # 將其復制一份
- % cp provider gprs
- # 編輯新的配置文件
- % vi gprs
配置文件比較長,本文最后會貼出我用的那個配置文件,這里就說下幾個修改項目:
首先有一個user的配置項,我們不需要驗證,清空雙引號內的內容下面是connect將*****替換為要撥的號碼,請替換為*99#(雖然比較奇怪,但就是這個)后面是device的配置,原本應該是/dev/modem,我們題換成剛剛綁定好的/dev/rfcomm0即可速度的設定我嘗試下來不是非常重要,大家按實際設置吧,我隨便設了一個其他的選項不用動了,就這樣保存即可。
5、啟動連接,啟動之前建議關閉現有的Internet(如果有的話),這樣才能測試出效果
- # 啟動連接
- % pppd call gprs
- # 這個時候手機上應該會出現是否允許連接的認證提示,義無反顧的按下yes吧
- # 如果沒有任何錯誤提示就代表成功了
- # 用ifconfig命令來確認
- % ifconfig
- ……省略……
- ppp0 Link encap:點對點協議
- inet 地址:172.18.77.114 點對點:10.6.6.6 掩碼:255.255.255.255
- UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 躍點數:1
- 接收數據包:4 錯誤:0 丟棄:0 過載:0 幀數:0
- 發送數據包:5 錯誤:0 丟棄:0 過載:0 載波:0
- 碰撞:0 發送隊列長度:3
- 接收字節:64 (64.0 B) 發送字節:97 (97.0 B)
- ……省略……
- # 看到ppp0這段就代表確實成功了
開始上網吧,這篇博客就是在手機連接Internet的狀態下發表的。Ubuntu連接上這件事確實搞的比較麻煩,不如Windows和OS X。雖然我用的是聯通的WCDMA但是如果是移動或者聯通的GPRS網絡的話應該也能適用完全相同的設定。最后附上我的配置文件:
- # example configuration for a dialup connection authenticated with PAP or CHAP
- #
- # This is the default configuration used by pon(1) and poff(1).
- # See the manual page pppd(8) for information on all the options.
- # MUST CHANGE: replace myusername@realm with the PPP login name given to
- # your by your provider.
- # There should be a matching entry with the password in /etc/ppp/pap-secrets
- # and/or /etc/ppp/chap-secrets.
- user ""
- # MUST CHANGE: replace ******** with the phone number of your provider.
- # The /etc/chatscripts/pap chat script may be modified to change the
- # modem initialization string.
- connect "/usr/sbin/chat -v -f /etc/chatscripts/pap -T *99#"
- # Serial device to which the modem is connected.
- /dev/rfcomm0
- # Speed of the serial line.
- 4096000
- # Assumes that your IP address is allocated dynamically by the ISP.
- noipdefault
- # Try to get the name server addresses from the ISP.
- usepeerdns
- # Use this connection as the default route.
- defaultroute
- # Makes pppd "dial again" when the connection is lost.
- persist
- # Do not ask the remote to authenticate.
- noauth
【編輯推薦】