Skip to content

Instantly share code, notes, and snippets.

@mcastelino
Last active September 24, 2022 07:33
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcastelino/fd4265be930182c53bb3eec0e7eb2eed to your computer and use it in GitHub Desktop.
Save mcastelino/fd4265be930182c53bb3eec0e7eb2eed to your computer and use it in GitHub Desktop.
How to upgrade Unifi Cloud Key 2 Firmware with Pi Hole

Last verified with

    Pi-hole v5.1.2 Web Interface v5.1.1 FTL v5.2
    Cloud Key firmware UCKG2.apq8053.v1.1.13.818cc5f.200430.0938

Instructions

#go superuser

sudo –i

#Let's install nano to make conf edit easier

apt-get install nano

#Install dnsmasq

apt-get update

apt-get install dnsmasq

#(Answer Y to replace the files as keeping the existing will point to 01-pihole.conf which does not work until pi-hole is installed)

# Ubiquiti switched the resolver to systemd-resolved which reserves the port 53

# dnsmasq install will fail to start dnsmasq so lets resolve that

sudo systemctl stop systemd-resolved

sudo systemctl disable systemd-resolved

sudo systemctl start dnsmasq

#Install pi-hole

cd /tmp

wget -O basic-install.sh https://install.pi-hole.net

#Install optional dependencies

#apt-get install man

#Install required dependencies

apt-get install whiptail

apt-get install dhcpcd5

apt-get install git

apt-get install dnsutils

apt-get install lsof

apt-get install unzip

apt-get install idn2

#downgrade libsqlite3 to support sqlite3

apt-get install libsqlite3-0=3.16.2-5+deb9u1

apt-get install sqlite3

apt-get install resolvconf

apt-get install lighttpd

apt-get install php-common

apt-get install php-cgi

apt-get install php-sqlite3

bash basic-install.sh

#Reconfigure lighttpd port to 8081

nano /etc/lighttpd/lighttpd.conf

#Restart lighttpd

/etc/init.d/lighttpd restart

#Change the pi-hole random password to your liking

pihole -a -p
  • Fix the php issue (valid only on older versions). If HTTP_HOST is not found, ignore this section.
/var/www/html/pihole/index.php

change

$serverName = htmlspecialchars($_SERVER["HTTP_HOST"]);

to

$serverName = htmlspecialchars($_SERVER["SERVER_ADDR"]);
@mcastelino
Copy link
Author

Last verified with

  • Pi-hole v5.1.2 Web Interface v5.1.1 FTL v5.2
  • Cloud Key firmware UCKG2.apq8053.v1.1.13.818cc5f.200430.0938

@jongio
Copy link

jongio commented Jan 14, 2021

Pi-hole v5.2.2 Web Interface v5.2.2 FTL v5.3.4
Cloud Key: 2.0.24

root@UCK-G2-Plus:~# sudo –i
sudo: –i: command not found

The code above needs to be updated to sudo -i, the dash is a special character, so it doesn't work.

root@UCK-G2-Plus:~# apt-get install nano
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package nano

You need to run apt-get update first

Got errors when running dnsmasq for the first time

root@UCK-G2-Plus:~# apt-get install dnsmasq
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  dns-root-data dnsmasq-base
Suggested packages:
  resolvconf
The following NEW packages will be installed:
  dns-root-data dnsmasq dnsmasq-base
