-
Configure wlan0 interface
/etc/network/interfaces:
auto wlan0
iface wlan0 inet static
address 192.168.22.1
netmask 255.255.255.0
-
Install the package hostapd for managing wireless card in host mode
sudo apt-get install hostapd
-
Configure hostap
File /etc/hostapd/hostapd.conf:
hw_mode=g
channel=11
driver=nl80211ssid=my-network-name
interface=wlan0# possible MAC address restriction
#macaddr_acl=0
#accept_mac_file=/etc/hostapd.accept
#deny_mac_file=/etc/hostapd.deny
#ieee8021x=1 # Use 802.1X authentication# encryption
wpa=2
wpa_passphrase=my-secret-password
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
rsn_pairwise=CCMP
ctrl_interface=/var/run/hostapd# Only root can configure hostapd
ctrl_interface_group=0 -
Start hostapd
sudo hostapd /etc/hostapd/hostapd.conf
Debug mode: sudo hostapd -dd /etc/hostapd/hostapd.confPossible errors:
Interface is managed with NetworkManager - check it: nmcli d should tell that intergace is NOT managed
Take it out from NetworkManager: sudo nmcli nm wifi off
Another error:
rfkill: WLAN soft blocked
Could not set interface wlan0 flags (UP): Operation not possible due to RF-kill
wlan0: Could not connect to kernel driver
Solution:
check interface state: rfkill list
unblock interface with rfkill: sudo rfkill unblock wlan
Hostap is already running
nl80211: Could not configure driver mode
nl80211 driver initialization failed.
hostapd_free_hapd_data: Interface wlan0 wasn't started
ps ax | grep hostap -
Try to connect to your new network - you should not obtain an IP address yet
-
Setup masquerading
-
Configure DHCP and DNS:
-
With dnsmasq:
Dnsmasq is not installed by default - only dnsmasq-base is, but it is not usable.sudo apt-get install dnsmasq
/etc/dnsmasq.conf:
interface=wlan0
dhcp-range=192.168.22.2,192.168.22.100,2h
#dhcp-host=11:22:33:44:55:66,192.168.1.2
Dnsmasq must be set in NetworkManager in /etc/NetworkManager/NetworkManager.conf:
dns=dnsmasq -
Old approach:
-
Autostart of hostapd
Add to the /etc/rc.local:
rfkill unblock wlan0 && hostapd /etc/hostapd/hostapd.conf
- Take out wlan interface from NetworkManager config (see error in Start hostapd): /etc/NetworkManager/NetworkManager.conf:
[keyfile]
unmanaged-devices=mac:<WLAN_MAC_ADDRESS>
Maybe the same there: no-auto-default=<WLAN_MAC_ADDRESS>
Bash script wifiup.sh:
#! /bin/bash
if [ `ps ax | grep hostap | grep -v grep | wc -l` -eq 0 ]; then
echo `rfkill list` > /tmp/wifi-rfkill-on-start
rfkill unblock wlan && hostapd /etc/hostapd/hostapd.conf & > /tmp/hostap.log
fi