- Making Raspberry Pi as an Access point
The Raspberry pi can be used as a wireless access point, running a standalone network. This can be done using the inbuilt wireless features of the Raspberry pi 3 or the raspberry pi zero W,or by using a suitable wifi dongle that supports access points.
Use the following to update your raspbian installation:
sudo apt-get update
sudo apt-get dist upgrade
The first step is to install the required packages:
sudo apt-get install dnsmasq hostapd
- hostapd – This is the package that allows you to use the built in WiFi as an access point
- dnsmasq – This is a combined DHCP and DNS server that’s very easy to configure
CONFIGURE YOUR INTERFACES
The first thing you’ll need to do is to configure your wlan0 interface with a static IP.
If you’re connected to the Pi via WiFi, connect via ethernet/serial/keyboard first.
In newer Raspian versions, interface configuration is handled by dhcpcd by default. We need to tell it to ignore wlan0, as we will be configuring it with a static IP address elsewhere. So open up the dhcpcd configuration file with
sudo nano /etc/dhcpcd.conf and add the following line to the bottom of the file:
To configure the static ip address , edit the interfaces configuration file with
sudo nano /etc/network/interfaces
iface wlan0 inet static
# wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
Restart dhcpcd with sudo service dhcpcd restart
and then reload the configuration for wlan0 with
sudo ifdown wlan0; sudo ifup wlan0.
Next, we need to configure hostapd. Create a new configuration file with
sudo nano /etc/hostapd/hostapd.conf with the following contents:
# 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
Open up the default configuration file with
sudo nano /etc/default/hostapd and find the line #DAEMON_CONF=”” and replace it with DAEMON_CONF=”/etc/hostapd/hostapd.conf”.(Don’t forget to remove the comment notation).
The shipped dnsmasq config file contains a wealth of information on how to use it, but the majority of it is largely redundant for our purposes. I’d advise moving it (rather than deleting it), and creating a new one with
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
sudo nano /etc/dnsmasq.conf
interface=wlan0 # Use the require wireless interface – usually wlan0
WE’RE ALMOST THERE!
Now we just need to start our services:
sudo service hostapd start
sudo service dnsmasq start
Using a wireless device, search for networks. The network SSID you specified in the hostapd configuration should now be present, and it should be accessible with the specified password.
If SSH is enabled on the Raspberry Pi access point, it should be possible to connect to it from another Linux box (or a system with SSH connectivity present) as follows, assuming the pi account is present:
After the completion of all these steps ,your raspberry pi will work as an access point and you can directly connect it using any other mobile device or wifi enabled module .