Top Raspberry Pi Uses for Your Homelab

Why Raspberry Pi for Homelab?

The Raspberry Pi is an affordable, low-power computer that’s perfect for:

1. DNS and DHCP Server

Run your entire network’s DNS and DHCP from a Pi:

Install Dnsmasq

sudo apt update
sudo apt install dnsmasq

sudo nano /etc/dnsmasq.conf

# Add:
interface=eth0
dhcp-range=192.168.1.100,192.168.1.200,24h
dhcp-option=option:router,192.168.1.1
dhcp-option=option:dns-server,192.168.1.50

# Add local DNS entries
address=/homelab.local/192.168.1.50
address=/pi.local/192.168.1.50

Block Ads with Pi-hole

Pi-hole provides DNS-level ad blocking for your entire network:

curl -sSL https://install.pi-hole.net | bash

# Access web interface: http://raspberrypi.local/admin

Benefits:

2. Reverse Proxy and Load Balancer

Run Nginx to route traffic to your services:

sudo apt install nginx

sudo nano /etc/nginx/sites-available/default

# Upstream servers
upstream docker_services {
    server 192.168.1.100:3000;  # Gitea
    server 192.168.1.100:3001;  # Grafana
    server 192.168.1.100:8080;  # App
}

server {
    listen 80;
    server_name homelab.local *.homelab.local;

    location / {
        proxy_pass http://docker_services;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }

    # Individual service routing
    location /git/ {
        proxy_pass http://192.168.1.100:3000/;
    }
}

sudo systemctl restart nginx

3. VPN Server

Create a secure tunnel into your homelab with WireGuard:

sudo apt install wireguard wireguard-tools

# Generate keys
wg genkey | tee privatekey | wg pubkey > publickey

# Create config
sudo nano /etc/wireguard/wg0.conf

[Interface]
Address = 10.0.0.1/24
ListenPort = 51820
PrivateKey = <your-private-key>

[Peer]
PublicKey = <client-public-key>
AllowedIPs = 10.0.0.2/32

# Enable
sudo systemctl enable wg-quick@wg0
sudo systemctl start wg-quick@wg0

# Port forward on router
# External: 51820 UDP → Pi: 51820 UDP

4. Network Monitoring and Packet Capture

Use your Pi as a network tap:

sudo apt install tcpdump wireshark-common

# Capture traffic
sudo tcpdump -i eth0 -w capture.pcap

# Monitor bandwidth
sudo apt install nethogs
sudo nethogs eth0

# Real-time traffic analysis
sudo apt install iftop
sudo iftop -i eth0

5. Home Automation Hub

Control smart home devices from a central Pi:

Home Assistant

# Install with Docker
docker run --init -d \
  --name homeassistant \
  --privileged \
  --restart=unless-stopped \
  -e TZ=America/Chicago \
  -v /path/to/homeassistant/config:/config \
  -v /run/dbus:/run/dbus:ro \
  ghcr.io/home-assistant/home-assistant:stable

Integrations:

6. Media Center and Streaming

Transform your Pi into a media server:

Kodi Media Center

sudo apt install kodi

# Or use Docker
docker run -d \
  --name kodi \
  -v /mnt/media:/media \
  -p 8080:8080 \
  linuxserver/kodi-headless

Jellyfin Streaming

docker run -d \
  --name jellyfin \
  -p 8096:8096 \
  -v /mnt/media:/media \
  -v /mnt/config:/config \
  jellyfin/jellyfin

7. Backup Server

Run automated backups using Syncthing or Restic:

Syncthing (Peer-to-Peer Sync)

sudo apt install syncthing

syncthing -generate="/home/pi/.config/syncthing"

# Access UI: http://localhost:8384

Restic (Encrypted Backups)

sudo apt install restic

# Initialize repo
restic -r /mnt/backups init

# Automated backup script
#!/bin/bash
restic -r /mnt/backups backup /home/important
restic -r /mnt/backups forget --keep-daily 7

8. Tor Exit Node (Optional)

Contribute to the Tor network:

sudo apt install tor

sudo nano /etc/tor/torrc

# Enable relay
RelayBandwidthRate 1 MByte  # 1MB/s
RelayBandwidthBurst 2 MByte # 2MB/s

# ContactInfo [email protected]
# Nickname piRelay

sudo systemctl restart tor

9. Weather Station

Collect local weather data with sensors:

#!/usr/bin/env python3
import board
import adafruit_dht
import time

dht_device = adafruit_dht.DHT22(board.D4)

while True:
    try:
        temp = dht_device.temperature
        humidity = dht_device.humidity
        print(f"Temp: {temp:.1f}°C, Humidity: {humidity:.1f}%")
    except RuntimeError as err:
        print(f"Error: {err}")
    time.sleep(2)

10. Network Time Server

Provide precise time to your network:

sudo apt install chrony

sudo nano /etc/chrony/chrony.conf

# Allow network
allow 192.168.1.0/24

# Listen on local IP
bindcmdaddress 192.168.1.50

sudo systemctl restart chrony

# Test from another machine
ntpq -p 192.168.1.50

11. Distributed Computing

Contribute to BOINC projects:

sudo apt install boinc-client boinc-manager

# Or use Docker
docker run -d \
  --name boinc \
  -v /opt/boinc:/var/lib/boinc \
  -p 31416:31416 \
  boinc/client:latest

12. Git Hooks and CI/CD

Run simple CI/CD with custom git hooks:

# Create hook
cat > .git/hooks/post-commit << 'EOF'
#!/bin/bash
echo "Running tests..."
./test.sh
echo "Deploying..."
./deploy.sh
EOF

chmod +x .git/hooks/post-commit

Hardware Recommendations

Use Case Model RAM Storage
DNS/DHCP Pi Zero 2W 512MB 8GB
Light Docker Pi 4 2GB 32GB
Streaming Pi 4 4GB 64GB SSD
Heavy Workload Pi 5 8GB 128GB SSD

Power Efficiency

Reduce power consumption:

# Disable HDMI (saves 40mW)
/usr/bin/tvservice -o

# CPU frequency scaling
echo powersave | sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

# Monitor power usage
vcgencmd measure_volts
vcgencmd get_throttled

Cooling Solutions

Passive Cooling:

Active Cooling:

Troubleshooting

Out of Memory

# Check memory
free -h

# Identify memory hogs
ps aux --sort=-%mem | head

Slow I/O

# Check disk health
df -h
iotop

# Use SSD instead of SD card for heavy workloads

Overheating

# Monitor temperature
watch vcgencmd measure_temp

# Check throttling
vcgencmd get_throttled

Conclusion

Raspberry Pi is remarkably versatile for homelab infrastructure. Start with a single Pi for DNS/DHCP, then expand with additional units for specialized roles.

Resources