用iptables通过IP forward实现。
首先是在内核中打开支持iptables的选项,可以把
Core Netfilter Configuration --->
IP: Netfilter Configuration --->
[*] Advanced netfilter configuration
都选上。
把新编译好的内核下载到板上,运行hostapd会出现kernel panic。改了内核选项后,要重新编译网卡驱动,这个问题可到解决。
然后是移植iptables,首先是配置iptables的编译环境,进入到iptables的目录/configure --prefix=/mnt/mmc/setAP/iptables--host=arm-linux
--prefix是以后iptables的安装文件存放的目录(包括可执行程序、库文件和包含文件等)--host是iptables的编译环境。由于板上很多目录都是只读的,不能添加文件,像把一些iptables的库文件放到lib/目录下是不行的。所以编译好之后,运行make install。这样在服务器的mnt/mmc/setAP/iptables的目录下会有系一列我们需要移植到板上的文件,把服务器iptables目录下的所有文件移植到板子mnt/mmc/setAP/iptables目录下(setAP和iptables目录是自己建的)。这样可以避免一些列的运行iptables找不到库文件的问题。到/mnt/mmc/setAP/iptables/sbin/目录下
./iptables –L 可以查看iptables是否正确安装
./iptables –t nat –L 可以查看iptables的nat功能是否正确安装
AP设好后,开启有线网卡,并给有线网卡设置网关
route add default gw 192.168.0.1 eth0 这样有线网卡可以访问局域网
</