0 upgraded, 3 newly installed, 0 to remove and 6 not upgraded.
Need to get 412 kB of archives.
After this operation, 936 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://deb.debian.org/debian stretch/main arm64 dns-root-data all 20190313                                                     02~deb9u1 [4746 B]
Get:2 http://deb.debian.org/debian stretch/main arm64 dnsmasq-base arm64 2.76-5+                                                     deb9u2 [392 kB]
Get:3 http://deb.debian.org/debian stretch/main arm64 dnsmasq all 2.76-5+deb9u2                                                      [15.9 kB]
Fetched 412 kB in 0s (5503 kB/s)
Selecting previously unselected package dns-root-data.
(Reading database ... 34603 files and directories currently installed.)
Preparing to unpack .../dns-root-data_2019031302~deb9u1_all.deb ...
Unpacking dns-root-data (2019031302~deb9u1) ...
Selecting previously unselected package dnsmasq-base.
Preparing to unpack .../dnsmasq-base_2.76-5+deb9u2_arm64.deb ...
Unpacking dnsmasq-base (2.76-5+deb9u2) ...
Selecting previously unselected package dnsmasq.
Preparing to unpack .../dnsmasq_2.76-5+deb9u2_all.deb ...
Unpacking dnsmasq (2.76-5+deb9u2) ...
Setting up dns-root-data (2019031302~deb9u1) ...
Processing triggers for systemd (241-5~bpo9+1) ...
Setting up dnsmasq-base (2.76-5+deb9u2) ...
Processing triggers for dbus (1.10.32-0+deb9u1) ...
Setting up dnsmasq (2.76-5+deb9u2) ...
Created symlink /etc/systemd/system/multi-user.target.wants/dnsmasq.service → /l                                                     ib/systemd/system/dnsmasq.service.
Job for dnsmasq.service failed because the control process exited with error cod                                                     e.
See "systemctl status dnsmasq.service" and "journalctl -xe" for details.
invoke-rc.d: initscript dnsmasq, action "start" failed.
● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
   Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset:                                                      enabled)
   Active: failed (Result: exit-code) since Wed 2021-01-13 22:04:45 PST; 25ms ag                                                     o
  Process: 18061 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SU                                                     CCESS)
  Process: 18063 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status                                                     =2)
      CPU: 41ms
Processing triggers for systemd (241-5~bpo9+1) ...
root@UCK-G2-Plus:~# apt-get install dnsmasq
Reading package lists... Done
Building dependency tree
Reading state information... Done
dnsmasq is already the newest version (2.76-5+deb9u2).
0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.

Ran again, got this:


root@UCK-G2-Plus:~# systemctl status dnsmasq.service
● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
   Loaded: loaded (/lib/systemd/system/dnsmasq.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2021-01-13 22:27:41 PST; 10s ago
  Process: 28892 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS)
  Process: 28894 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=2)
      CPU: 33ms

Jan 13 22:27:41 UCK-G2-Plus systemd[1]: dnsmasq.service: Failed with result 'exit-code'.
Jan 13 22:27:41 UCK-G2-Plus systemd[1]: Failed to start dnsmasq - A lightweight DHCP and caching DNS server.

Ran

apt-get update

Re-ran nano install and it succeeded with this

root@UCK-G2-Plus:~# apt-get install nano
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  spell
The following NEW packages will be installed:
  nano
0 upgraded, 1 newly installed, 0 to remove and 6 not upgraded.
Need to get 474 kB of archives.
After this operation, 2088 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian stretch/main arm64 nano arm64 2.7.4-1 [474 kB]
Fetched 474 kB in 0s (8985 kB/s)
Selecting previously unselected package nano.
(Reading database ... 34656 files and directories currently installed.)
Preparing to unpack .../nano_2.7.4-1_arm64.deb ...
Unpacking nano (2.7.4-1) ...
Setting up nano (2.7.4-1) ...
update-alternatives: using /bin/nano to provide /usr/bin/editor (editor) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/editor.1.gz because associated file /usr/share/man/man1/nano.1.gz (of link group editor) doesn't exist
update-alternatives: using /bin/nano to provide /usr/bin/pico (pico) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/pico.1.gz because associated file /usr/share/man/man1/nano.1.gz (of link group pico) doesn't exist

It would be good if you could point to the exact line or section of the lighttp config that needs to be updated, server.port.

If would be good if you could point to the line to check for the PHP file. I think it is only at the top for $serverName, but I spent some time searching the file for it.

I also wasn't sure if I should leave the IP as 192.168.1.218 or change it.

I tried with leaving it as 192.168.1.218 and that wouldn't resolve the admin interface. I then tried with 192.168.1.2 and that didn't work either.

I then set it to 192.168.1.200/24 and kept 192.168.1.1 as the gateway.

It didn't work until I rebooted the Cloud Key...now pihole admin works....BUT I cannot access the cloud key admin interface. I can SSH into it, but the interface doesn't come up when I hit via browser.

It's late so I'm now factory resetting my cloud key and probably just going to run pihole on a PI.

Jon

@jeroeninhaarlem
Copy link

Anybody any luck updating the distro of the UCK g2 plus to debian 10 or 11 (so to match the glibc_2.28 requirement on the latest pihole-FTL) ?

@wijzijnwolf
Copy link

Workaround for issue with glibc_2.28 requirement: pi-hole/FTL#1420 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment