Electrical-Forenics Home ray@RayFranco.com                       601.529.7473

   Updated 7/13/2025

   © Dr. Ray Franco, PhD, PE  :  2006-2025

Raspberry Pi Hardening

Imager Telemetry

To disable imager telemetry, open the imager, and hit "Ctl-Shift-X" to reviel the hidden dialog box. Click on options tab, and uncheck the telemetry radio button.

Surprisingly, this is not global. You have do this for each user.

IPv6

To disable IPv6, add the following to /firmware/boot/cmdline.txt [1][2]:

ipv6.disable=1

Alternately, the Debian way is to add the following to etc/sysctl.conf [1][2]

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

If you disable ipv6 then in /etc/wayvnc/config you "must" change the line "address=::" to "address=0.0.0.0" [3]. This applies even if you or not using vnc. Without doing tis your Pi will not shutdown correctly.

Radios

To disable WiFi and/or Bluetooth on the Raspberry Pi, add the following at the end of /boot/firmware/config.txt [4][5][6]:

dtoverlay=disable-wifi
dtoverlay=disable-bt

Mulitcast Domain Name Server (mDNS)

If you do not need mDNS, remove "avahi" [7]:

sudo apt remove --purge avahi-daemon
sudo apt autoremove --purge

Warning if you need to communicte with an Apple device via Bonjour then do not remove the avahi-daemon.

Network Time Protocol (NTP)

You can disable ntp with the following command:[8][9]

sudo timedatectl set-ntp false

However, I believe the current version of the Advance Package Tool (APT) uses the ntp to synchronize the clock in order to update packages.

Network Filter Tables (nftables)

The best way to harden a Raspberry Pi is with nftables, but first you have to enable them:

sudo systemctl enable nftables

Then you write tables that contains "chains" and the chains contain "rules". This is behond the scope of this page, but these is a sample nftable file at the end of this page.

