注意:以上雖然分配到IP,但是不能上網(wǎng),需要使用iptables開啟本地的SNAT
經(jīng)過前面幾個(gè)步驟,無線網(wǎng)卡已經(jīng)可以自動(dòng)分配IP,現(xiàn)在只需要把無線網(wǎng)卡的數(shù)據(jù)都經(jīng)過eth0(有線網(wǎng)絡(luò))發(fā)到外網(wǎng)去,這就需要IP轉(zhuǎn)發(fā)了。
6.配置內(nèi)核
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 --->
//注意要選最后一項(xiàng),不然在使用hostapd命令時(shí)會(huì)出錯(cuò),“rfkill: Cannot open RFKILL control device”.
7.移植iptables直接用buildroot配置編譯就行,或者獨(dú)立編譯,這里不講了udhcpc -i eth0
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
這樣連接wifi,手機(jī)和ubuntu的WPA2-PSK的無線wifi AP設(shè)置完畢,可以正常使用了。