標籤彙整: linux

Kali Linux下设立Wifi AP

在Kali Linux下设立Wifi AP的如下:

1. 安装所需package

apt-get install -y hostapd dnsmasq wireless-tools iw

2. 首先设定dnsmasq,这个提供DHCP和DNS服务功能


cat > /etc/dnsmasq.conf
log-facility=/var/log/dnsmasq.log
#address=/#/10.0.0.1
#address=/google.com/10.0.0.1
interface=wlan0
dhcp-range=10.0.0.10,10.0.0.250,12h
dhcp-option=3,10.0.0.1
dhcp-option=6,10.0.0.1
#no-resolv
log-queries
EOF

service dnsmasq start

3. 设定hostpad,这个会建立起Wifi AP服务


nano /etc/default/hostapd

#change this line
DAEMON_CONF="/etc/hostapd/hostapd.conf"

cat > /etc/hostapd/hostapd.conf
interface=wlan0
driver=nl80211
ssid=FreeWifi
channel=1
# Yes, we support the Karma attack.
#enable_karma=1
EOF

4. 接下来是设定NAT table,网上很多复杂设定,其实只需要开通FORWARD和MASQUERADE就可以了。当然也要开通ip_forward


iptables -t nat -F
iptables -F
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
echo '1' > /proc/sys/net/ipv4/ip_forward

5. 最后启动服务


ifconfig wlan0 up
ifconfig wlan0 10.0.0.1/24

airmon-ng check kill
service hostapd start