References

  1. How to Really Disable IPv6 on Rspberry Pi
  2. Linux FOSS - How to Disable IPv6 on Debian 12
  3. Raspberry Pi Forum - Is WayVNC Fixed?
  4. Raspberry Pi Forum - Pi 5 Bookworm - Disable WiFi and Bluetooth Audio
  5. Raspberry Pi Forum - How to Disable Onboard Wlan0 and Exlusive use Dongle wlan1 and wlan3
  6. stack exchange - disable wifi (wlan0) on pi 3
  7. Disable or remove unneeded services and software to help keep your Raspberry Pi online
  8. Raspberry Pi Forum - How to Disable System Time Update
  9. Linux manual page - imedatectl(1_

Do Not Trust Google

To remove Google's Chromium browser:

sudo apt remove --purge chromium

Ironicaly this leaves behind chromium-common and other packages. To remove them:

sudo apt autoremove --purge

Locking Down Firefox

In the search box type: about:config

Click, accept the risk and continue

Search for an toggle the following to false:

network.captive-portal-service-enabled false
network.connectivity-service-enabled false
media.peerconnectection.enabled false
app.normandy.enabled false

Unforntuately, you need to this for every user.

References

  1. How to stop Firefox from making automatic connections

NordVPN

To revent NordVPN from collecting data:

nordvpn set analytics disabled

All your dns quiries should go through NordVPN's secure tunnel, but just in case, you can manually set your dns servers to NordVPN DNS servers.

References

  1. NordVPN Support - Change your DNS servers on Linux with NordVPN

Bluetooth - Meta

According to Rob Braxman Tech, Meta (Facebook), collects MAC addresses vi bluetooth [1].

To disable bluetooth services:

sudo systemctl disable bluetooth.services

You can also prevent Bluetooth modules from loading by adding the following to /etc/modprobe.d/blacklist.conf


blacklist bluetooth
blacklist btusb
             

References

  1. YouTUbe - Rob Braxman Tech - How to be Invisible on the Internet. 10 Identifiers to Eliminate
  2. TecMint - How to Disable Bluetooth at Linux Startup

Sample nftable file

#!/usr/bin/nft -f

# lockdown4a.nft

# Last Updated on 7/1i/2025 
#
# Add use NordVPN DNS Servers 
#
# The NetBIOS may be need for Samba File Sharring but I want to block here!


table ip fb {

set update_debian { 
	typeof ip daddr 
	elements = { 151.101.2.132, 151.101.66.132, 151.101.130.132, 
                     151.101.194.132, 146.75.94.132, 199.232.66.132, 
                     151.101.46.132, 146.75.126.132, 199.232.90.132, 
                     151.101.18.132, 146.75.106.132, 151.101.22.132,
                     151.101.114.132, 199.232.98.132, 199.232.38.132,
                     146.75.42.132, 151.101.162.132, 151.101.202.132,
                     146.75.78.132, 151.101.134.132, 151.101.14.132,
                     151.101.74.132
                   }
}

set update_pi { 
	typeof ip daddr 
	elements = { 176.126.240.167, 176.126.243.6, 46.235.231.151,
                     46.235.231.111, 93.93.135.118, 93.93.135.141,
                     93.93.135.117, 176.126.240.86, 176.126.240.84,
                     46.235.231.145, 176.126.243.5, 176.126.243.3
                    }
}

set update_nordvpn { 
	typeof ip daddr 
	elements = { 104.19.159.190, 104.16.208.203 }
}



set input_dropped_udp { typeof ip saddr . udp sport . ip daddr . udp dport; }
set input_dropped_tcp { typeof ip saddr . tcp sport . ip daddr . tcp dport; }

set input_dropped_dropbox  { typeof ip saddr . udp sport . ip daddr . udp dport; }
set input_dropped_scansnap { typeof ip saddr . udp sport . ip daddr . udp dport; }
set input_dropped_mDNS { typeof ip saddr . udp sport . ip daddr . udp dport; }

set input_samba_NetBIOS { typeof ip saddr . udp sport . ip daddr . udp dport; }

set  output_dropped_ntp { typeof ip saddr . udp sport . ip daddr . udp dport; }
 
set  output_dropped_mDNS { typeof ip saddr . udp sport . ip daddr . udp dport; }

set dropped_tcp_http  { typeof ip saddr . tcp sport . ip daddr . tcp dport; }
set dropped_udp_http  { typeof ip saddr . udp sport . ip daddr . udp dport; }
set dropped_input_tcp { typeof ip saddr . tcp sport . ip daddr . tcp dport; }


set output_https_tcp  { typeof ip saddr . tcp sport . ip daddr . tcp dport; }


set unknown_protocol { typeof ip saddr . tcp sport . ip daddr . tcp dport; }
set unknown_tcp { typeof ip saddr . tcp sport . ip daddr . tcp dport; }

    chain INPUT {
        type filter hook input priority filter; policy drop;
        meta iif lo counter accept
        # allow vnc ???

        ct state established,related counter accept
        ct state invalid counter drop

        tcp dport {5800, 5900, 5901 } counter accept
        udp dport {5800, 5900, 5901 } counter accept
        tcp sport {5800, 5900, 5901 } counter accept
        udp sport {5800, 5900, 5901 } counter accept

        udp dport 17500 counter drop
        udp dport 52217 counter drop
        udp dport 5353  add @input_dropped_mDNS { ip saddr . udp sport . ip daddr . udp dport } counter drop
        udp dport {137,138} add @input_samba_NetBIOS { ip saddr . udp sport . ip daddr . udp dport } counter accept
        ip protocol tcp add @input_dropped_tcp { ip saddr . tcp sport . ip daddr . tcp dport } counter drop
        ip protocol udp add @input_dropped_udp { ip saddr . udp sport . ip daddr . udp dport } counter drop
        ip protocol icmp counter drop
        
        counter drop
     } # Close INPUT chain

     chain OUTPUT {
        type filter hook output priority filter; policy drop;

# Accept List
        # Debian Updates 
        tcp dport 80 ip daddr @update_debian counter accept

        # Raspberry Pi Updates
        tcp dport 80 ip daddr @update_pi counter accept

        # NordVPN Updates 
         tcp dport 80 ip daddr @update_nordvpn counter accept

        # Nordvpn-NordLynx 
        udp dport 51820 counter accept
        tcp dport 8884 counter accept # Require but no documented

        # NordVPN OpenVPN
        udp dport 1194 counter accept
        udp sport 1194 counter accept

        # Network Time Protocol
        udp dport 123 counter accept

        # Secure Shell Protocol
        tcp dport 22 counter accept
        udp dport 22 counter accept

       # NetBIOS 
       tcp dport 139 counter accept

       # SMB Protocol
       tcp dport 445 counter accept

       # VNC Protocol
       tcp dport {5800, 5900, 5901 } counter accept
       udp dport {5800, 5900, 5901 } counter accept
#       tcp sport {5800, 5900, 5901 } counter accept
#       udp sport {5800, 5900, 5901 } counter accept

        # Domain Name Servers 
        udp dport 53 counter accept
        tcp dport 53 counter accept 
        

        # Should ct state new be added to the https below?
        #
        # accept https
        tcp dport 443 counter add @output_https_tcp \
            { ip saddr . tcp sport . ip daddr . tcp dport } accept
        udp dport 443 counter accept

        # Local Traffic
        oif lo counter accept
        iif lo counter accept

        # Establishd Traffic
        ct state established, related counter accept

# Dropped List:
        # ICMP Protocol
        ip protocol icmp counter accept

        # Multicast DNS
        udp dport 5353 add @output_dropped_mDNS \
            {ip saddr . udp sport . ip daddr . udp dport} \
            counter accept 
 
        # http traffic
        tcp dport 80 add @dropped_tcp_http \
             { ip saddr . tcp sport . ip daddr . tcp dport } \
             counter drop
         udp dport 80 add @dropped_udp_http \
             { ip saddr . udp sport . ip daddr . udp dport } \
         counter drop

         # Unknown https traffic
        udp dport {1-1023} counter drop
        udp dport {1024-65535} counter drop

        tcp dport {1-1023} add @unknown_tcp {ip saddr . tcp sport . ip daddr . tcp dport } counter drop
        tcp dport {1024-65535} add @unknown_protocol {ip saddr . tcp sport . ip daddr . tcp dport} counter drop

        # Everything Else
        counter drop
      } # close OUPUT chain
}