1.使用hostapd+dnsmasq
配置wlan0地址:ifconfig wlan0 192.168.33.1/24
安装软件:apt-get install hostapd,dnsmasq
建立相应配置文件
cat /etc/damask.conf
interface=wlan0
bind-interfaces
server=114.114.114.114
server=8.8.8.8
domain-needed
bogus-priv
dhcp-range=192.168.33.51,192.168.33.70
cat /etc/hostapd/hostapd.conf
interface=wlan0
driver=nl80211
ssid=testap
hw_mode=g
channel=6
ignore_broadcast_ssid=0
wmm_enabled=1
auth_algs=1
wpa=2
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP TKIP
启动服务
service hostapd start(hostapd -B /etc/hostapd/hostapd.conf)
service dnsmasq start
停止时顺序相反
开启nat转换(可能会先echo 1>/proc/sys/net/ipv4/ip_forward)
iptables -t nat -A POSTROUTING -o eth0 -j MAQUERADE
注:对于systemd开启转发要在如下这里设置
cat /etc/systemd/network/80-dhcp.network
[Match]
[Network]
IPForward=1