5

How to give your Raspberry Pi a Static IP Address - UPDATE– The Pi Hut

 3 years ago
source link: https://thepihut.com/blogs/raspberry-pi-tutorials/how-to-give-your-raspberry-pi-a-static-ip-address-update
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How to give your Raspberry Pi a Static IP Address - UPDATE

Jul 16, 2014
How to give your Raspberry Pi a Static IP Address
Share

This tutorial will show you how to set a static IP address on your Pi with the release of Raspbian Jessie. At the time of writing, the latest release date of Raspbian Jessie is 18-03-2016 with Kernal version 4.1.

I recommend doing this on a fresh install, however if you have attempted to set a static IP address already, you may have found yourself editing the interfaces file (/etc/network/interfaces). I hope you made a backup, because you’ll need to remove any edits you have made, and revert it back to its original state!

The following is done over SSH, but you could just as well plug your Pi into a monitor, hook up a keyboard and mouse, and use the Terminal instead.

Start by editing the dhcpcd.conf file

sudo nano /etc/dhcpcd.conf

dhcpcd.conf_1024x1024.jpg?v=1561725914

Scroll all the way to the bottom of the file and add one, or both of the following snippets. Depending on whether you want to set a static IP address for a wired connection or a wireless connection eth0 = wired, wlan0 = wireless.

You’ll need to edit the numbers in the snippet so they match your network configuration.

interface eth0

static ip_address=192.168.0.10/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1

interface wlan0

static ip_address=192.168.0.200/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1

interface = This defines which network interface you are setting the configuration for.
static ip_address = This is the IP address that you want to set your device to. (Make sure you leave the /24 at the end)
static routers = This is the IP address of your gateway (probably the IP address or your router)
static domain_name_servers = This is the IP address of your DNS (probably the IP address of your router). You can add multiple IP addresses here separated with a single space.

To exit the editor, press ctrl+x
To save your changes press the letter “Y” then hit enter

dhcpcd.conf_1024x1024.jpg?v=1561725914

Now all you need to do is reboot, and everything should be set!

reboot

You can double check by typing

ifconfig

And checking the interfaces IP address

ip-set_1024x1024.jpg?v=1561725973

Share

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK