注意:以上虽然分配到IP,但是不能上网,需要使用iptables开启本地的SNAT
经过前面几个步骤,无线网卡已经可以自动分配IP,现在只需要把无线网卡的数据都经过eth0(有线网络)发到外网去,这就需要IP转发了。
6.配置内核
Networking support --->
Networking options --->Network packet filtering framework (Netfilter) --->
Core Netfilter Configuration ---> //除了下面列出的其他全选
< > Transparent proxying support (EXPERIMENTAL)
< > set target and match support
< > CHECKSUM target support
< > "CT" target support
< > "DSCP" and "TOS" target support
< > "NOTRACK" target support
< > "TCPOPTSTRIP" target support (EXPERIMENTAL)
< > "dscp" and "tos" match support
< > "ipvs" match support
<*> IP set support --->
(256) Maximum number of IP sets
<*> bitmap:ip set support
<*> bitmap:ip,mac set support
<*> bitmap:port set support
<*> list:set set support
<*> IP virtual server support ---> //除了下面列出的其他全选
[ ] IP virtual server debugging
[ ] SCTP load balancing support
< > FTP protocol helper
< > SIP persistence engine
IP: Netfilter Configuration ---> //里面的全选
<*> RF switch subsystem support --->
//注意要选最后一项,不然在使用hostapd命令时会出错,“rfkill: Cannot open RFKILL control device”.
7.移植iptables直接用buildroot配置编译就行,或者独立编译,這里不讲了udhcpc -i eth0
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
这样连接wifi,手机和ubuntu的WPA2-PSK的无线wifi AP设置完毕,可以正常使用了。