Raspberry Pi 3 Model B+ Router (AP) Updated 2019


  • Raspberry Pi 3 B+ or Raspberry Pi Zero W
  • Image Raspbian onto your SD card
  • Set up your Pi with your configuration like Keyboard and wifi.

Lets Update

First, update your system’s package list by entering the following command:

sudo apt-get update

Next, upgrade all your installed packages to their latest versions with the command:

sudo apt-get dist-upgrade

Install all the required software in one go with this command:

sudo apt install dnsmasq hostapd

Configuring a static IP
We are configuring a standalone network to act as a server, so the Raspberry Pi needs to have a static IP address assigned to the wireless port. This documentation assumes that we are using the standard 192.168.x.x IP addresses for our wireless network, so we will assign the server the IP address It is also assumed that the wireless device being used is wlan0.

To configure the static IP address, edit the dhcpcd configuration file with:

sudo nano /etc/dhcpcd.conf

Go to the end of the file and edit it so that it looks like the following:

interface wlan0
static ip_address=
nohook wpa_supplicant

Now restart the dhcpcd daemon:

sudo systemctl restart dhcpcd

Configuring the DHCP server (dnsmasq)
The DHCP service is provided by dnsmasq. By default, the configuration file contains a lot of information that is not needed, and it is easier to start from scratch. Rename this configuration file, and edit a new one:

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

Type or copy the following information into the dnsmasq configuration file and save it:

interface=wlan0 # Use the require wireless interface - usually wlan0

So for wlan0, we are going to provide IP addresses between and, with a lease time of 24 hours. If you are providing DHCP services for other network devices (e.g. eth0), you could add more sections with the appropriate interface header, with the range of addresses you intend to provide to that interface.

Reload dnsmasq to use the updated configuration:

sudo systemctl reload dnsmasq

Configuring the access point host software (hostapd)
You need to edit the hostapd configuration file, located at /etc/hostapd/hostapd.conf, to add the various parameters for your wireless network. After initial install, this will be a new/empty file.

sudo nano /etc/hostapd/hostapd.conf

Add the information below to the configuration file. This configuration assumes we are using channel 7, with a network name of NameOfNetwork, and a password AardvarkBadgerHedgehog. Note that the name and password should not have quotes around them. The passphrase should be between 8 and 64 characters in length.

To use the 5 GHz band, you can change the operations mode from hw_mode=g to hw_mode=a. Possible values for hw_mode are:
a = IEEE 802.11a (5 GHz)
b = IEEE 802.11b (2.4 GHz)
g = IEEE 802.11g (2.4 GHz)
ad = IEEE 802.11ad (60 GHz)

#speeds up the downloads

We now need to tell the system where to find this configuration file.

sudo nano /etc/default/hostapd

Find the line with #DAEMON_CONF, and replace it with this:


Start it up
Now enable and start hostapd:

sudo systemctl unmask hostapd
sudo systemctl enable hostapd
sudo systemctl start hostapd

Add routing and masquerade
Edit /etc/sysctl.conf and uncomment or add this line:


Add a masquerade for outbound traffic on eth0:

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

See issues below if this fails.

Save the iptables rule.

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

Edit /etc/rc.local and add this just above exit 0 to install these rules on boot.

iptables-restore < /etc/iptables.ipv4.nat

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@
By this point, the Raspberry Pi is acting as an access point, and other devices can associate with it. Associated devices can access the Raspberry Pi access point via its IP address for operations such as rsync, scp, or ssh.

Whos connected?

To find out whos connected to your router install nmap

sudo apt install nmap

NOTE: you will need to be connected to the internet. Best way is to plug into ethernet.

Once its in install you can then type this in and it will list out all connected devices.

sudo nmap -sP -PI -PT > list.text

Starting Nmap 7.40 ( https://nmap.org ) at 2019-06-19 08:56 MST
Nmap scan report for ShadowBook-Pro (
Host is up (-0.090s latency).
MAC Address: F0:18:98:28:1C:1C (Unknown)
Nmap scan report for kali (
Host is up (-0.15s latency).
MAC Address: 80:1F:02:F6:68:B6 (Edimax Technology)
Nmap scan report for
Host is up.
Nmap done: 256 IP addresses (3 hosts up) scanned in 15.18 seconds

filter it down to IP’s only

sudo nmap -sP -PI -PT | grep -i Nmap > list.text 


If you have issues with MASQUERADE you should run sudo apt update then sudo apt upgrade to ensure your kernel has been replaced, then reboot and check uname -r; it should give a version with a corresponding /lib/modules/ directory that does exist. The pi kernel can boot without any, however, so to check, try lsmod; if there’s nothing, something is wrong. If there is, you can filter that lsmod | grep -P "ip|nf” to see the ones that are related to iptables/netfilter (and anything else that coincidentally contains those letter combinations).
The base module is actually ip_tables, but it should be loaded automatically. The base module for NAT is nf_nat but that should be loaded automatically as well.

Loading Facebook Comments ...