Chapter 4 Steps to create a Wifi-access point

  1. If you have an ethernet cable plugged in into your Pi, you can start the web browser and see if the internet is working or not
  2. Now type ifconfig in the terminal and note the IP address of your Pi in the eth0 interface(this would be the IP address of the Pi)
  3. You now want to create a wifi-hotspot using the wifi-card on the Pi. This can be achieved using a service called hostapd but you don’t just want the hotspot, you also want the internet access through the wireless access point. You also install the dnsmasq service for this purpose which is an easy to configure DNS and DHCP server
  4. Use the following command and hit y when prompted to do so

bash sudo apt-get install dnsmasq hostapd 5. The next step you need to do is to provide your wlan0 interface with a static IP. We already have our raspberry pi connected to the ethernet cable from whihc we will be sharing our internet 6. We will be using dhcpcd(most feature-rich open source DHCP client) to configure our interface configuration so open it up using

bash sudo nano /etc/dhcpcd.conf 7. We need to tell it that our wlan0 has a static IP. So add these lines to it at the bottom of the file:

bash interface wlan0 static ip_address=172.24.1.1/24 8. We also need to prevent wpa_supplicant from running and interfering with setting up wlan0 in access point mode. To do this open up the interface configuration file with

bash sudo nano /etc/network/interfaces and comment out the line containing wpa-conf in the wlan0 section, so that it looks like this

bash allow-hotplug wlan0 iface wlan0 inet manual # wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf 9. Now restart dhcpcd with

bash sudo service dhcpcd restart and it should assign wlan0 with a static IP address 10. Now we need to configure hostapd. Change the configuration file for hostapd using

bash sudo nano /etc/hostapd/hostapd.conf with the contents given in the hostapd.conf file 11. To check whether all we’ve been doing is working or not, just run this command

bash sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf If everything goes well, you should be able to see the network Pi3-AP from your mobile phone or laptop device. You can try connecting to it in whoch case you would see some output from the Pi but you won’t be allotted an IP address until we configure dnsmasq. So press Ctrl + c to stop it 12. Right now, hostapd is not configured to work on a fresh boot. So we also need to tell hostapd where to look for the config file when it starts up on boot. Open up the default configuration file with

bash sudo nano /etc/default/hostapd and find the line #DAEMON_CONF=“” and replace it with DAEMON_CONF=“/etc/hostapd/hostapd.conf” and this would do the job