My desktop computer has a wired connection to the internet and so the built-in wifi card is normally not used. I decided to enable and use it as a wireless access point.
Unfortunately NetworkManager will only create an ad-hoc wifi network, and Android devices will only connect to infrastructure access points. Don’t ask why… A rooted Android phone or tablet can be configured to connect to an ad-hoc network, and if a separate program can configure a Linux box to act as an access point, NetworkManager should be able to do the same. As far as I can see, there are no good technical reasons for either of these deficiencies.
The solution is
First tell NetworkManager not to interfere and leave the wifi hardware in peace:
sudo nano /etc/NetworkManager/NetworkManager.conf
where ab:cd:ef:12:34:56 is the MAC address of your wifi card.
Install and configure hostapd, dnsmasq and configure wlan0 interface and ipv4 forwarding:
sudo apt-get install hostapd dnsmasq sudo service hostapd stop sudo service dnsmasq stop # these are only needed if you do not want the services to start automatically on boot sudo update-rc.d hostapd disable sudo update-rc.d dnsmasq disable
sudo nano /etc/default/hostapd
sudo nano /etc/init.d/hostapd
# The following line seems to reset the config file path (set in /etc/default/hostapd)?! # DAEMON_CONF=
sudo nano /etc/hostapd.conf
# Define interface interface=wlan0 # Select driver driver=nl80211 # Set access point name ssid=Name_of_your_AP # Set access point harware mode to 802.11g hw_mode=g # Set WIFI channel (can be easily changed) channel=11 # Enable WPA2 only (1 for WPA, 2 for WPA2, 3 for WPA + WPA2) wpa=2 wpa_passphrase=Your_secret_wifi_password
sudo nano /etc/dnsmasq.conf
# Bind to only one interface bind-interfaces # Choose interface for binding interface=lo,wlan0 no-dhcp-interface=lo # Specify range of IP addresses for DHCP leasses dhcp-range=192.168.4.2,192.168.4.10
sudo nano /etc/network/interfaces
# The loopback network interface auto lo iface lo inet loopback auto wlan0 iface wlan0 inet static hostapd /etc/hostapd.conf address 192.168.4.1 netmask 255.255.255.0
sudo nano /etc/sysctl.conf
sudo nano /etc/rc.local
... # enable NAT for wireless access point on wlan0 iptables -t nat -A POSTROUTING -s 192.168.4.0/24 ! -d 192.168.4.0/24 -j MASQUERADE ...
Bring up wlan0 interface and restart services
ifup wlan0 sudo service dnsmasq restart sudo service hostapd restart
ip link set dev wlp0s20f0u4 up