查看文章
 
openSUSE Linux 下利用中国移动3G上网卡上网
2009-07-12 18:57

最近入手了中国移动的G3无线宽带,G3引领3G生活嘛,自然也有咱Linuxer的份。
确定关键字之后便去Google了一番,马上便有了结果,嘿嘿。
需要安装usb_modeswitch(附加libusb) wvdial。这些软件一般都是系统自带的,手动安装在此不赘述,如: zypper in wvdial 即可,Google上查去。

请先检查您的系统里面是否已经安装有所需软件
#zypper install wvdial
在安装好usb_modeswitch 之后编辑usb_modeswitch.conf,
其中DefaultVendor 和DefaultProduct等值是根据您的3G设备而具体设定的

比如我的设备如下:
openSuSE:/etc/udev/rules.d # lsusb | grep Huawei
Bus 005 Device 005: ID 12d1:1da1 Huawei Technologies Co., Ltd.

那么我就将/etc/usb_modeswitch.conf配置文件修改成如下

openSuSE:~ #cat   /etc/usb_modeswitch.conf
#----------------------------------
# HUawei ET128 TD-SCDMA/GSM
# Editor: l1nuxer
# Date: 2009-07-10

DefaultVendor=0x12d1
DefaultProduct=0x1da1

TargetVendor=0x12d1
TargetProduct=0x1da1

HuaweiMode=1

然后添加udev rule,这样就不需要每次插入3G设备的时候手动运行usb_modeswitch了。

openSuSE:~ #cd /etc/udev/rules.d/
openSuSE:/etc/udev/rules.d # ls
40-alsa.rules              42-bluetooth-serial.rules 52-irda.rules                     65-wacom.rules          77-network.rules
40-bluetooth.rules         42-gsm-drivers.rules      52-usx2yaudio.rules               70-kpartx.rules         79-yast2-drivers.rules
40-lomoco.rules            51-gpsd.rules             55-libsane.rules                  70-persistent-cd.rules 81-mount.rules
41-bluetooth-hid2hci.rules 51-hso-udev.rules         56-sane-backends-autoconfig.rules 70-persistent-net.rules 81-mptctl.rules
41-soundfont.rules         51-lirc.rules             60-pcmcia.rules                   71-multipath.rules      99-iwlwifi-led.rules

在此我直接编辑42-gsm-drivers.rules 文件,您也可以自己添加任意的以.rules作为扩展名的文件,比如42-my3gmodem-drivers.rules,按照约定一般都不使用50开头的文件。

openSuSE:/etc/udev/rules.d # cat 42-gsm-drivers.rules
......

#SYSFS{idVendor}=="<YourDefaultVendorID>", SYSFS{idProduct}=="<YourDefaultProductID>", RUN+="/usr/sbin/usb_modeswitch"
SYSFS{idVendor}=="12d1", SYSFS{idProduct}=="1da1", RUN+="/usr/sbin/usb_modeswitch -c /etc/usb_modeswitch.conf"

......

可以看到输出有变化,证明我们转换成功了。
openSuSE:/etc/udev/rules.d # lsusb | grep Huawei
Bus 005 Device 005: ID 12d1:1d09 Huawei Technologies Co., Ltd.

然后运行wvdialconf 来配置modem和初始化wvdial.conf

openSuSE:/etc/udev/rules.d # wvdialconf
Editing `/etc/wvdial.conf'.

Scanning your serial ports for a modem.

Modem Port Scan<*1>: S0   S1   S2   S3   S4   S5   S6   S7  
WvModem<*1>: Cannot get information for serial port.
ttyACM0<*1>: ATQ0 V1 E1 -- OK
ttyACM0<*1>: ATQ0 V1 E1 Z -- +CME ERROR: 10
ttyACM0<*1>: ATQ0 V1 E1 S0=0 -- OK
ttyACM0<*1>: ATQ0 V1 E1 S0=0 &C1 -- OK

......

Found an USB modem on /dev/ttyACM0.
Modem configuration written to /etc/wvdial.conf.
ttyACM0<Info>: Speed 460800; init "ATQ0 V1 E1 S0=0 &C1 &D2"
ttyACM1<Info>: Speed 460800; init "ATQ0 V1 E1 S0=0 &C1 &D2"
ttyACM2<Info>: Speed 460800; init "ATQ0 V1 E1 S0=0 &C1 &D2"

最后配置 wvdial 拨号

修改 /etc/wvdial.conf

注意,拨号号码是 *99***1# 为 3G的, GPRS/EDGE 的直接用 *99# 即可.

注意,以上过程是详细的配置过程,方便您手动配置,

如果您很懒,可以直接将一下内容保存为脚本 g3.sh ,并以管理员身份运行即可.

#!/bin/sh
# Author: vsu@opensuse.org
# Date: 2009-08-13
# Copyright (C) 2009 Free Software Foundation.Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# Usage:Help to configure the plugin usbmodem
#

version="PnP USB Modem configure tool.
version 2009.08
Author: vsu (vsu@opensuse.org)
Copyright (C) 2009 Free Software Foundation.Inc.
This is free software. You may redistribute copies of it under the terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.

Written by vsu."
usage="Usage:
This small tool just try to help you configure your \"plugin and play\" usb modem.
You should have usb_modeswitch installed to run your device, this is only the configure.

just run $0 or append the [OPTION] to see more.
OPTIONS:
--version: display version
--help: display this help."

ROOT_UID=0
UDEVCONF="/etc/udev/rules.d/43-usb_modem-drivers.rules"
USCONF="/etc/usb_modeswitch.conf.2"

if [ "$UID" != "$ROOT_UID" ]
then
echo "Only root can run this script."
exit 1
fi

for arg
do
case $arg in
--version) echo "$version";exit 0;;
--help) echo "$usage";exit 0;;
-*) shift;;
*) echo "$usage";exit 1;;
esac
done

clear
echo "Plugin your device and let's begin."
echo "Now check your lsusb output:"
lsusb | nl
echo " Which line shows your device ?"
read LINE
while [ -z $LINE ]
do
echo "You have to tell me which line, or please press Ctrl+C to exit"
read LINE
done


echo "Now write to configure file: $UDEVCONF "
echo -e "ACTION!=\"add\", GOTO=\"usbmodem_rules_end\"\n\nLABEL=\"usbmodem_rules_begin\"\
# Option Globetrotter & other switch-mode mobile broadband modems\n\
SYSFS{idVendor}==\"$VENDOR\", SYSFS{idProduct}==\"$PRODUCT\", RUN+=\"/usr/sbin/usb_modeswitch -c $USCONF\"\n\
LABEL=\"usbmodem_rules_end\"" > $UDEVCONF

echo -e "# Created by $0
# Date $(date)

DefaultVendor=0x"$VENDOR"
DefaultProduct=0x"$PRODUCT"

TargetVendor=0x"$VENDOR"
TargetProduct=0x"$PRODUCT"

HuaweiMode=1\n" > $USCONF

echo "Configure finished. you should check if it can work, or please modify the $USCONF please.
NOTE: This configure tool is for Huawei mode.
if you got another product. please modify the line \"HuaweiMode\" in $USCONF"

将上面脚本内容保存为 foo.sh , chmod 755 foo.sh 之后直接以 root 身份运行即可.

wvdial 配置和前文相同.


类别:Linux||添加到搜藏 |分享到i贴吧|浏览(2561)|评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
     

   
帮助中心 | 空间客服 | 投诉中心 | 空间协议
©2012 Baidu