LH
  • Projects
  • Build

Pi Zero W: Setting a Static IP Address

I don't have a complicated network so I want to put the Pi somewhere where I can easily find it,

  1. sudo vi /etc/dhcpcd.conf (Note the cd at the end of the name)
  2. Add the following lines to the end:
interface wlan0
static ip_address=192.168.4.10/24
static routers=192.168.4.1
static domain_name_servers=192.168.4.2

Explanation

  • I want to use 192.168.4.10 as my static IP. The routers line is almost always the same as the IP but ending in .1.
  • I run Pi-hole on .2 so that gives me the DNS address.
  • If I was using a newer Raspberry Pi OS or Debian then I would probably be editing /etc/network/interfaces instead of dhcpcd.conf

Making the Pi Easy to Find

Configure Pi-hole to resolve the domain name,

  1. Go to Local DNS - DNS Records
  2. Add the Pi Zero to /etc/hosts on my servers
< Back