• Making Raspberry Pi as an Access point

Raspberry Pi as 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

PACKAGES

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:

denyinterfaces wlan0

To configure the static ip address , edit the interfaces configuration file with

sudo nano /etc/network/interfaces

allow-hotplug wlan0

iface wlan0 inet static

   address 172.24.1.1

netmask 255.255.255.0

network 172.24.1.0

broadcast 172.24.1.255

# 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.

CONFIGURE HOSTAPD

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

interface=wlan0

# Use the nl80211 driver with the brcmfmac driver

driver=nl80211

# This is the name of the network

ssid=Pi3-AP

# Use the 2.4GHz band

hw_mode=g

# Use channel 6

channel=6

# Enable 802.11n

ieee80211n=1

# Enable WMM

wmm_enabled=1

# Enable 40MHz channels with 20ns guard interval

ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]

# Accept all MAC addresses

macaddr_acl=0

# Use WPA authentication

auth_algs=1

# Require clients to know the network name

ignore_broadcast_ssid=0

# Use WPA2

wpa=2

# Use a pre-shared key

wpa_key_mgmt=WPA-PSK

# The network passphrase

wpa_passphrase=raspberry

# Use AES, instead of TKIP

rsn_pairwise=CCMP

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).

CONFIGURE DNSMASQ

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

server=8.8.8.8

dhcp-range=192.168.0.2,192.168.0.20,255.255.255.0,24h

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:

ssh pi@192.168.0.1

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 .

LEAVE A REPLY

Please enter your comment!
Please enter your name here