Tutorial 4 - Make Hotspot using PiTalk and Raspberry Pi

Tutorial 4 - Make Hotspot using PiTalk and Raspberry Pi

In this tutorial, you will learn how to integrate PiTalk (Smart-phone based on raspberry Pi) with Raspberry Pi' WiFi to make your personal Internet hotspot. It can be used as a router to connect to the internet and also host a local area network.

  1. Connect your Raspberry Pi to the internet using WiFi or Ethernet.


  2. Install the required packages:
    sudo apt-get install dnsmasq hostapd


  3. Configure 'wlan0' interface with a static IP. Open configuration file:
    sudo nano /etc/dhcpcd.conf
    and add the following line at the bottom:
    denyinterfaces wlan0
    Note: This must be above any 'interface' lines you may have added.


  4. Now configure static IP using the command:
    sudo nano /etc/network/interfaces
    and edit the file:
    allow-hotplug wlan0  
    iface wlan0 inet static  


  5. Now we need to configure 'hostapd'. Create a configuration file by using the command:
    sudo nano /etc/hostapd/hostapd.conf
    and add the following content:
    # This is the name of the WiFi interface we configured above
    # Use the nl80211 driver with the brcmfmac driver
    # This is the name of the network
    # Use the 2.4GHz band
    # Use channel 6
    # Enable 802.11n
    # Enable WMM
    # Enable 40MHz channels with 20ns guard interval
    # Accept all MAC addresses
    # Use WPA authentication
    # Require clients to know the network name
    # Use WPA2
    # Use a pre-shared key
    # The network passphrase
    # Use AES, instead of TKIP


  6. Open up the default configuration file using:
    sudo nano /etc/default/hostapd
    and find the line
    and replace it with


  7. Configure 'dnsmasq' configuration file:
    sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig  
    sudo nano /etc/dnsmasq.conf
    and paste the following into the new file:
    # Use interface wlan0  
    # Explicitly specify the address to listen on bind-interfaces      
    # Bind to the interface to make sure we aren't sending things elsewhere  
    server=       # Forward DNS requests to Google DNS  
    domain-needed        # Don't forward short names  
    bogus-priv           # Never forward addresses in the non-routed address spaces.  
    dhcp-range=,,12h # Assign IP addresses between and with a 12 hour lease time  


  8. Now enable packet forwarding:
    sudo nano /etc/sysctl.conf
    and remove the '#' from the beginning of the line containing:
    Now reboot your Raspberry Pi or active it immediately with:
    sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"


  9. Now we need to share our Raspberry Pi internet connection to our devices connected over WiFi by configuring:
    sudo iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE  
    sudo iptables -A FORWARD -i ppp0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT  
    sudo iptables -A FORWARD -i wlan0 -o ppp0 -j ACCEPT


  10. We need these rules to be applied every time we reboot the Raspberry Pi, so run the command to save the file:
    sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
    Now we need to run this after each reboot, so open the 'rc.local' file and add the following line just above the 'exit 0'
    iptables-restore < /etc/iptables.ipv4.nat


  11. Now to start the services type:
    sudo service hostapd start
    sudo service dnsmasq start


  12. Now to cross check everything configured correctly, reboot the Raspberry Pi:
    sudo reboot