Skip to content

Configs and full guide for running homelab on Raspberry Pi 5

Notifications You must be signed in to change notification settings

vasujain275/homelab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OS Installation

  • Use Rapsberry pi Imager to burn os to sd card
  • Make sure to install Raspberry Pi OS Lite 64-bit
  • Username - pi

Setup ssh keys

  • Go to ~/.shh folder on your pc and copy the public ssh key you want to use
  • Ssh to raspberrypi using password, then run the following commands
mkdir .ssh
cd .ssh
touch authorized_keys
nano authorized_keys  

First Update

sudo apt update && sudo apt upgrade

Docker Install

Uninstall any conflicting versions

Run the following command to uninstall all conflicting packages:

for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done

Installing Docker through apt

  1. Set up Docker's apt repository.
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
  1. Install the Docker packages.
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
  1. Added User to Docker Group -
sudo groupadd docker
sudo usermod -aG docker $USER

Refrence - https://docs.docker.com/engine/install/debian/

Configure mount-hdd.service before proceeding

Static IP Config

  1. Check for interface name
nmcli con show

Copy the name of wifi type. 2. Backup original Settings

sudo nmcli con show "Name that you copied" | tee original_network_settings.txt
  1. Add the prefered static ip
sudo nmcli con mod "Name that you copied" ipv4.method manual ipv4.addr 192.168.1.50/24

sudo nmcli con mod "Name that you copied" ipv4.addr 192.168.1.50/24 ipv4.gateway 192.168.1.1 ipv4.dns 1.1.1.1 ipv4.method manual

Refrence - https://nitratine.net/blog/post/how-to-set-a-static-ip-address-on-a-raspberry-pi-5/

ZSH4HUMANS Setup

if command -v curl >/dev/null 2>&1; then
  sh -c "$(curl -fsSL https://raw.githubusercontent.com/romkatv/zsh4humans/v5/install)"
else
  sh -c "$(wget -O- https://raw.githubusercontent.com/romkatv/zsh4humans/v5/install)"
fi

Refrence - https://github.com/romkatv/zsh4humans

Setting Up New Github SSH Keys

Generating a new SSH Key

ssh-keygen -t ed25519 -C "[email protected]"

Use homelab_gh for key name.

Adding your SSH key to the ssh-agent

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/homelab_gh

Refrences - Ref 1

Adding a new SSH key to your GitHub account

Follow this guide - https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account

Tailscale Setup -

Install Tailscale -

curl -fsSL https://tailscale.com/install.sh | sh

Login -

sudo tailscale login

Subnets Setup -

  1. To enable local network access / exit node from raspberry pi -
echo 'net.ipv4.ip_forward = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf
echo 'net.ipv6.conf.all.forwarding = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf
sudo sysctl -p /etc/sysctl.d/99-tailscale.conf
  1. Now, Enable subnet routes from the admin console
  2. Now run the following command on the pi -
sudo tailscale up --advertise-routes=192.168.0.0/24,192.168.1.0/24 --advertise-exit-node

Subnets Optimisation for Ethernet

NETDEV=$(ip route show 0/0 | cut -f5 -d' ')
sudo ethtool -K $NETDEV rx-udp-gro-forwarding on rx-gro-list off

Enable on each boot

Changes made via ethtool are not persistent and will be lost after the machine shuts down. On Linux distributions using networkd-dispatcher (which you can verify with systemctl is-enabled networkd-dispatcher), copy and run the following commands to create a script that will configure these settings on each boot.

printf '#!/bin/sh\n\nethtool -K %s rx-udp-gro-forwarding on rx-gro-list off \n' "$(ip route show 0/0 | cut -f5 -d" ")" | sudo tee /etc/networkd-dispatcher/routable.d/50-tailscale
sudo chmod 755 /etc/networkd-dispatcher/routable.d/50-tailscale

Test the created script to ensure it runs successfully on your machine:

sudo /etc/networkd-dispatcher/routable.d/50-tailscale
test $? -eq 0 || echo 'An error occurred.'

Ref - https://tailscale.com/kb/1019/subnets , https://tailscale.com/kb/1320/performance-best-practices

Cloudflare Tunnels

Go to Cloudflare Dashboard > Zero Trust > Networks > Tunnels then configure.

Synchting Setup

Install Syncthing

sudo mkdir -p /etc/apt/keyrings
sudo curl -L -o /etc/apt/keyrings/syncthing-archive-keyring.gpg https://syncthing.net/release-key.gpg
echo "deb [signed-by=/etc/apt/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list

# Update and install syncthing:
sudo apt-get update
sudo apt-get install syncthing

Refrence - https://apt.syncthing.net/

Enable and Start the Service

sudo systemctl enable [email protected]
sudo systemctl start [email protected]

About

Configs and full guide for running homelab on Raspberry Pi 5

Resources

Stars

Watchers

Forks

Languages