OpenWrt 4G网卡拨号配置

本文详细介绍了如何在OpenWrt系统中配置4G网卡进行拨号上网。首先讲解了4G网卡的基础知识,包括接口类型和USB协议。接着,阐述了配置USB驱动的方法,通过`lsusb`检测设备,并在内核配置中启用相关USB串口和PPP支持。最后,提到了使用PPP工具`comgt`以及添加`ppp0`网络节点的步骤,参考了相关链接以供深入学习。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

基础知识

MiniPCI-e, 接口其实就是USB接口, 采用的USB协议.

USB协议中有product id, vendor id.

4G网卡的拨号方式有三种:
PPP (PPP over EV-DO, CDMA, UMTS or GPRS)
QMI (USB modems using QMI protocol)
NCM (USB modems using NCM protocol)

配置USB驱动

检测方法是lsusb, 可以看到这个.
将USB的驱动中加入驱动中.

drivers/usb/serial/option.c 

static const struct usb_device_id option_ids[] = {
{ USB_DEVICE(0x161c, 0x9115) },

串口相关配置:

1、USB 串口驱动相关的配置项:
CONFIG_USB_SERIAL=y
CONFIG_USB_SERIAL_OPTION=y
CONFIG_USB_SERIAL_WWAN=y

make kernel_menuconfig

Device Drivers —>
USB support —>
USB Serial Converter support —> (默认是M,且不能设为*)

习惯上=y 使得编译进内核而不是作为模块,那么得配置好一些USB相关
<> Support for Host-side USB (默认M,选择 方便USB Serial可以=y)
<*> USB announce new devices
[*] Enable USB persist by default
<*> EHCI HCD(USB 2.0) support
[*] Root Hub Transaction Translators
[*] Improved Transaction Translator scheduling
<*> OHCI HCD support
<*> USB Modem (CDC ACM) support
<*> USB Printer support
<*> USB Wireless Device Management support

USB Serial Converter support —>
<*> USB driver for GSM and CDMA modems

退出后保存,git status查看会修改target/linux/ramips/mt7620n/config-3.10 这里便是内核的默认编译配置文件

2、PPP 拨号的相关配置项:
CONFIG_PPP=y
CONFIG_PPP_MULTILINK=y
CONFIG_PPP_FILTER=y
CONFIG_PPP_ASYNC=y
CONFIG_PPP_SYNC_TTY=y
CONFIG_PPP_DEFLATE=y
CONFIG_PPP_BSDCOMP=y

make kernel_menuconfig

Device Drivers —>
[*] Network device support —>
<*> PPP (point-to-point protocol) support
<*> PPP BSD-Compress compression
<*> PPP Deflate compression
[*] PPP filtering
[*] PPP multilink support
<*> PPP MPPE compression (encryption)
[*] PPP multilink support
<*> PPP over Ethernet
<*> PPP support for async serial ports
<*> PPP support for sync tty ports

  1. 配置工具PPP需要
    Utilities —>
    <*> comgt

四、添加ppp0网络节点

target/linux/ramips/base-files/etc/uci-defaults/02_network

+       m201)
+               ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
+               ucidef_set_interfaces_3g "ppp0"
+               ;;
+
        ur-336un)

package/base-files/files/lib/functions/uci-defaults.sh

+ucidef_set_interface_ppp0() {
+       local ifname=$1
+       
+       uci batch <<EOF
+set network.ppp0='interface'
+set network.ppp0.ifname='$ifname'
+set network.ppp0.proto='3g'
+set network.ppp0.apn='3gnet'
+set network.ppp0.service='umts'
+set network.ppp0.dialnumber='*99#'
+set network.ppp0.device='/dev/ttyUSB0'
+EOF
+}

+ucidef_set_interfaces_3g() {
+       local ppp0_ifname=$1
+       
+       ucidef_set_interface_ppp0 "$ppp0_ifname"
+}
+

package/network/config/firewall/files/firewall.config

config zone
+       option network          'wan ppp0'

调试的时候可以手动设置(我这里是华为MU709s-2 WCDMA 联通3G):
进入etc/config/修改network,增加一个3G 网络节点

config interface 'ppp0'
        option ifname 'ppp0'
        option proto '3g'
        option apn '3gnet'
        option service 'umts'
        option dialnumber '*99#'
        option device '/dev/ttyUSB0'

注:联通apn:3gnet 电信apn:ctnet 移动apn:cmnet/cmwap
联通dialnumber:3G为*99# 电信:3G为#777 移动为:*99***1# LTE为:*99#

参考链接
[1] http://blog.youkuaiyun.com/yicao821/article/details/45370669
[2] https://wiki.openwrt.org/doc/uci/network

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

钱国正

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值