Cluster Hat setup - Part 5 - Access Point Setup

Submitted by code_admin on Wed, 07/25/2018 - 15:23

Cluster Hat setup - Part 1
Cluster Hat setup - Part 2
Cluster Hat setup - Part 3 - Ansible
Cluster Hat setup - Part 4 - Docker Registry
Cluster Hat setup - Part 5 - Access Point Setup
Cluster Hat - Other Processes
Set up a new Raspberry Pi 3 to join the cluster

Step 23 - Setup access point

In summary we now have a cluster with 5 machines:

  • controller
  • p1
  • p2
  • p3
  • p4

The controller has a bridge, a DHCP server and a DNS server which connects all 5 together in a network 192.168.2.*.

I have also used the an external wifi dongle to connect the Raspberry Pi 3 to the internet via my home wifi. (192.168.1.* network)
I could set up port forwarding through the external adapter to allow clients to access services running on the Pi Zero's in the cluster.

However I don't want to do this. A use case for my cluster would be to put it into a bag and bring it with my laptop to other locations and possible demo it to others. To do this I will need to connect to it somehow and setup the wifi password etc. for that location. So instead I will setup the controller raspberry Pi as a WiFi access point. This way I can always use the laptop to connect to and operate the cluster.

(I referenced… for a lot of this step)

Only wifi adapters that support master mode can be used as wifi access points. You can check if an adapter supports master mode with the following command:

  1. sudo iwconfig wlan1 mode master
  2. iwconfig

To set up the access point install hostapd on the controller:

  1. sudo apt-get install hostapd

The wlan0 section of the /etc/network/interfaces file I already used has the relevant entry for wlan0 access point:

  1. ##wlan0 is the interface for the access point
  2. allow-hotplug wlan0
  3. iface wlan0 inet manual
  4.     pre-up brctl addif br0 wlan0

Then I created a config file for hostapd:

  1. sudo nano /etc/hostapd/hostapd.conf

and used:

  1. interface=wlan0
  2. bridge=br0
  4. driver=nl80211
  6. #SSID of network
  7. ssid=Pi_Cluster_Admin
  9. # Use the 2.4GHz band
  10. hw_mode=g
  12. # Use channel 6
  13. channel=6
  15. # Enable 802.11n
  16. ieee80211n=1
  18. # Enable WMM
  19. wmm_enabled=1
  21. # Enable 40MHz channels with 20ns guard interval
  22. ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
  24. # Accept all MAC addresses
  25. macaddr_acl=0
  27. # Use WPA authentication
  28. auth_algs=1
  30. ignore_broadcast_ssid=0
  32. # Use WPA2
  33. wpa=2
  35. # Use a pre-shared key
  36. wpa_key_mgmt=WPA-PSK
  38. # The network passphrase
  39. wpa_passphrase=raspberry
  41. rsn_pairwise=CCMP

(Of course I didn't use this passphrase)

I ran the command

  1. sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf

The access point appeared and I was able to log in with my phone!

I enabled the service permanently by editing the file sudo nano /etc/default/hostapd and setting:

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

I then entered the command

  1. sudo systemctl enable hostapd

I then rebooted the cluster.

Step 24 - Final Checkpoint

You can check this setup has worked by disconnecting the laptop from the home wifi and connecting it to the Pi_Cluster_Admin. It should still be possible to access the internet through this connection.

As the laptop is on the same network as the cluster you can also load a browser and connect to http://p1/ or and see the apache welcome page.


And that's the end of the tutorial. I plan to use this as a platform for future adventures learning Ansible, Docker, Microservices, and more. I have created a quick reference page for process I use maintain the cluster here - Cluster Hat - Other Processes.

If you have found any issues, improvements with this tutorial then it would be great if you share them with me so I can correct and improve my setup. I should be active in the clusterhat forum (!forum/clusterhat)

Cameron MacFarland has created similar steps to what I have followed as an Ansible setup process which is available here:
I haven't run it myself but it looks like a great one step way to achieving a similar result to this tutorial.

RJM Article Type
Public Article