How to give your Raspberry PI a Static IP
Bradly S

How to give your Raspberry Pi a Static IP Address

This small guide is mostly to accompany my other guide on how to turn your Raspberry Pi into an Alexa Smart Device, however, this may come of use to you if you’re falling upon this blog post!

I’ll try and make this as easy as possible to follow, generally speaking, the configuration for this will be the same across all Raspberry Pi versions in the future, but I will update this should I need to in the future.

To start with, you’ll want to open “Terminal”, or SSH (On a remote computer). Run the following command:

sudo nano /etc/dhcpcd.conf

From here, scroll to the bottom (Hold down on the Keyboard). The last line may say “nohook lookup-hostname”.

Copy and Paste the following, changing the details of the bolded numbers to the static IP you wish to keep:

interface eth0
static ip_address=192.168.0.2/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1
interface wlan0
static ip_address=192.168.0.2/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1

The routers= and domain_name_servers= would both equal the IP of your router if you live at home. Otherwise, the name_servers is the IP of your DNS records and the routers are the IP of your gateway.
You will need to keep the /24 at the end of the ip_address.

From here, press ctrl + x and then press Y to save changes. Simply reboot your Pi after and your Static IP will be done!

If you wish to check this, open Terminal again and type the following:

ifconfig
0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Smarthomebit.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com. This site also participates in other affiliate programs and is compensated for referring traffic and business to these companies.

Want to get more out of your Smart Home?

Get Started Today with my 5-Day Smart Home Bootcamp!

0
Would love your thoughts, please comment.x
()
x