分类: LINUX
2011-04-04 23:57:54
1. 把HuaWei 3G上网卡insert到电脑的USB port.
#dmesg | grep HUAWEI
[ 4411.960220] scsi 10:0:0:0: CD-ROM HUAWEI Mobile CMCC CD 1.25 PQ: 0 ANSI: 0
# lsusb | grep Huawei
Bus 005 Device 007: ID 12d1:1d09 Huawei Technologies Co., Ltd.
这里需要记下ID 后面的.
2.
下载安装usb_modeswitch .
下载地址:
安装请看软件的README文件.
拷贝编译完的usb_modeswitch 到/sbin下
#usb_modeswitch -h 查看使用方法
#usb_modeswitch -W 最好执行一下,查看一下设置 print all settings before running
3.需要修改 /etc/wvdial.conf 配置文件.
Please see my config file:
[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = USB Modem
Baud = 460800
;Baud = 9216000
New PPPD = yes
Modem = /dev/ttyACM2 #这里我是安装了gnome-ppp自动识别出来的
;Modem = /dev/ttyUSB0
ISDN = 0
; Phone =
; Password =
; Username =
Phone = *99***1#
Password = any
Username = any
Stupid Mode = 1
4.拔号
$sudo wvdial
可能需要等一会,你会看到
heqiang@heqiang-laptop:~$ sudo wvdial
–> WvDial: Internet dialer version 1.60
–> Cannot get information for serial port.
–> Initializing modem.
–> Sending: ATZ
ATZ
OK
–> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
–> Modem initialized.
–> Sending: ATDT*99***1#
–> Waiting for carrier.
ATDT*99***1#
CONNECT 236800
–> Carrier detected. Starting PPP immediately.
–> Starting pppd at Thu Jun 11 14:17:31 2009
–> Pid of pppd: 19674
–> Using interface ppp0
–> pppd: п��P)J[08]@)J[08]
–> pppd: п��P)J[08]@)J[08]
–> pppd: п��P)J[08]@)J[08]
–> pppd: п��P)J[08]@)J[08]
–> pppd: п��P)J[08]@)J[08]
–> pppd: п��P)J[08]@)J[08]
–> pppd: п��P)J[08]@)J[08]
–> local IP address 10.68.212.84
–> pppd: п��P)J[08]@)J[08]
–> remote IP address 192.200.1.21
–> pppd: п��P)J[08]@)J[08]
–> primary DNS address 221.130.33.52
–> pppd: п��P)J[08]@)J[08]
–> secondary DNS address 221.130.33.60
–> pppd: п��P)J[08]@)J[08]
说明连接成功了!
$sudo ifconfig ppp0
ppp0 Link encap:点对点协议
inet 地址:10.68.212.84 点对点:192.200.1.21 掩码:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 跃点数:1
接收数据包:18798 错误:0 丢弃:0 过载:0 帧数:0
发送数据包:14731 错误:0 丢弃:0 过载:0 载波:0
碰撞:0 发送队列长度:3
接收字节:23233292 (23.2 MB) 发送字节:1357737 (1.3 MB)
5.
这里写的比较单,相信你能成功.
不行的话,下面的希望有用:
一开始插上3G卡的时候,lsusb显示为:
ubuntu@Ubuntu:~$ lsusb | grep Huawei
Bus 002 Device 002: ID 12d1:1da1 Huawei Technologies Co., Ltd.
这时候,修改/etc/usb_modeswitch.conf:
DefaultVendor= 0x12d1
DefaultProduct= 0x1da1
TargetVendor= 0x12d1
TargetProduct= 0x1da1
HuaweiMode=1
执行sudo usb_modeswitch -W 令修改生效。这时候
ubuntu@Ubuntu:~$ lsusb | grep Huawei
Bus 002 Device 002: ID 12d1:1d09 Huawei Technologies Co., Ltd.
会发现1da1变成了1d09. 然后再修改/etc/usb_modeswitch.conf
DefaultVendor= 0x12d1
DefaultProduct= 0x1d09
TargetVendor= 0x12d1
TargetProduct= 0x1d09
;HuaweiMode=1
再执行sudo usb_modeswitch -W令修改生效。
检查/dev/下面, 会出来ttyACM0, ttyACM1, 和ttyACM2.
然后再执行sudo wvdialconf自动生成配置文件
ubuntu@Ubuntu:~$ sudo wvdialconf
Editing `/etc/wvdial.conf’.
Scanning your serial ports for a modem.
Modem Port Scan<*1>: S0 S1 S2 S3
WvModem<*1>: Cannot get information for serial port.
ttyACM0<*1>: ATQ0 V1 E1 — OK
ttyACM0<*1>: ATQ0 V1 E1 Z — OK
ttyACM0<*1>: ATQ0 V1 E1 S0=0 — OK
ttyACM0<*1>: ATQ0 V1 E1 S0=0 &C1 — OK
ttyACM0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 — OK
ttyACM0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 — OK
ttyACM0<*1>: Modem Identifier: ATI — Manufacturer: HuaWei
ttyACM0<*1>: Speed 4800: AT — OK
ttyACM0<*1>: Speed 9600: AT — OK
ttyACM0<*1>: Speed 19200: AT — OK
ttyACM0<*1>: Speed 38400: AT — OK
ttyACM0<*1>: Speed 57600: AT — OK
ttyACM0<*1>: Speed 115200: AT — OK
ttyACM0<*1>: Speed 230400: AT — OK
ttyACM0<*1>: Speed 460800: AT — OK
ttyACM0<*1>: Max speed is 460800; that should be safe.
ttyACM0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 — OK
WvModem<*1>: Cannot get information for serial port.
ttyACM1<*1>: ATQ0 V1 E1 — OK
ttyACM1<*1>: ATQ0 V1 E1 Z — OK
ttyACM1<*1>: ATQ0 V1 E1 S0=0 — OK
ttyACM1<*1>: ATQ0 V1 E1 S0=0 &C1 — OK
ttyACM1<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 — OK
ttyACM1<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 — OK
ttyACM1<*1>: Modem Identifier: ATI — Manufacturer: HuaWei
ttyACM1<*1>: Speed 4800: AT — OK
ttyACM1<*1>: Speed 9600: AT — OK
ttyACM1<*1>: Speed 19200: AT — OK
ttyACM1<*1>: Speed 38400: AT — OK
ttyACM1<*1>: Speed 57600: AT — OK
ttyACM1<*1>: Speed 115200: AT — OK
ttyACM1<*1>: Speed 230400: AT — OK
ttyACM1<*1>: Speed 460800: AT — OK
ttyACM1<*1>: Max speed is 460800; that should be safe.
ttyACM1<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 — OK
WvModem<*1>: Cannot get information for serial port.
ttyACM2<*1>: ATQ0 V1 E1 — OK
ttyACM2<*1>: ATQ0 V1 E1 Z — OK
ttyACM2<*1>: ATQ0 V1 E1 S0=0 — OK
ttyACM2<*1>: ATQ0 V1 E1 S0=0 &C1 — OK
ttyACM2<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 — OK
ttyACM2<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 — OK
ttyACM2<*1>: Modem Identifier: ATI — Manufacturer: HuaWei
ttyACM2<*1>: Speed 4800: AT — OK
ttyACM2<*1>: Speed 9600: AT — OK
ttyACM2<*1>: Speed 19200: AT — OK
ttyACM2<*1>: Speed 38400: AT — OK
ttyACM2<*1>: Speed 57600: AT — OK
ttyACM2<*1>: Speed 115200: AT — OK
ttyACM2<*1>: Speed 230400: AT — OK
ttyACM2<*1>: Speed 460800: AT — OK
ttyACM2<*1>: Max speed is 460800; that should be safe.
ttyACM2<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 — OK
Found an USB modem on /dev/ttyACM0.
Modem configuration written to /etc/wvdial.conf.
ttyACM0
ttyACM1
ttyACM2
ubuntu@Ubuntu:~$
再修改/etc/wvdial.conf中的相应部分就可以了。我的配置如下:
[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Password = any
Phone = *99***1#
Modem Type = USB Modem
Stupid Mode = 1
Baud = 460800
New PPPD = yes
Modem = /dev/ttyACM0
ISDN = 0
username = any
; Phone =
; Password =
; Username =
之后,就知道该怎么做了吧? sudo wvdial就OK了。
ubuntu@Ubuntu:~$ sudo wvdial
–> WvDial: Internet dialer version 1.60
–> Cannot get information for serial port.
–> Initializing modem.
–> Sending: ATZ
ATZ
OK
–> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
–> Modem initialized.
–> Sending: ATDT*99***1#
–> Waiting for carrier.
ATDT*99***1#
CONNECT 2800000
–> Carrier detected. Starting PPP immediately.
–> Starting pppd at Mon Jun 22 11:11:50 2009
–> Pid of pppd: 4134
–> Using interface ppp0
–> local IP address 10.140.162.111
–> remote IP address 192.200.1.21
–> primary DNS address 221.130.33.60
–> secondary DNS address 221.130.33.52
OK了!