Firefly开源社区

[Android] 【以太网】以太网共享网络

31

积分

0

威望

0

贡献

技术小白

积分
31
发表于 2019-11-28 18:07:18     
类似USB网络共享。
把板子的4G网络,或者WIFI网络通过以太网口分享出来。
回复

使用道具 举报

31

积分

0

威望

0

贡献

技术小白

积分
31
发表于 2019-11-28 18:12:11     
以下假设A(eth0)分享 B(ppp0)的网络。
第一步,开启接口的dhcp功能
netcfg eth0 up
busybox ifconfig eth0 192.168.0.1 netmask 255.255.255.0
ndc tether interface add eth0
ndc tether start 192.168.0.2 192.168.0.254
第二步,开启nat转发功能
ip rule add from all lookup main pref 9999
ndc nat enable eth0 ppp0 2 xx.xx.xx.xx/32           //eth0以太网共享ppp0 4G网的网络,32是子网掩码
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -I PREROUTING -i eth0  -p udp --dport 53 -j DNAT --to-destination xxx.xxx.xx.xx   //xxx.xxx.xx.xx是ppp0网络的dns地址,这个写错会导致分享出来的网络上不了网。
回复

使用道具 举报

3747

积分

17

威望

18

贡献

官方团队

Rank: 9Rank: 9Rank: 9

积分
3747
发表于 2019-11-29 08:54:11     
laughing哥 发表于 2019-11-28 18:12
以下假设A(eth0)分享 B(ppp0)的网络。
第一步,开启接口的dhcp功能
netcfg eth0 up

回复

使用道具 举报

330

积分

0

威望

0

贡献

技术达人

Rank: 2

积分
330
发表于 2020-1-13 11:51:29     
laughing哥 发表于 2019-11-28 18:12
以下假设A(eth0)分享 B(ppp0)的网络。
第一步,开启接口的dhcp功能
netcfg eth0 up

xx.xx.xx.xx是啥?
回复

使用道具 举报

31

积分

0

威望

0

贡献

技术小白

积分
31
发表于 2020-3-2 15:41:58     

连上4G网络后 ,getprop | grep dns 看下,里面有个ppp0的属性
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

友情链接 : 爱板网 电子发烧友论坛 云汉电子社区 粤ICP备14022046号-2
快速回复 返回顶部 返回列表