A quick and clean guide to set up your Raspberry Pi Zero 2 W headlessly with Wi-Fi, SSH, and a static IP β perfect for IoT and embedded projects.
- Raspberry Pi Zero 2 W
- microSD card (β₯8GB)
- Card reader
- Computer with internet access
- Wi-Fi credentials
- Optional: your SSH public key
- Download Pi Imager from raspberrypi.com
- Install and open it
- Choose device:
Raspberry Pi Zero 2 W - Choose OS:
Raspberry Pi OS Lite (64-bit) - Choose storage: your microSD card
Then click on βοΈ Advanced options (Ctrl + Shift + X) and set:
- β
Hostname (e.g.
rpi-zero) - β Username & Password
- β Wi-Fi SSID & password
- β
Enable SSH
- You can also generate a key pair
- Paste your public SSH key
- Click Save and then Write
Once completed: SD card is ready to boot.
- Insert the SD card
- Plug in the Pi
- Wait 1β2 minutes
ssh your-username@your-pi-ip-address
# or (if your router supports mDNS)
ssh [email protected]sudo apt update && sudo apt full-upgrade -y
sudo apt autoremove -y
sudo apt clean-
Launch the network manager UI:
sudo nmtui
-
Then:
- Choose Edit a connection
- Select your Wi-Fi interface
- Go to IPv4 Configuration
- Change method to
Manual - Fill in:
- Address: (e.g.
192.168.1.42/24) - Gateway: your router (e.g.
192.168.1.1)
- Address: (e.g.
- Save and exit
-
Reboot:
sudo reboot
Pi-hole is a powerful network-wide ad blocker β perfect for a headless Raspberry Pi setup!
-
Connect to your Pi:
ssh your-username@your-pi-ip-address
-
Run the official installer:
curl -sSL https://install.pi-hole.net | bash -
Follow the installer steps:
- Choose the correct network interface (usually
wlan0) - Enter upstream DNS providers (Cloudflare, Quad9, etc.)
- Confirm static IP configuration
- Note the web interface address (e.g.
http://192.168.1.42/admin)
- Choose the correct network interface (usually
-
Once installed, access the web UI:
http://your-pi-ip/admin -
Change the admin password if needed:
pihole -a -p
π‘ You can now set your router or devices to use your Piβs IP as their primary DNS server.
Your Pi now:
- Boots without screen or keyboard
- Connects to Wi-Fi on startup
- Allows SSH login (with password or key)
- Uses a static IP on your network
You can now:
- Host lightweight apps
- Run sensors or automations
- Create a custom NAS, VPN, or local server
- Or just have fun tinkering!
Happy Hacking! π€π§