鸣涧 发表于 2022-3-14 17:36:12

OpenWRT EC20 4G网卡自动拔号配置方法 

OpenWRT 4G网卡自动拔号配置方法 

查看是否驱动成功(驱动移植是收费服务有需求可以联系)
ls /dev



添加端口wwan0
vim /etc/config/network

config interface 'loopback'
      option ifname 'lo'
      option proto 'static'
      option ipaddr '127.0.0.1'
      option netmask '255.0.0.0'

config globals 'globals'
      option ula_prefix 'fd59:a22b:2bea::/48'

config interface 'lan'
      option type 'bridge'
      option _orig_ifname 'eth0.1 ra0'
      option _orig_bridge 'true'
      option proto 'dhcp'
      option ifname 'eth0.1 ra0'
      option hostname 'gateway'

config switch
      option name 'switch0'
      option reset '1'
      option enable_vlan '1'

config switch_vlan
      option device 'switch0'
      option vlan '1'
      option ports '0 1 2 3 6t'

config switch_vlan
      option device 'switch0'
      option vlan '2'
      option ports '4 6t'

config interface 'wwan'
      option proto 'dhcp'
      option ifname 'wwan0'

重启网关

reboot
4G网卡

拨号命令
uqmi -d /dev/cdc-wdm0 --start-network internet --autoconnect
拨号查询命令
uqmi -d /dev/cdc-wdm0 --get-data-status

root@TJ:/# uqmi -d /dev/cdc-wdm0 --get-data-status
"connected"拔号成功

查看网络连接情况
fconfig
.....
wwan0   Link encap:EthernetHWaddr C2:28:EB:4D:61:C8
          inet addr:10.7.104.115Bcast:10.7.104.119Mask:255.255.255.248
          inet6 addr: fe80::c028:ebff:fe4d:61c8/64 Scope:Link
          UP BROADCAST RUNNING NOARP MULTICASTMTU:1500Metric:1
          RX packets:68 errors:0 dropped:0 overruns:0 frame:0
          TX packets:482 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:10735 (10.4 KiB)TX bytes:125275 (122.3 KiB)


开机自动 4G 拨号上网

vim /etc/rc.local
exit0 前添加
sleep 5
uqmi -d /dev/cdc-wdm0 --start-network internet --autoconnect &
整个内容:
# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.
/root/watch&
sleep 5
uqmi -d /dev/cdc-wdm0 --start-network internet --autoconnect &
exit 0 重启网关

reboot
再次查看网络连接情况
fconfig
.....
wwan0   Link encap:EthernetHWaddr C2:28:EB:4D:61:C8
          inet addr:10.7.104.115Bcast:10.7.104.119Mask:255.255.255.248
          inet6 addr: fe80::c028:ebff:fe4d:61c8/64 Scope:Link
          UP BROADCAST RUNNING NOARP MULTICASTMTU:1500Metric:1
          RX packets:68 errors:0 dropped:0 overruns:0 frame:0
          TX packets:482 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:10735 (10.4 KiB)TX bytes:125275 (122.3 KiB)
设置一切OK
页: [1]
查看完整版本: OpenWRT EC20 4G网卡自动拔号配置方法