Search This Blog

Showing posts with label Raspberry Pi 5. Show all posts
Showing posts with label Raspberry Pi 5. Show all posts

Saturday, November 9, 2024

Raspberry Pi: Pi-hole network wide adblocker

These days our browsing experience can feel very cluttered with ads and it has been like that for many decades. I remember how quiet the internet browsing experience became with the first adblockers. My first addon for this purpose was Adblock Plus, later on I switched over to uBlock Origin. Since I have many devices, including phones it requires me to manage these addons on multiple devices.

It was a few years ago that I heard of Pi-hole and I liked the idea that it would remove ads even from my phone and the games I play there. That it would remove many ads on multiple devices was also a clear selling point.

Over time my understanding of how a network is built has increased and so has my understanding of Raspberry Pi, to the degree that I now felt ready to try create a Pi-hole installation and run it at home.
My current router is locked down from my ISP point of view, so I tested it by redirecting a device to the Pi-hole for testing.

This is a practical guide of how I did it. What I used is: Raspberry Pi 5 (8gb RAM), SD card for the OS, USB-C charger. 

Creating a Pi-hole installation

1. Download Raspberry Pi Imager to flash the OS to your SD card: https://downloads.raspberrypi.org/imager/imager_latest.exe
The operative system image is already included in your Raspberry Pi Imager.

2. Install it by running as admin and run the program after the installation is complete.

3. The GUI of the program let's you choose your Raspberry Pi Model. In my case I took the 5.

4. Choose the OS "Raspberry Pi OS Lite (64-bit)" it has no GUI, so it is all command line.
Pi-hole is compatible with Ubuntu and Debian as well, along with a few other Linux distros.

5. Set options such as SSH-access and the proper wifi-settings so the Raspberry Pi connects to your wifi directly. In the future I plan to use a regular Cat 8, 0.5m ethernet cable or something similar. Put the finished SD card in your Raspberry Pi and start it up, it should then connect to your network.

6. To SSH into it you will need to know the IP address, you get this by looking in your router's list of connected devices. At this stage you also want to lock the IP address, this is because you will lose network connectivity if the router/device won't find the Pi-hole at the given IP in the DNS-settings.

7. It is time to start PowerShell as admin now and install Pi-hole on the headless Raspberry Pi OS Lite. Write SSH and the username@IP. 
Example: SSH admin@192.168.0.14
The password is the same you put in the Raspberry Imager setup for SSH.

8. Once successfully connected you will get a command line available to you.
Run sudo raspi-config to set details for your computer. If you did the settings in the Raspberry Pi Imager correctly, you won't need much config here. 

9. When you have double checked your settings, run sudo curl -sSL https://install.pi-hole.net | bash
This will start the installation process of the actual Pi-hole software.

10. Make sure your Pi has a static IP and then continue through the prompts.
Add Cloudflare as uplink DNS, install the premade list and install the web server.
Enable query logging.
Show everything.
Then let the script work.
Take note of the login password, and access the page using the IP/admin.
Example: 192.168.0.14/admin

Now you have set up your Pi-hole and the next step to actually block ad traffic is to direct it through the device.

Directing traffic through the Pi-hole

Debian 12
Open terminal and write the following commands:
sudo su
nano /etc/resolv.conf

Replace the pre-existing numbers with the IP-address of your Pi-hole
nameserver 8.8.8.8
nameserver 8.8.4.4

Click ctrl+x to save and then confirm with Y.

Windows 11
Press ctrl+r
Write ncpa.cpl and hit enter
Right-click your adapter of choice and take properties
Go into the properties of IPv4
Enter a manual DNS (the IP of your Pi-hole device)




Your router
Since the GUIs of routers differ this is the general guideline.
Logon to your router by browsing to its IP (you can find this gateway IP by doing ipconfig)
Set both primary and secondary DNS addresses to your Pi-hole's IP. Should you set the secondary IP to 1.1.1.1 for example, then it will use the backup DNS if your primary goes down.


Wednesday, January 24, 2024

Raspberry Pi: How to mine Monero

As I was looking for projects for Raspberry Pi I found a video on Youtube that NetworkChuck had posted. One project that I wanted to try for a few days was to mine cryptocurrency on the device, mostly to see if it was possible and learn what the process looks like. While the Pi 5 is the most powerful yet, it does not compare to dedicated mining machines. Simply put, it was interesting to learn but not a profitable venture in the slightest.

Some things to consider are the following:

- You are part of a miner pool, since your hardware might be weak you pool your resources with others and thus share the rewards with the pool

- There is a minimum payment threshold before the currency is sent to your wallet, I mined for 4-5 days straight and did not see any results in the wallet.

Download and install the wallet

I used the basic GUI wallet from Monero, they have a regular installer for Windows.

You install it like any other app, keep in mind that you can avoid the 90gb storage by running it in simple mode. It will take a while to sync the so called blockchain when starting up the wallet, but you avoid having to deal with 90gb of storage. A server somewhere else will be handling this for you, so it is also less anonymous if that is important for you.

Pro tip: Store your account recovery details, passwords etc. safely.

In your wallet you can find your wallet address under the account tab, use this when you start your Monero miner on the Raspberry Pi 5 later.

To install the miner

First I created a folder called monero.

Then went into the folder, ran the following code from the terminal:

sudo apt install git build-essential cmake libuv1-dev libssl-dev libhwloc-dev -y

git clone https://github.com/xmrig/xmrig.git

cd xmrig

mkdir build && cd build

cmake ..

make

To start the miner 

