快速业务通道

在Linux上实现3G拔号上网

作者 佚名技术 来源 Linux系统 浏览 发布时间 2012-04-16


我的3G上网卡是华为 E1750,操作系统是openSUSE 11.2,之前只能在虚拟机运行的Windows里上3G,感觉这样实在不方便,于是想到了直接在Linux里连接3G网络.

主要参考了2篇文档,尤其向第一篇作者yel617致谢,分别是:

<<华为E1750在DM6446上的移植>>
<<USB_ModeSwitch - Activating Switchable USB Devices on Linux>>



闲话少说,直接写方法.



1. software
================

http://www.draisberghof.de/usb_modeswitch/

usb-modeswitch
usb-modeswitch-data
libusb




2. install
==============

安装软件

root# tar jxvf usb-modeswitch-1.1.3.tar.bz2
root# cd usb-modeswitch-1.1.3/
root# make install

root# tar jxvf usb-modeswitch-data-20100707.tar.bz2
root# cd usb-modeswitch-data-20100707/
root# make install

then upgrade libusb to the lastest version.

root# cp /usr/share/doc/packages/ppp/scripts/pon /usr/local/sbin
root# cp /usr/share/doc/packages/ppp/scripts/poff /usr/local/sbin
root# chmod ug x /usr/local/sbin/pon /usr/local/sbin/poff


接下来,接上3G上网卡,可以看到 lsusb 输出的结果多了"USB Modem"字样.

root# lsusb
...
Bus 002 Device 010: ID 12d1:1001 Huawei Technologies Co., Ltd. E620 USB Modem
...




3. configure
================

建立3个PPP配置文件.

root# cat /etc/ppp/peers/wcdma
nodetach
lock
/dev/gsmmodem
115200
user "card"
password "card"
crtscts
show-password
usepeerdns
noauth
noipdefault
novj
novjccomp
noccp
defaultroute
ipcp-accept-local
ipcp-accept-remote
connect ''/usr/sbin/chat -s -v -f /etc/ppp/peers/wcdma-chat-connect''
disconnect ''/usr/sbin/chat -s -v -f /etc/ppp/peers/wcdma-chat-disconnect''


root# cat /etc/ppp/peers/wcdma-chat-connect
ABORT ''NO CARRIER''
ABORT ''ERROR''
ABORT ''NO DIALTONE''
ABORT ''BUSY''
ABORT ''NO ANSWER''
'''' \rAT
OK \rATZ
OK \rAT CGDCONT=1,"IP","3gnet",,0,0
OK-AT-OK ATDT*99#
CONNECT \d\c


root# cat /etc/ppp/peers/wcdma-chat-disconnect
ABORT "ERROR"
ABORT "NO DIALTONE"
SAY "\nSending break to the modem\n"
'''' "\K"
'''' " ATH"
SAY "\nGoodbay\n"




4. connect
==============

拔号连接

root# pppd call wcdma &
......
Serial connection established.
Using interface ppp0
Connect: ppp0 <--> /dev/gsmmodem
CHAP authentication succeeded
CHAP authentication succeeded
Could not determine remote IP address: defaulting to 10.64.64.64
not replacing default route to eth0 [10.217.15.1]
local IP address 172.27.25.133
remote IP address 10.64.64.64
primary DNS address 202.106.195.68
secondary DNS address 202.106.46.151
Script /etc/ppp/ip-up finished (pid 10543), status = 0x0


手工添加DNS

root# echo "nameserver 202.106.46.151" >> /etc/resolv.conf


手工指定默认网关

root# route add default gw 172.27.25.133


测试网络是否可用

root# ping -c 5 www.sina.com.cn
PING libra.sina.com.cn (202.108.33.80) 56(84) bytes of data.
64 bytes from 202.108.33.80: icmp_seq=1 ttl=56 time=39.6 ms
64 bytes from 202.108.33.80: icmp_seq=2 ttl=56 time=48.3 ms
64 bytes from 202.108.33.80: icmp_seq=3 ttl=56 time=46.8 ms
64 bytes from 202.108.33.80: icmp_seq=4 ttl=56 time=44.6 ms
64 bytes from 202.108.33.80: icmp_seq=5 ttl=56 time=44.1 ms

--- libra.sina.com.cn ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4006ms
rtt min/avg/max/mdev = 39.670/44.739/48.330/2.957 ms




5. disconnect
==================

root# poff





凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号