Here’s an overview of the steps to set up a wireless access point (WAP) with hostapd on Debian or Ubuntu Linux:
- Install hostapd and its dependencies:
sudo apt-get update
sudo apt-get install hostapd dnsmasq
- Configure hostapd:
Create a new configuration file for hostapd, for example at “/etc/hostapd/hostapd.conf”. Add the following lines to the file, replacing “ssid” and “password” with the desired values:
interface=wlan0
driver=nl80211
ssid=YourSSID
hw_mode=g
channel=6
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=YourPassword
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
- Configure dnsmasq:
Create a new configuration file for dnsmasq, for example at “/etc/dnsmasq.conf”. Add the following lines to the file:
interface=wlan0
listen-address=127.0.0.1
bind-interfaces
server=8.8.8.8
domain-needed
bogus-priv
dhcp-range=192.168.50.50,192.168.50.150,12h
- Start hostapd:
sudo hostapd /etc/hostapd/hostapd.conf
- Start dnsmasq:
sudo service dnsmasq start
- Configure the network interface:
sudo ifconfig wlan0 192.168.50.1
- Enable IP forwarding:
sudo sysctl net.ipv4.ip_forward=1
- Set up NAT:
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
After completing these steps, your WAP should be up and running. You can verify by connecting to the WAP from another device and checking the network connection.