概述
一、3G拨号
ipv4拨号详细请参考官方指导文档https://openwrt.org/docs/guide-user/network/wan/wwan/3gdongle
/etc/config/network文件配置3G拨号
config interface 'modem_1_1'
option ifname '3g-modem'
option service 'umts'
option apn 'ctlte'
option proto '3g'
option device '/dev/ttyUSB3'
option ath 'NONE'
option metric '40'
option disabled '0'
修改/etc/chatscripts/3g.chat
ABORT BUSY
ABORT 'NO CARRIER'
ABORT ERROR
REPORT CONNECT
TIMEOUT 10
"" 'AT+CGDCONT=1,"IPV4V6","$USE_APN"' #IP改成IPV4V6
SAY "Calling UMTS/GPRS"
TIMEOUT 30
OK "ATD$DIALNUMBER"
CONNECT ' '
修改/etc/chatscripts/evdo.chat
# This is a simple chat script based off of the one provided by Sierra Wireless
# for CDMA connections. It should work for both Sprint and Verizon networks.
ABORT BUSY
ABORT 'NO CARRIER'
ABORT ERROR
ABORT 'NO DIAL TONE'
ABORT 'NO ANSWER'
ABORT DELAYED
REPORT CONNECT
TIMEOUT 10
'' AT
OK ATZ
"" 'AT+CGDCONT=1,"IPV4V6"' #添加这一行
SAY 'Calling CDMA/EVDO'
TIMEOUT 30
OK ATDT#777
CONNECT ''
重启网络,拨号成功
root@GL-MT1300:/# ifconfig 3g-modem_1_1
3g-modem_1_1 Link encap:Point-to-Point Protocol
inet addr:10.5.62.187 P-t-P:10.64.64.64 Mask:255.255.255.255
inet6 addr: fe80::253d:3ace:f3d7:f48f/10 Scope:Link
inet6 addr: 240e:47d:227:4d45:253d:3ace:f3d7:f48f/64 Scope:Global
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:173 errors:0 dropped:0 overruns:0 frame:0
TX packets:244 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:18465 (18.0 KiB) TX bytes:25589 (24.9 KiB)
二、qmi拨号
ipv4拨号详细请参考官方指导文档https://openwrt.org/docs/guide-user/network/wan/wwan/ltedongle
/etc/config/network文件配置qmi拨号
config interface 'modem_1_1'
option ifname 'wwan0'
option service 'fdd_lte'
option apn 'ctlte'
option proto 'qmi'
option device '/dev/cdc-wdm0'
option pdptype 'IPV4V6'
option metric '40'
option disabled '0'
修改/lib/netifd/proto/qmi.sh拨号脚本
[ "$pdptype" = "ip" -o "$pdptype" = "ipv6" -o "$pdptype" = "ipv4v6" ] || pdptype="ip"
[ "$pdptype" = "ipv4v6" ] && echo -e "AT+CGDCONT=1,"IPV4V6"r" > /dev/ttyUSB3 #通过at指令设置ipv4v6拨号上下文
if [ "$pdptype" = "ip" ]; then
[ -z "$autoconnect" ] && autoconnect=1
[ "$autoconnect" = 0 ] && autoconnect=""
else
[ "$autoconnect" = 1 ] || autoconnect=""
fi
[ "$pdptype" = "ip" -o "$pdptype" = "ipv4v6" ] && {
cid_4=$(uqmi -s -d "$device" --get-client-id wds)
if ! [ "$cid_4" -eq "$cid_4" ] 2> /dev/null; then
echo "Unable to obtain client ID"
proto_notify_error "$interface" NO_CID
return 1
fi
拨号成功
root@GL-MT1300:/# ifconfig wwan0
wwan0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.5.62.187 P-t-P:10.5.62.187 Mask:255.255.255.248
inet6 addr: 240e:47d:222:24b1:c7c4:c510:4725:926/64 Scope:Global
inet6 addr: fe80::c7c4:c510:4725:926/64 Scope:Link
inet6 addr: 240e:47d:222:24b1:7332:f010:92c8:5c85/64 Scope:Global
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:1188 errors:0 dropped:0 overruns:0 frame:0
TX packets:1679 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:134960 (131.7 KiB) TX bytes:185042 (180.7 KiB)
三、给下级终端分配ipv6
参考openwrt配置ipv6配置ipv6路由环境
修改/etc/config/network文件
config interface 'wan6'
option proto 'dhcpv6'
option disabled '0'
option ifname '@modem_1_1' #wan6绑定modem接口
3g拨号,修改lib/netifd/ppp6-up,使用wan6作为ipv6接口,不使用openwrt默认${PPP_IPPARAM}_6接口
#!/bin/sh
PPP_IFNAME="$1"
LLREMOTE="$5"
PPP_IPPARAM="$6"
. /lib/netifd/netifd-proto.sh
proto_init_update "$IFNAME" 1 1
proto_set_keep 1
[ -n "$LLREMOTE" ] && proto_add_ipv6_route "::0" 0 "$LLREMOTE" "" "" ""
proto_send_update "$PPP_IPPARAM"
exit #设置路由表后退出,不是用官方默认配置的ipv6接口
[ -n "$PPP_IPPARAM" ] && {
[ -n "$LLLOCAL" ] && proto_add_ipv6_address "$LLLOCAL" 128
}
proto_send_update "$PPP_IPPARAM"
[ -d /etc/ppp/ip-up.d ] && {
for SCRIPT in /etc/ppp/ip-up.d/*
do
[ -x "$SCRIPT" ] && "$SCRIPT" "$@"
done
}
exit
if [ -n "$AUTOIPV6" ]; then
ZONE=$(fw3 -q network $PPP_IPPARAM 2>/dev/null)
json_init
json_add_string name "${PPP_IPPARAM}_6"
json_add_string ifname "@$PPP_IPPARAM"
json_add_string proto "dhcpv6"
[ -n "$ZONE" ] && json_add_string zone "$ZONE"
[ -n "$EXTENDPREFIX" ] && json_add_string extendprefix 1
[ -n "$IP6TABLE" ] && json_add_string ip6table $IP6TABLE
[ -n "$PEERDNS" ] && json_add_boolean peerdns $PEERDNS
json_close_object
ubus call network add_dynamic "$(json_dump)"
fi
qmi拨号,修改qmi.sh使用wan6做为ipv6接口,不使用qmi.sh默认的ipv6接口
...
proto_close_data
proto_send_update "$interface"
local zone="$(fw3 -q network "$interface" 2>/dev/null)"
- [ -n "$pdh_6" ] && {
+ [ -n "$pdh_6" -a "aaa" = "bbb" ] && {
if [ -z "$dhcpv6" -o "$dhcpv6" = 0 ]; then
json_load "$(uqmi -s -d $device --set-client-id wds,$cid_6 --get-current-settings)"
json_select ipv6
json_get_var ip_6 ip
json_get_var gateway_6 gateway
json_get_var dns1_6 dns1
json_get_var dns2_6 dns2
json_get_var ip_prefix_length ip-prefix-length
...
重启网络,配置完成,下级终端可以获取ipv6,并成功上网ipv6
建议使用nat6模式,使用Native让下级终端使用原生ipv6,可能还需要配置路由表
最后
以上就是眼睛大缘分为你收集整理的openwrt modem拨号获取ipv6(qmi拨号/3g拨号)的全部内容,希望文章能够帮你解决openwrt modem拨号获取ipv6(qmi拨号/3g拨号)所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复