在Linux主机上将有线和无线网卡连接起来
数据从有线网卡进来后能从无线出去到另一台主机无线网卡后从有线网卡出去
由于项目需要需要实现数据从有线网卡进来,然后能够从无线网卡出去。
大致情况:
两台主机(或者开发板上的ARM)均有有线和无线网卡。
方法一
使得两张无线网卡在同一个网段,修改Linux上的路由表和网关,使得同一台Linux上的有线和无线能通,将主机A和B均设置为对方的网关(这一步很重要,若只修改路由表无法传输数据)。
- 输入命令
#!/bin
auto-generated by IPForward service (utility.py)
sysctl -w net.ipv4.conf.all.forwarding=1
sysctl -w net.ipv4.conf.default.forwarding=1
sysctl -w net.ipv6.conf.all.forwarding=1
sysctl -w net.ipv6.conf.default.forwarding=1
sysctl -w net.ipv4.conf.all.send_redirects=0
sysctl -w net.ipv4.conf.default.send_redirects=0
sysctl -w net.ipv4.conf.all.rp_filter=0
sysctl -w net.ipv4.conf.default.rp_filter=0
sysctl -w net.ipv4.conf.eth0.forwarding=1
sysctl -w net.ipv4.conf.eth0.send_redirects=0
sysctl -w net.ipv4.conf.eth0.rp_filter=0
sysctl -w net.ipv4.conf.wlan0.forwarding=1
sysctl -w net.ipv4.conf.wlan0.send_redirects=0
sysctl -w net.ipv4.conf.wlan0.rp_filter=0
ip route add 10.16.97.0/24 via 192.168.43.43 dev wlan0
在最后一条修改路由表项命令的时候需要自己根据情况修改
修改网关命令
方法二
创建虚拟网卡,这样的话好像只能在一侧能设置虚拟网卡连接有线和无线。(有线和无线之间好像是隔开的,有待验证)