4.配置hostapd和dhcpd
a) 配置hostapd
vim /etc/hostapd.conf
interface=wlan0
driver=nl80211
ssid=MYZR
channel=9
hw_mode=g
macaddr_acl=0
ignore_broadcast_ssid=0
auth_algs=1
wpa=3
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
b)配置dhcpd
touch /var/db/dhcpd.leases
vim /etc/dhcpd.conf
在最后增加:
subnet 192.168.155.0 netmask 255.255.255.0
{
range 192.168.155.2 192.168.155.10;
option domain-name-servers 8.8.8.8;
option routers 192.168.155.1;
}
5.启动热点和自动获取IP
echo "1" >/proc/sys/net/ipv4/ip_forward
hostapd -B /etc/hostapd.conf
ifconfig wlan0 192.168.155.1
dhcpd wlan0
看图片“WIFIAP.png” Finally, you can search for the “MYZR” hotspot through your mobile phone and directly enter the password“12345678”. In this way, the mobile phoneWIF will be connected successfully and will automatically distinguish192.168.155.*IP. Note: Although the above IP is assigned, it cannot access the Internet. You need to use iptables to enable local SNAT After the previous steps, the wireless network card can automatically allocate an IP. Now you just need to send the data of the wireless network card to the external network through eth0 (wired network) , which requires IP forwarding. 6.Configure the kernel
· Networking support ---> Networking options --->
· Network packet filtering framework (Netfilter) ---> Core Netfilter Configuration ---> //Select all except those listed below < > 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 ---> //Select all except those listed below [ ] IP virtual server debugging [ ] SCTP load balancing support < > FTP protocol helper < > SIP persistence engine IP: Netfilter Configuration ---> //Select all in <*> RF switch subsystem support ---> //Note that you must select the last item, otherwise you will get an error when using the hostapdcommand, “rfkill: Cannot open RFKILL control device”. 7.TransplantiptablesJust use buildroot to configure and compile, or compile independently, which I will not explain here udhcpc -i eth0 iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE Connecting to wifi in this way, the settings of the mobile phone and ubuntu'sWPA2-PSK's wirelesswifi AP are complete and can be used normally.
Transplantiptables Just use buildroot to configure and compile. Or compile it independently, I won’t talk about it hereudhcpc -i eth0 iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE Connect like thiswifi , mobile phone and ubuntu’sWPA2-PSK Wirelesswifi AP is set up and can be used normally.