zj2092 发表于 2018-5-15 10:57:42

linux debian 手机usb线和蓝牙拨号上网

  
  
  
  闲话少说,没有网络是很难过的,家里、单位都有网络,但偶尔没网的地方又想上网,就要充分利用手机的上网包月流量。
  本人手机:n97mini(只要支持蓝牙就行,呵呵)
  笔记本(laptop):华硕A2400(老爷机,256M内存,debian6)
  蓝牙适配器:Henkel,不知道,反正手机上显示ISSCBTM,这个linux应该没问题
  参考文档:首先当然是在官方wiki找:http://wiki.debian.org/UseYourCellPhoneAsModem,用连接线可以了,但是用蓝牙却不行,考虑是不是没开蓝牙拨号服务,因为在windows下可以,但一直没找到怎么看的方法。左搜右搜,最后终于在这篇文档上找到了答案:http://davesource.com/Solutions/20070520.T-Mobile-Nokia-E65-Ubuntu-Linux.html。原因很简单,因为手机不同,所以DUN(Dial Up Networking)服务对应的rfcomm端口不同,官方文档的是用2端口,见命令:rfcomm connect 0 11:22:33:44:55:66 2 &,后接&表示在后台运行,我的手机却是在22端口,这是用sdptool命令查到的,后面会说。好,下面就上操作步骤(参考官方文档,略加修改):
  1、首先查看、安装蓝牙服务。
  # /etc/init.d/bluetooth status
bluetooth is running
没有请安装
  #aptitude install bluetooth   或者 启动# /etc/init.d/bluetooth start
有些是这个命令,随便
#apt-get install bluez-utils(bluez) (在testing/unstable, bluez代替bluez-utils).
  2、插上蓝牙适配器,查看识别情况,一般没问题。
  #lsusb | grep -i bluetooth
(should show the bluetooth device)
Bus 004 Device 003: ID 1131:1001 Integrated System Solution Corp.
KY-BT100 Bluetooth Adapter
#hcitool dev
(also lists bluetooth devices)
  
  Devices:
    hci0    00:11:22:33:44:55 (这应该显示的是你的设备mac地址)
  3、手机与电脑配对,最好在手机上将电脑端设为授权设备,不用验证就可连接。
  4、设置手机Modem参数。
  用usb数据线接上手机,手机选“ovi套件”模式,然后安装拨号工具包。
  # apt-get install wvdial
# wvdialconf
  会创建配置文件/etc/wvdial.conf,

  Init1 = ATZ
  Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
  Phone = <your phone number>
  Username = <your username>
  Password = <your password>
  Baud = 460800
  ISDN = 0
  Modem Type = USB Modem
  Modem = /dev/ttyACM0
  修改如下(缺省的参数最好不要改,因为是自动生成的,只需要把号码、用户名、密码修改,然后加上条Init6,配置手机上网的方式):
  

Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init6 = AT+CGDCONT=1,&quot;IP&quot;,&quot;cmnet&quot;
New PPPD = yes
Phone = *99***1#
Username = any
Password = any
Baud = 460800
ISDN = 0


Modem Type = USB Modem
Modem = /dev/ttyACM0


Modem = /dev/rfcomm0
  然后用ifconfig命令将连网设备down。
  5、手机usb数据线拨号上网。
  # wvdial usb &
  6、手机蓝牙拨号上网还需要配置rfcomm参数。
  前面用hcitool dev命令看到了蓝牙适配器,下面用hcitool scan命令搜索手机。
  Scanning...
    00:11:22:33:44:55    NameDevice(这显示的是你的手机mac地址和名字)
  或者在手机上拨号&quot;*#2820#&quot;,得到手机的mac地址。然后用命令sdptool search dun或者sdptool browse 00:11:22:33:44:55(这里用你手机的mac地址)查找你手机拨号服务的rfcomm端口。
  sdptool search dun
Service Name: Dial-Up Networking
Service RecHandle: 0x1001e
Service Class ID List:
&quot;Dialup Networking&quot; (0x1103)
Protocol Descriptor List:
&quot;L2CAP&quot; (0x0100)
&quot;RFCOMM&quot; (0x0003)
    Channel: 2
Language Base Attr List:
code_ISO639: 0x454e
encoding:    0x6a
base_offset: 0x100
Profile Descriptor List:
&quot;Dialup Networking&quot; (0x1103)
    Version: 0x0100
  主要看channel的号码,我的手机是22,所以后面我修改rfcomm.conf端口号为22。我的文件/etc/bluetooth/rfcomm.conf内容。
  rfcomm0 {
#       # Automatically bind the device at startup
#       bind no;
#
#       # Bluetooth address of the device
      device e4:ec:10:d5:f4:ab;
#
#       # RFCOMM channel for the connection
      channel 22;
#
#       # Description of the connection
      comment &quot;wvdial connect blz&quot;;
}

rfcomm1 {
#       # Automatically bind the device at startup
#       bind no;
#
#       # Bluetooth address of the device
      device e4:ec:10:d5:f4:ab;
#
#       # RFCOMM channel for the connection
      channel 1;
#
#       # Description of the connection
       comment &quot;Example Bluetooth device&quot;;
}

请参照自己的手机修改。
  7、命令:rfcomm connect 0
  连接rfcomm0进行拨号上网,因为前面在rfcomm.conf里面设置了手机mac地址和端口号,所以这只要直接连接设备0就行了,如果不做上面设置,请在命令行输入:
  rfcomm connect 0 00:11:22:33:44:55 22 &
  8、看着电脑显示拨号连接信息,大功告成。
  
  
页: [1]
查看完整版本: linux debian 手机usb线和蓝牙拨号上网