How to set a Static IP for Raspberry Pi

Hi all, the first thing you should probably consider when setting up a gaming server is how to set a Static IP address for your Raspberry Pi. Let’s get into it.

Step One: SSH into your RP and find the current IP address.

ssh [email protected]

hostname -I

Screen Shot 2021-12-10 at 6.13.24 PM

Step Two: Find your router’s gateway IP address.

ip r | grep default

Step Three: Find your router’s DNS IP Address

sudo nano /etc/resolv.conf

Step Four: Add Static IP Settings.
Now you should have all the info you need to make your Static IP. Next, we’ll edit the dhcp.conf file.

sudo nano /etc/dhcpcd.conf

Scroll to the bottom and put in the information you just gathered, along with your preferences.

interface = wlan or eth cable
static ip_address = whatever you want your new IP to be. I recommend something between
static routers = your gateway IP address
static domain_name_servers = your static DNS address

This is just an example of what you could do, make it to your preferences and make sure it matches the info you collected above.

interface eth0
static ip_address=
static routers=
static domain_name_servers=

Make sure to do ctrl+x to save changes, press y for yes and press enter to exit.

Step Five: Reboot the RP to enact changes.

sudo reboot

Step Six: Check your hostname to see the effects have taken place.

hostname -I

You should now see the static IP you set up in your dhcp.conf file. Congrats! You’ve set up a Static IP for Raspberry Pi!


This is great, thanks for posting! One thing to note is that not all routers assign the subnet Sometimes the range will be or something else entirely. However it will almost always start with “192.168.a.b”.

Great point, thanks for the comment!

Sometimes 10.0.x.x will be used

sometimes it could also be 172.29.x.x

Those are usually public IP’s. I’ve only seen 192.168.x.x or 10.x.x.x by default.