Static IP Address on Raspberry Pi (Raspbian)

Static IP Address on Raspberry Pi (Raspbian)

No doubt this is done to death, so no fluff.

  1. Modify the dhcpcd (DHCP client) configuration file: sudo nano /etc/dhcpcd.conf

  2. If your router is your DNS server, point domain_name_servers to the router’s IP address as shown below. I’ve pointed mine to the Raspberry Pi.

  3. Append values like this, depending on your setup, to /etc/dhcpcd.conf file:

# This will be different if your Pi is connecting via wifi. I'm on ethernet.
interface eth0
# This is the IP address of the Raspberry Pi.
static ip_address=192.168.1.33/24
# IP address of the default gateway. AKA the internal IP address of your router.
static routers=192.168.1.1
# DNS server to use. Normally the IP address of your router. I'm using my Raspberry Pi for DNS.
static domain_name_servers=192.168.1.33
  1. Restart the DHCP client service or restart the Pi altogether:
# New way
sudo systemctl restart dhcpcd

Now see the IP address:


ip addr show eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000     link/ether 33:44:55:66:ee:dd brd ff:ff:ff:ff:ff:ff     inet 192.168.1.33/24 brd 192.168.1.255 scope global eth0        valid_lft forever preferred_lft forever