How to turn a Raspberry Pi into a wireless access point

Are you looking to create multiple indoor access points without any latency issues and connectivity is often related to WiFi extender use? In this article, you will learn how to turn a Raspberry Pi into a wireless access point.

When the wireless access point is working, anyone with a password can connect to the Raspberry Pi as if it were a mini router, ideal for everyone from cafe owners who want to provide it to customers. Free WiFi, to employers who need to create a private network for employees or even someone who likes the idea of ​​having multiple WiFi networks at home!

How to turn a Raspberry Pi into a wireless access point?

  1. Things to prepare
  2. Get started: Set up a Raspberry Pi
  3. Install the hostapd, dnsmasq and firewall plugins
  4. Specify a static IP address
  5. Allow routing
  6. Configure service DHCP and DNS
  7. Create network name and password
  8. Connect to the wireless access point

Things to prepare

To complete this tutorial, you will need:

  1. The Raspberry Pi 3/4 runs Raspbian. Without Raspbian, you can get the latest version and flash it with Etcher.
  2. The power cable is compatible with the Raspberry Pi
  3. External keyboard and how to attach it to a Raspberry Pi
  4. HDMI or micro HDMI cables, depending on the Raspberry Pi model
  5. External screen
  6. Ethernet cable. Because the purpose is to turn the Raspberry Pi into a wireless access point, you will need to connect via Ethernet rather than WiFi. This also means it is impossible to use Raspberry Pi 2 or Raspberry Pi Zero, because they are missing Ethernet ports or wireless network cards.

Get started: Set up a Raspberry Pi

To get started, connect all peripherals to the Raspberry Pi, including an Ethernet cable.

How to turn a Raspberry Pi into a wireless access point Picture 1

When the Raspberry Pi has finished booting, you should check to see if you are running the latest version of Raspbian. Launch Terminal by clicking the application icon on the toolbar. Type the following command:

sudo apt-get update

Press Enteron the keyboard and wait for the command to execute.

Enter the next command and press Enteragain:

sudo apt-get upgrade

After the upgrade, it is best to restart the Raspberry Pi for all system changes to take effect. Run the following command:

reboot

Install the hostapd, dnsmasq and firewall plugins

Please install hostapd (host access point daemon), this is a software package that can convert network interface card (Network Interface Card) into access point.

To install hostapd on Raspberry Pi, open Terminal and run the following command:

sudo apt install hostapd

Activate the wireless access point and set it to run automatically on startup:

sudo systemctl unmask hostapd sudo systemctl enable hostapd

Next, install dnsmasq, provide the Domain Name System (DNS) caching and the Dynamic Host Configuration Protocol (DHCP) server designed for small networks.

To install this package, run the following command in Terminal:

sudo apt install dnsmasq

Finally, install netfilter-persistent and iptables-persistent, two plugins responsible for saving and loading firewall rules on the Raspberry Pi:

sudo DEBIAN_FRONTEND=noninteractive apt install -y netfilter-persistent iptables-persistent

Specify a static IP address

The Dynamic Host Configuration Protocol server requires a static IP address, so in this section, you will configure a static IP for the Raspberry Pi.

To get started, run the following command in Terminal:

sudo nano /etc/dhcpcd.conf

Raspbian will open the configuration file for dhcpcd. Scroll to the bottom of this file and add the following lines:

interface wlan0 static ip_address=192.168.4.1/24 nohook wpa_supplicant

Save the changes by pressing Ctrl+ O, followed by Ctrl+ X.

Allow routing

The Raspberry Pi access point is currently running its own independent wireless network. However, if you want to allow customers to access computers on your Ethernet network, then you will need to enable routing.

To allow routing, create the routed-ap.conf file using the following command:

sudo nano /etc/sysctl.d/routed-ap.conf

This command creates the routed-ap.conf file and opens it for editing in the Nano editor. In the text editor, type the following:

net.ipv4.ip_forward=1

Save the changes.

Add a new firewall rule to the Raspberry Pi by running the following command:

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Finally, use netfilter-persistent to ensure new rules are loaded on startup:

sudo netfilter-persistent save

Configure service DHCP and DNS

The dnsmasq package provides a default configuration file, but you don't need all the options included in this file.

To make things easier, rename the default configuration file dnsmasq. And create a completely blank replacement file.

Then open this new dnsmasq.conf file in the Nano editor and add only the configuration options you really need.

To get started, run the following Terminal commands:

sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig sudo nano /etc/dnsmasq.conf

Add the following configuration options:

interface=wlan0 dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h domain=wlan address=/gw.wlan/192.168.4.1

Save the changes.

Create network name and password

Configure the wireless access point by editing the hostapd configuration file.

To open this file and edit, run the following command:

sudo nano /etc/hostapd/hostapd.conf

Add some information for the wireless access point, including naming and password security. To help protect the access point, the password must be 8 characters or more, a combination of letters, numbers and symbols.

This tutorial creates an access point named NetworkName with the password PassphrasePassphrase. But make sure you use something more secure for your network!

interface=wlan0 ssid=NetworkName hw_mode=g channel=7 macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 wpa=2 wpa_passphrase=PassphrasePassphrase wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP

Save the changes.

Connect to the wireless access point

Congratulations, you have turned your Raspberry Pi into a wireless access point.

To verify that everything is working properly, you should restart your Raspberry Pi and check if the access point can be connected after this reboot.

Once the Raspberry Pi has been rebooted, grab any WiFi-enabled device and scan for nearby wireless networks. You should see a network with the name you specified in the hostapd.conf file of the Raspberry Pi.

How to turn a Raspberry Pi into a wireless access point Picture 2 The network with the specified name will appear

Try connecting to this network and you will be prompted for a password. Enter the passphrase from the hostapd.conf file and after a few moments, you will be successfully connected to your wireless access point.

How to turn a Raspberry Pi into a wireless access point Picture 3

You can now surf the Internet on WiFi-enabled devices as if it were directly connected to the router.

4 ★ | 41 Vote

May be interested

  • 5 ways to copy data from Raspberry Pi to PC5 ways to copy data from Raspberry Pi to PC
    whatever purpose you use raspberry pi for, at some point, you will want an easy way to get data out of pi's sd card and insert it into your pc's hard drive.
  • Bring WiFi homeBring WiFi home
    in the past, building a home wireless network was considered a luxury demand because the device for it was quite expensive. however, just less than 1 million vnd can now set up a wireless access point in your home.
  • How to make a Raspberry Pi a web serverHow to make a Raspberry Pi a web server
    today's article will show you how to turn a raspberry pi into a personal web server. at the end of this tutorial, you will learn how to install the apache web server on the raspberry pi, set up php and create a simple website to access over the local network.
  • How to turn a Raspberry Pi into an IRC serverHow to turn a Raspberry Pi into an IRC server
    irc is one of the classic chat protocols still used by many modern online communities. today, there is no shortage of irc servers and clients available. you can also set up your own irc server with a raspberry pi.
  • Share your Mac's Internet connection with wireless devicesShare your Mac's Internet connection with wireless devices
    if you are using a mac and do not know that you can use a mac as a wireless access point to share the internet connection for other wireless ethernet devices such as mobile phones and laptops ...
  • Tutorial on DD-WRT - Part 5: Wireless repeaterTutorial on DD-WRT - Part 5: Wireless repeater
    previously, when you wanted to expand the scope of a wireless access point, you had to set up a wds (wireless distribution system), along with two or more routers supporting wds.
  • How to set up Wi-Fi and Bluetooth on Raspberry Pi 3How to set up Wi-Fi and Bluetooth on Raspberry Pi 3
    while the raspberry pi model b + and the raspberry pi 2 have added usb ports, the best solution is still to have bluetooth and wi-fi integrated, which users finally get in the raspberry pi 3.
  • 3 ways to edit file boot / config.txt on Raspberry Pi3 ways to edit file boot / config.txt on Raspberry Pi
    what is the fastest way to access the file config.txt in the / boot directory / when raspberry is still running? if you have to turn off to get back the microsd card, how will it be edited?
  • Review the EnGenius EnSky Wi-Fi 6 4x4 Indoor Access Point routerReview the EnGenius EnSky Wi-Fi 6 4x4 Indoor Access Point router
    engenius ensky wi-fi 6 4x4 indoor access point is a high quality 802.11ax access point that supports mesh, which simplifies deployment of power-over-ethernet technology.
  • Wireless LAN security (Term 2)Wireless LAN security (Term 2)
    a wireless lan consists of three parts: wireless client, access points and access server. the typical wireless client is a laptop with a wireless nic (network interface card) installed to allow access to the wireless network. access points (ap) provide three