Access Point WiFi with Raspberry Pi, extend your wired network

Access Point WiFi with Raspberry Pi, extend your wired network

A WiFi access point will help extend your existing wired network. This means you don't need to configure a DHCP server and the rest of devices in your home or office (wired or wireless) will communicate easier with the devices that connected through the WiFi of your Raspberry Pi. This is called a “bridged access point“.

If you are using a Raspberry Pi 3 or newer, a WiFi module is included in the same board; otherwise you will have to get a WiFi USB dongle. Make it explicitly says “Access Point capable”.

Installation

Before starting a new setup, be sure to make an update to the repositories in your Raspberry Pi.

sudo apt-get update

The next step is to install the access point software called hostapd.

sudo apt install hostapd

Afterwards, enable the service and set the option to start the service when the Raspberry Pi starts.

sudo systemctl unmask hostapd
sudo systemctl enable hostapd

Configuration

Ensure wireless unblock for the Access Point operation

5GHz wireless networking is by default disabled in your Raspberry Pi. Execute this code to unblock it:

sudo rfkill unblock wlan

Setup the bridge network

A bridge network will ensure a Ethernet network and a wireless network to see each other. To create this bridge named br0, create a file with the following command:

sudo nano /etc/systemd/network/bridge-br0.netdev

Add the following content and afterwards click save (ctrl + x and ‘yes' and ‘enter'):

[NetDev]
Name=br0
Kind=bridge

Now a similar process to bind the Ethernet interface with this bridge, making it member of it. Create this another file.

sudo nano /etc/systemd/network/br0-member-eth0.network

Add the following content and afterwards click save (ctrl + x and ‘yes' and ‘enter')

[Match]
Name=eth0

[Network]
Bridge=br0

There is no need to create the bridge member ‘wlan0'. This happens only to wireless network interfaces.

Enable the systemd-networkd service. This will take effect on the boot evertime.

sudo systemctl enable systemd-networkd

Define the bridge device IP configuration

In other to make the bridge to work properly, we have to block the Ethernet network eth0 and the wireless network wlan0 to search an IP address by their own, through DHCP. Only the bridge br0 will do so.

Let's open the DHCPCD configuration file:

sudo nano /etc/dhcpcd.conf

Add at the top of the rest of lines, this code:

denyinterfaces wlan0 eth0

And add this at the very bottom of the file:

interface br0

This way, br0 will search for an address in a DHCP server (like your router). Therefore, you can make a DHCP reservation when you know the MAC address.

Enable Port Forwarding to the Access Point

This way, the data between wlan0 and eth0 can pass to each other.

sudo nano /etc/sysctl.conf

Search for #net.ipv4.ip_forward=1 and remove the # from the beginning of the line to enable the forwarding.

Access Point's registers

You need to configure a various parameters for your new wireless network. Access to register file by typing this line:

sudo nano /etc/hostapd/hostapd.conf
country_code=EC
interface=wlan0
bridge=br0
driver=nl80211
ssid=Juditova WiFi
hw_mode=g
channel=6
ieee80211n=1
wmm_enabled=1
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_passphrase=raspberry
rsn_pairwise=CCMP

Did you notice that here you associate the wireless network wlan0 and the bridge br0? A reason why you didn't need to create another file associating wlan0 and br0. Therefore, this completes the bridge.

Now, let's configure two important customizable parameters. SSID is the name of your network and wpa_passphrase is the password of the access point. The password should be between 8 and 63 characters.

Select the country code, depending on where you live right now (obviously). Check this website in order to check the correct code of your country.

To change the operation mode of the wireless network, choose between any of these values in the hw_mode parameter:

  • a = IEEE 802.11a (5 GHz) (For Raspberry Pi 3B+ or later)
  • b = IEEE 802.11b (2.4 GHz)
  • g = IEEE 802.11g (2.4 GHz)

Access Point's configuration path

Well, hostapd must know the address to the configuration file you just wrote. So type the following code:

sudo nano /etc/default/hostapd

Find the line #DAEMON_CONF="" and replace it with this:

DAEMON_CONF="/etc/hostapd/hostapd.conf"

Press Ctrl + X to exit the editor (select ‘yes' and ‘enter' to save). Now, let's reboot.

sudo systemctl reboot

Reserving the new ‘physical' address for the Access Point

Since we denied wlan0 and eth0, br0 works now as a standalone interface. This means that your Raspberry Pi will look for a new IP address. If you don't need to do this, skip to the next heading.

Before going any further, check my blog post on how to reserve an IP address on the DHCP server on your Router.

https://www.techzorro.com/blog/dhcp/

But how do we know the new physical address of the br0? There two (main) options:

Ask your Raspberry Pi

Indeed! Just open the terminal and type the following code and you will get something similar like this:

ifconfig

Look for the br0 interface in the ether parameter.

DHCP Clients.

Look for the DHCP clients in your router's website (for me it's 192.168.1.1). You might find it quick and easy like mine:

Testing the Access Point

As displayed in the picture below, my WiFi access point works! Now, I can use it to surf the web.

Resources

You have reached this far!

Thank you for reading the blog post. Your comments and suggestions are welcomed. At the bottom of this page, leave a message or just say hi! The whole team of techZorro will appreciate it. Don't forget to share it on social media as well.

techZorro’s Index of Content

Click on the following link to browse likewise content in the blog in techZorro. This index will help you see what you are looking for in a bird’s eye view.

techZorro's Newsletter!

If you enjoyed this blog post, please subscribe to techZorro’s newsletter so you don’t miss any future blog posts!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.