使用 HSDPA 调制解调器

来自 Alpine Linux


要求

此文档在 Alpine-2.1.3 上测试过。

你将需要一个 HSDPA USB 调制解调器。
使用 'dmesg | less' 来找出它使用的 /dev/ttyUSB? (你需要编辑下面显示的配置以反映正确的端口号)

安装软件包

安装所需的软件包

apk add ppp

加载模块

现在让我们加载驱动程序(使用你刚发现的值),并配置 Alpine 以在启动时自动加载它。

modprobe ppp_generic echo "ppp_generic" >> /etc/modules-load.d/ppp.conf

配置文件

/etc/ppp/peers/E220

(文件名 'E220' 可以更改,但你需要在运行 pon/poff 命令时记住它)

debug
/dev/ttyUSB0
460800
crtscts
modem
noauth
usepeerdns
defaultroute
noipdefault
noccp
nobsdcomp
novj
connect '/usr/sbin/chat -v -f /etc/ppp/chat-E220-pin || /usr/sbin/chat -f /etc/ppp/chat-E220-nopin'

/etc/ppp/chat-E220-pin

(文件名 'chat-E220-pin' 可以更改,但你需要修改上面显示的配置文件以反映你的决定)

ABORT "BUSY"
ABORT "ERROR"
ABORT "NO CARRIER"
REPORT "CONNECT"
TIMEOUT "10"
"" "ATZ"
OK "AT+CPIN={PIN}"
OK AT+CGDCONT=1,"ip","{APN}"
OK "ATE1V1&D2&C1S0=0+IFC=2,2"
OK "AT+IPR=115200"
OK "ATE1"
TIMEOUT "60"
"" "ATD*99***1#"
CONNECT \c

/etc/ppp/chat-E220-nopin

(文件名 'chat-E220-nopin' 可以更改,但你需要修改上面显示的配置文件以反映你的决定)

ABORT "BUSY"
ABORT "ERROR"
ABORT "NO CARRIER"
REPORT "CONNECT"
TIMEOUT "10"
"" "ATZ"
OK AT+CGDCONT=1,"ip","{APN}"
OK "ATE1V1&D2&C1S0=0+IFC=2,2"
OK "AT+IPR=115200"
OK "ATE1"
TIMEOUT "60"
"" "ATD*99***1#"
CONNECT \c
注意: {PIN} 替换为你的 SIM 卡的 "PIN" 码(通常是一个 4 位数字代码)
注意: {APN} 替换为你的服务使用的 "接入点名称" (例如 "web.omnitel.it")。如果你不知道 Internet APN,请咨询你的服务提供商

路由

创建一个到你的 'ppp0' 设备的默认网关路由。

ip route add default dev ppp0

DNS

找出你的提供商的 DNS 服务器。

egrep -i 'pppd.*dns' /var/log/messages

这可能会给你一些有用的信息。
搜索一个可能是你的提供商的 DNS 服务器的 IP 地址,并将此 IP 地址添加到 '/etc/resolv.conf' 中。

echo "nameserver {DNS-server-IP-address}" > /etc/resolv.conf

启动/停止

启动连接

pon E220

停止连接

poff E220

如果出现问题...

检查进程是否正在运行

pidof pppd

日志文件可能会给你关于哪里出错的线索

egrep "pppd|chat" /var/log/messages

检查网卡信息

ifconfig ppp0

pppd 有一个状态信息功能,可能会派上用场

pppstats

Huawei E378

在 Alpine 2.3.3 上测试过。

添加 usb-modeswitch(目前仅在 testing 仓库中)

apk add usb-modeswitch

/etc/modules

usbserial vendor=0x12d1 product=0x1446

/etc/usb_modeswitch.conf

# Configuration for the usb_modeswitch package, a mode switching tool for
# USB devices providing multiple states or modes
#
# This file is evaluated by the wrapper script "usb_modeswitch_dispatcher"
# in /usr/sbin
# To enable an option, set it to "1", "yes" or "true" (case doesn't matter)
# Everything else counts as "disable"

# Disable automatic mode switching globally (e.g. to access the original
# install storage)
DisableSwitching=0

# Enable logging (results in a extensive report file in /var/log, named
# "usb_modeswitch_<interface-name>" (and probably others)
EnableLogging=1

DefaultVendor=0x12d1
DefaultProduct=0x1446

TargetVendor=0x12d1
TargetProduct=0x14ac

MessageContent="55534243000000000000000000000011060000000000000000000000000000"

CheckSuccess=5

/etc/network/interfaces

auto ppp0
iface ppp0 inet ppp
        provider E378
        pre-up usb_modeswitch -c /etc/usb_modeswitch.conf

/etc/ppp/peers/E378

debug
/dev/ttyUSB0
460800
crtscts
modem
noauth
usepeerdns
defaultroute
noipdefault
noccp
nobsdcomp
novj
connect '/usr/sbin/chat -v -f /etc/ppp/peers/chat-E378-nopin'

/etc/ppp/peers/chat-E378-nopin

ABORT "BUSY"
ABORT "ERROR"
ABORT "NO CARRIER"
REPORT "CONNECT"
TIMEOUT "10"
"" "ATZ"
OK AT+CGDCONT=1,"ip","isp.telus.com"
OK AT+CGQREQ=1,2,4,3,6,31
OK AT+CGQMIN=1,2,4,3,6,31
OK AT+CGATT=1
OK ATD*99#
CONNECT \c


Novatel MC679

在 Alpine 2.4.5 上测试过。

添加 usb-modeswitch(目前仅在 testing 仓库中)

apk add usb-modeswitch

/etc/modules

usbserial vendor=0x1410 product=0x7042

/etc/usb_modeswitch.conf

# Configuration for the usb_modeswitch package, a mode switching tool for
# USB devices providing multiple states or modes
#
# This file is evaluated by the wrapper script "usb_modeswitch_dispatcher"
# in /usr/sbin
# To enable an option, set it to "1", "yes" or "true" (case doesn't matter)
# Everything else counts as "disable"

# Disable automatic mode switching globally (e.g. to access the original
# install storage)
DisableSwitching=0

# Enable logging (results in a extensive report file in /var/log, named
# "usb_modeswitch_<interface-name>" (and probably others)
EnableLogging=1

DefaultVendor= 0x1410
DefaultProduct=0x5059

TargetVendor=  0x1410
TargetProduct= 0x7042

MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
NeedResponse=1

/etc/network/interfaces

auto ppp0
iface ppp0 inet ppp
        provider MC679
        pre-up usb_modeswitch -c /etc/usb_modeswitch.conf || true

/etc/ppp/peers/MC679

debug
/dev/ttyUSB0
460800
crtscts
modem
noauth
usepeerdns
defaultroute
noipdefault
noccp
nobsdcomp
novj
connect '/usr/sbin/chat -v -f /etc/ppp/peers/chat-MC679-nopin'

/etc/ppp/peers/chat-MC679-nopin

ABORT "BUSY"
ABORT "ERROR"
ABORT "NO CARRIER"
REPORT "CONNECT"
TIMEOUT "10"
"" "ATZ"
OK ATD*99#
CONNECT \c