Raspberry Pi Kernel/Firmware Upgrade/Downgrade

I’ve been looking at a problem with one of my Raspberry Pi projects freezing every now and again.  I have a suspicion from reading recent posts that it could be kernel related.  I found a good article here which also links to the rpi-update utility on Github here

The great thing here is the utility allows a downgrade.

I can also never remember how to find the current kernel version so, for me, this is what I use:

Unattended Upgrades on my Raspberry Pi’s

I can never quite remember how I like my unattended upgrades configured on my Raspberry Pi’s so I’m just popping it here.  It should work for all versions!

 

To check it:

Logs can be found at:

 

CTF Resources

This is really just a place for me to remind myself of useful resources I’ve used when undertaking CTF challenges 🙂

Cryptography Resources:

Dcode – the essential site for deciphering and decoding messages
Cryptii – Modular online encoding, encryption and conversion tool
quipqiup – a fast and automated cryptogram solver

Network Resources:

netcat (nc) -a feature-rich network debugging and investigation tool

BBC micro:bit expoloration

On a whim I nipped out and bought the only BBC micro:bit in stock at PB Tech in New Plymouth as I was curious to have a play and see where it might fit in between Raspberry Pi’s and Arduino’s for teaching kids.

I thought turning it into a simple digital watch would be a fun place to start learning so, below is the result.

The virtual micro:bits, below, are interactive so click on the ‘shake’ button to simulate shaking it in real life to display the time.

The code can also be found in my Github repo, here.  It will be the most recent version if I have made changes and haven’t had time, or have forgotten, to update this post 🙂

Enjoy!

Pi-hole in a Docker Container on a Raspberry Pi

While I was disappearing down a rabbit hole investigating unbound as a DNS Privacy server, I came across Pi-Hole – A black hole for Internet advertisements.

I’ve always used uBlock Origin for ad blocking but that is a per client thing which is a bit of a hassle.

Pi-hole provides ad blocking for all clients on the network, seamlessly.  I just configure DNS on each client, via DHCP, to point towards the Pi-Hole server.

Obviously, I love Docker so it’s in a Docker Container on a Raspberry Pi.

Currently, I’ve sacrificed DNS privacy but I’ll work on that later in terms of getting Pi-hole to send all DNS queries through my own DNS server.

This is how I implemented it.  Obviously, these aren’t detailed instructions but more of a reference to jog my memory if I need it!

********************
Note: Substitute the IP address of the host that the Container is running on for ${IP} and ${IPv6}
********************

 

 

Raspberry Pi Docker Container to send all LAN DNS requests to Cloudflare’s 1.1.1.1 DNS over TLS

I wanted to implement this on a Raspberry Pi that I have running Docker.  However, I wasn’t able to find an image in Docker Hub for the ARM architecture that the Raspberry Pi uses so I made my own based on the x86-64 image, here.

  • Place the Dockerfile and unbound.conf in the same directory.
  • Docker file:

  • unbound.conf:

 

  • Build the Docker image:

 

  • Start a container as a daemon from the above image:

 

  • Configure all clients to point to the IP address of the Docker Host for DNS.

EDUP 802.11n Mini Wi-Fi Adapter Sleeping

 

I bought some EDUP 802.11 N Mini Wi-Fi Adapters from China.  They’re cheap and do a fine job plugged into my Raspberry Pi’s.

However, by default, they always go to sleep which makes it difficult to connect to them via ssh etc.  To fix this, here’s what I did:

To identify the USB WLAN Adapter I did the following:

Then:

From that I was able to derive that the WLAN adapter was using the rtl8192cu drivers.

A bit of Googling later, I was able to disable power management on the Wifi adapter, like this:

Reboot…

Run:

It should return 0 if the power management is off.

Bask in the glory of your WiFi adapter that stays up all the time 🙂

Deploy Watchtower in Docker

Watchtower is an application that will monitor your running Docker containers and watch for changes to the images that those containers were originally started from. If watchtower detects that an image has changed, it will automatically restart the container using the new image.

  • A 16 megabyte limit is set on the container, in this instance.
  • I’ve added a hostname for this container because Watchtower sends emails with the hostname of the Watchtower Docker container in the subject line.  By setting my own hostname instead of the default Docker generated hostname, I can glance at the email and see which of my hosts containers have just been updated.
  • Email notifications are configured using the container environment variables using the -e flags.  These can be omitted if you don’t want any notifications.

Deploy Portainer in Docker

Portainer is an Open-Source lightweight Management UI which allows you to easily manage your Docker Hosts or Swarm Clusters

  • Port 9000 of the container is published to the host
  • A 16 megabyte limit is set on the container, in this instance.
  • Data is persisted in a named volume called ‘portainer_data’

The container can also be deployed using the more explicit –mount flag which became available for standalone containers in Docker 17.06.

Install Docker and Compose on Ubuntu 16.04 LTS

If you plan on using the –memory flag when creating containers, you may need to enable memory and swap accounting in the Kernel.

  1. Log into the Ubuntu host as a user with sudo privileges.
  2. Edit the /etc/default/grub file. Add or edit the GRUB_CMDLINE_LINUX line to add the following two key-value pairs:
  3. Save and close the file.
  4. Update GRUB.

    If your GRUB configuration file has incorrect syntax, an error occurs. In this case, repeat steps 3 and 4.

    The changes take effect when the system is rebooted.

More detailed information can be found in the Docker Post-Installation Steps for Linux.