RK3288-7.1下实现4G路由功能,即:4G网络通过RJ45共享给其他设备,比如PC

RK3288-7.1下实现4G路由功能,即:4G网络通过RJ45共享给其他设备,比如PC

需求:产品有WIFI,4G,以太网接口,工作在室外,想把4G信号共享到RJ45输出,RJ45连接到交换机,
交换机再连接其他设备,组成局域网功能。

思路:先实现4G和以太网共存,再把4G信号通过iptables实现路由转发,先再adb下用命令实现,然后在 java层封装接口

1.先打上RK双以太网共存补丁《Android 支持双以太网卡补丁20180108》,

2.基本信息获取,
A:ifconfig

AT5:/ # ifconfig
ifconfig
ppp0 Link encap:Point-to-Point Protocol
inet addr:10.171.2.114 P-t-P:10.64.64.64 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:170 errors:0 dropped:0 overruns:0 frame:0
TX packets:748 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:45978 TX bytes:88922

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope: Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:0 TX bytes:0

AT5:/ #

从中可得,4G获取到的IP是:10.171.2.114

B:获取4G DNS
AT5:/ # getprop | grep -rn dns
getprop | grep -rn dns
(standard input):74:[net.change]: [net.dns2]
(standard input):75:[net.dns1]: [120.196.165.7]
(standard input):76:[net.dns2]: [221.179.38.7]
(standard input):78:[net.ppp0.dns1]: [120.196.165.7]
(standard input):79:[net.ppp0.dns2]: [221.179.38.7]
AT5:/ #
可知4G获取到的DNS是120.196.165.7

3.adb指令实现

#!/system/bin/sh

ip rule add from all lookup main pref 9999(更改优先级为最高)

ifconfig eth0 down

ifconfig eth0 up

busybox ifconfig eth0 192.168.43.1 (设置eth0)

ndc netd 5003 tether start 192.168.43.2 192.168.43.254(设置路由地址范围)

ndc netd 7 nat enable eth0 ppp0 2 10.6.194.114/24(设置转发地址,24位mask地址)

echo 1 >/proc/sys/net/ipv4/ip_forward(使能转发)

iptables -t nat -I PREROUTING -i eth0 -p udp --dport 53 -j DNAT --to-destination 120.196.165.7(ppp0 DNS)

4.Android层封装参考https://blog.csdn.net/zhoumushui/article/details/102892554

有技术问题:欢迎咨询QQ: 1617890720(如果你把我当成免费的答案提取机,就免加了)

  • 4
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

九月天-深圳专业软硬件开发

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

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

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

打赏作者

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

抵扣说明:

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

余额充值