注意:以上雖然分配到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設置完畢,可以正常使用了。