raspberrypi-unifi-controller-ap

I picked up an AP from Unifi, but I already have a firewalla and some switches. I originally set up the AP manually with the Wi-Fi AP. If that’s all you need to do it will run, I couldn’t figure out how to get VLANs configured for specific. Well, you need to use the Unifi controller. You can get this with a cloud key or a dream machine, but it gives you the remote console. Turns out you can make your own Unifi controller. Let’s do that with one of the Raspberry Pi’s that are lying around.

A quick google later and big shout out to (emmet)[https://pimylifeup.com/rasberry-pi-unifi/] for getting the guide below guide together. Setup goes superfast, its like 15 minutes and spend more time looking for a nail as you now need to reset the AP so it can be adopted by the controller.

Take a peek at this guy, Evan he explains all the configurations and gives you a starting point on whether or not you should change a setting (Unifi advance wi-fi settings) [https://evanmccann.net/blog/2021/11/unifi-advanced-wi-fi-settings]

Configure the VLAN ID and map them each to a Wi-Fi network and associate them with your ap.

Then you just need to find all the Wi-Fi devices and rest their connection to your segmented networks. Congrats! you can now cut off internet access to all the IoT & music things that lay about your house.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# Installing the UniFi Controller on the Raspberry Pi


## Preparing your Raspberry Pi for the UniFi Controller

```bash
sudo apt update
sudo apt upgrade
```

### Adding Entropy using rng-tools

**2.** To improve the startup speed of the UniFi controller software on our Raspberry Pi, we need to install `rng-tools`.

We will utilize this package to ensure the Raspberry Pi has enough entropy for the random number generation that the UniFi software uses.

```bash
sudo apt install rng-tools
```

**3.** We now need to make a slight change to the rng-tools configuration.

Begin editing the config file by running the following command.

```bash
sudo nano /etc/default/rng-tools-debian
```

**4.** Within this file, find and uncomment the following line.

**Find**

```ini
#HRNGDEVICE=/dev/hwrng
```

**Replace With**

```ini
HRNGDEVICE=/dev/hwrng
```

By uncommenting this line, we are adding to the amount of entropy (The amount of randomness) that the system has available.

The Raspberry Pi features an integrated random number generator that we can utilize to increase the entropy pool.

**5.** Once you have made the change, save the file by pressing CTRL + X, then Y, followed by ENTER.

**6.** Finally, restart the `rng-tools` service by running the command below.

```bash
sudo systemctl restart rng-tools
```

Once the service has finished restarting, it should now be safe to proceed to the next section of this guide.

### Installing an Older Release of LibSSL

**7.** Due to the version of MongoDB that we will be utilizing, we will need to install an older release of LibSSL to our Raspberry Pi.

In particular, we will be installing LibSSL 1.0. You can download this old release by using the following command.

```bash
wget http://ports.ubuntu.com/pool/main/o/openssl/libssl1.0.0_1.0.2g-1ubuntu4_arm64.deb -O libssl1.0.deb
```

**8.** Once the package has been downloaded, all we need to do to install it is to run the command below.

```bash
sudo dpkg -i libssl1.0.deb
```

### Installing MongoDB to your Raspberry Pi for the UniFi Controller

**9.** To use the UniFi Controller on your Raspberry Pi, we will need to install MongoDB.

This is the database server that UniFi uses to store all of its data. As we cant rely on the package repository, we will need to follow some additional steps.

For this first step, we will download the latest available version of MongoDB 3.6 to our Pi. We are installing 3.6 as this is currently the only supported release for the UniFi Controller.

```bash
wget https://repo.mongodb.org/apt/ubuntu/dists/xenial/mongodb-org/3.6/multiverse/binary-arm64/mongodb-org-server_3.6.22_arm64.deb -O mongodb.deb
```

**10.** Once the package is downloaded, install it by using the following command within the terminal.

```bash
sudo dpkg -i mongodb.deb
```

**11.** Now that we have installed the MongoDB server, set it to start when your Raspberry Pi boots using the command below.

```bash
sudo systemctl enable mongod
```

**12**. Finally, start MongoDB by running the command shown below in the terminal.

This will start the server immediately, so we wont have to wait till our device restarts.

```bash
sudo systemctl start mongod
```

## Installing the UniFi Controller to the Raspberry Pi

**1.** Our first task is to add the UniFi repository to our sources list.

We can achieve this by running the command below.

```bash
echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/ubiquiti-archive-keyring.gpg] https://www.ui.com/downloads/unifi/debian stable ubiquiti' | sudo tee /etc/apt/sources.list.d/100-ubnt-unifi.list >/dev/null
```

You might notice that we are using “`amd64`” and not “`arm64`” or “`armhf`“. This is due to Ubiquiti not having their repository set up to mark “`arm64`” as compatible. However, it doesnt hugely matter as, at the moment, it will still download files compatible with our Raspberry Pi.

**2.** We now need to add the repositories GPG key by using the following command.

```bash
curl https://dl.ui.com/unifi/unifi-repo.gpg | sudo tee /usr/share/keyrings/ubiquiti-archive-keyring.gpg >/dev/null
```

The GPG key is what helps tell the package manager it is downloading the correct package.

**3.** As we made changes to the repositories, we need to now update the package list by running the command below.

```bash
sudo apt update
```

**4.** Now finally, we can install version 17 of the OpenJDK runtime as well as the Unifi Controller software itself to our Raspberry Pi by running the following command.

```bash
sudo apt install openjdk-17-jre-headless unifi
```

Installing UniFi through this method will automatically set up a service. This service will automatically start the UniFi software at boot.

Additionally, we are installing version 17 of the Java runtime environment as it is currently the only version supported by the UniFi controller.

## First Boot of the UniFi Controller on your Raspberry Pi

In this section, we are going to walk you through the initial configuration steps of the UniFi software.

**1.** First, retrieve the [local IP address for your Raspberry Pi](https://pimylifeup.com/raspberry-pi-ip-address/).

If you have terminal access to your Pi, you can use the following command.

```bash
hostname -I
```

**2.** With your Raspberry Pis IP address handy, go to the following web address in your favorite web browser.

Ensure that you replace “`<IPADDRES>`” with the IP of your Raspberry Pi.

```
https://<IPADDRESS>:8443
```