Be in the build folder and enter the command below. You define which pool, which address and what you want to name your miner in case you have several computers mining at the same time.

./xmrig -o gulf.moneroocean.stream:10128 -u <wallet adress goes here> -p pi5

While it is mining you can press H to check your hashrate, higher is better. To see what you have contributed press S. Press C to check your connection, such as your difficulty.

To stop the miner

Ctrl + C, like any other command in a terminal

Friday, January 19, 2024

Raspberry Pi 5: Ubuntu server installation

Prerequisites

To get Ubuntu Server on Raspberry Pi it was actually as easy as just getting the Raspberry Pi imager from the official website.

Install it and run it directly.

Choose device (raspberry pi 5), choose OS (other general-purpose OS -> Ubuntu -> Ubuntu Server)

Choose a device to flash it to.

You will have options to include into your file, these are important. You want to set up wifi, make sure SSH is active and set an admin login, this is used later when you SSH in with PowerShell and when you login to the server with RDP. 

Flash the OS to the SD card, you are now done with the first step.

First time booting Ubuntu Server on Raspberry Pi 5

Put the SD card in the device. Keyboard, mouse and monitor is optional as you can manage the device wirelessly and remotely right away if you performed the options detailed in part 1.

Go to your router and find the IP address of the device, this is used in next step.

Open PowerShell and write ssh admin@192.168.0.X where admin is the user name and X is the last part of the IP address. Confirm with password. SSH is a secure alternative to Telnet.

You will then be taken to an admin prompt that takes linux commands.
You might want to start with the following command:

sudo apt-get update && sudo apt-get upgrade

Make sure to confirm if it prompts you.  

GUI and RDP to Ubuntu Server

The last step was to configure a desktop experience and RDP.

For the deskop experience I simply ran two commands, it would seem that the first one is required.

sudo apt install ubuntu-desktop-minimal

sudo apt-get install xfce4

If prompted, I went with the option lightdm and I restarted all serviced that asked me too, some which also disconnected me from the internet.

For the RDP I first ran the following command:

sudo apt install xrdp -y

Followed by this command that shows you if the installation went alright.

sudo systemctl status xrdp

After that I could RDP using the built-in solution on Windows. Some sources claim you need to fix ssl certs and restart the service, but I could start it right away.

Configure your RDP from your Windows computer

Configure a RDP link on your desktop with the following steps:

1. Open remote desktop connection from your start menu

2. Pick "show options"

3. Computer should be the IP address, user name is the one you entered at the flashing of the image

4. Save as, place it in a good location. Now you can use it and just entering your password.

When you login using RDP you will be greeted with a more familiar desktop experience.


Enjoy!

Raspberry Pi 5: Installing Windows 11

Previously I have had a Raspberry Pi 3b+  and after that I had a Raspberry Pi 4, 8GB, both which I ran Windows 10 on. Times have changed and I got the next generation of this single board computer now. During my research I found out that there now are people that have managed to get Windows 11 Enterprise running on a Raspberry Pi 5. 

Keep in mind that the platform uses ARM processor so that you will get that version of Windows, but it is also supposed to have a built-in system that can simulate the x64 architecture.

One of my experiments that I have planned, is to keep a Minecraft Bedrock server running on my Raspberry Pi 5 that will be installed with Windows 11.

The hardware

For this project I got the following hardware which set me back €178 or 1999 SEK.
The following is a breakdown of the costs converted to EUR.

SanDisk Extreme microSD card (128gb) €27

Kingston DataTraveler Micro Metal (256gb) €22

Raspberry Pi 5 (8gb) €76

Original case with fan €9

Charger €11

Import fee/VAT €33

I bought my Raspberry Pi 5 from The Pi Hut. The purchase experience was relatively smooth, but the transport time was super slow (keep in mind that I had already been waiting quite some time since my pre-purchase). Then the Pi got stuck in transit because I had to pay €30 in import fees as well. It was shipped around 29:th of December and has to this date not yet arrived. Something to keep in mind when you pick your point of purchase in other words.

The installation process

For this experiment, I followed this video to get Windows 11 on Raspberry Pi 5.

You will need UEFI-files (the files used for booting up pretty much) which can be downloaded here
Once downloaded, unzip the archive and place the files on your SD-card. The SD-card needs to be formatted as FAT32, I had trouble flashing it so had to partition it to a part that was smaller than 32GB.

Download the Win11 Enterprise ARM64 image as well from this link, this is what you flash to the USB.
As of January 2024 I used the following settings: Windows 11, latest build, ARM64 architecture, Enterprise edition and English (UK) as language.

You will need the WoR (Windows on Raspberry) program, this contains the script that allows flashing of the iso. Download and then extract contents to a new folder that you name to something intelligible.

Start WoR.exe as admin, go through the guide, make sure to choose Raspberry Pi 3. This is because boot files and main OS are kept separately at this stage. This step took a long time, so make sure to start early.

Put the SD card and the USB into the Raspberry Pi and your peripherals, then boot it up. After that it is pretty much a standard Windows 11 experience, but you are not running an activated version so you will miss out on certain customization.

Verdict

Well, after a lot of struggle I managed to get it running. The experience albeit familiar, it was also extremely slow, you can not do anything practical with this setup at this point. There can be minutes of delay after pressing a key and SFC /scannow and the DISM restorehealth commands can take hours, just to fail. Getting a bedrock server on this setup would not be feasible, neither RDP or Enable-PSRemoting worked.

Perhaps in the future there will be a better experience, but for now my recommendation is to not run with this setup. It was a good experiment.