Skip to content

10. Basic AP (Manual Configuration)

Koutto edited this page Nov 1, 2020 · 1 revision
  1. Install dnsmasq:
apt-get install dnsmasq
  1. Create a configuration file /etc/dnsmasq.conf as follows:
interface=wlan0
dhcp-authoritative
dhcp-range=192.168.1.2,192.168.1.30,255.255.255.0,12h
dhcp-option=3,192.168.1.1
dhcp-option=6,192.168.1.1
server=8.8.8.8
log-queries
log-dhcp
listen-address=192.168.1.1 # to make DNS and DHCP servers listening only on the interface used for AP
bind-interfaces # make sure to bind only on the provided interface (otherwise bind on all interfaces by default)
  1. Set IPs and routes:
ifconfig wlan0 up 192.168.1.1 netmask 255.255.255.0
route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1
  1. Start dnsmasq:
dnsmasq -C /etc/dnsmasq.conf -d
  1. Install hostapd:
apt-get install hostapd
  1. Create a configuration file hostapd.conf:
interface=wlan0
driver=nl80211
ssid=MYWIFI
hw_mode=g
channel=11
macaddr_acl=0
ignore_broadcast_ssid=0
auth_algs=1
wpa=2
wpa_passphrase=mywifipassphrase
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
wpa_group_rekey=86400
ieee80211n=1
wme_enabled=1
  1. Set monitor mode and start hostapd:
# airmon-ng check kill # Might be necessary to kill interfering processes
iwconfig wlan0 mode monitor
ifconfig wlan0 up
hostapd ./hostapd.conf
  1. Configure forwarding and redirection (to enable Internet access):
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface wlan0 -j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward
Clone this wiki locally