Introduction: Configuring the Raspberry Pi Ethernet Port With a Static IP Address

Picture of Configuring the Raspberry Pi Ethernet Port With a Static IP Address

This Instructable will show how to quickly configure the Raspberry Pi ethernet port with a static IP address. This makes it much easier to log into it remotely because you will always know what the IP address is of your Pi.


This is a very basic Instructable for PC/Windows users or other not familar with Linux.

This Instructable has been updated (3/3/2017) for the new PIXEL version of Raspian. The network configuration has changed to use the dhcpcd.config file vs the interfaces file.


Hardware Required:
Raspberry Pi
Network switch
Ethernet Cables

Optional:
Wi-Pi WiFi wireless USB dongle

Step 1: Review Current Network Settings

Picture of Review Current Network Settings

From the command prompt or LXTerminal:

Type the command "ifconfig"

This command will display the current network settings.

Step 2: Backup the Current Network Configuration

Picture of Backup the Current Network Configuration

it is a good idea to make a backup of the dhcpdc.conf file if you are new to linux:

sudo cp /etc/dhcpcd.conf /etc/dhcdcp.backup

This will allow you to roll back any changes you make.

Step 3: Modify the Network Settings

Picture of Modify the Network Settings

To edit the network setting you must edit the dhcpcd.conf file to set up a static IP address.

The following command can be used to load the file into an editor update the file:

sudo nano /etc/dhcpcd.conf

Place these lines at the top of the file too set the Ethernet port (eth0) to a static IP address:

interface eth0

static ip_address=10.11.44.124/24

static routers=10.11.44.1

static domain_name_servers=172.16.33.85

Set the address (ip_address) to the IP address you want the Raspberry Pi to occupy.

Set the routers value to the gateway address

If available, set to domain_name_servers to you name servers


Once the file has been updated, use ctrl x to save and exit.

Step 4: Restart the Raspberry Pi

Picture of Restart the Raspberry Pi

Once the dhcpcd file has been updated, you must restart the Raspberry Pi for the changes to take effect.

Used to following command to restart:

sudo reboot

Step 5: Test the New Network Setup

Picture of Test the New Network Setup

Use the "ping" command to confirm that the Raspberry Pi is on the network and talking to another computer also on the network.

If you have trouble pinging other computers on the network work, check the following:

1. Confirm that the ethernet cable is firmly connected to the Raspberry Pi and network switch.
2. Confirm that the ip address, mask and gateway are correct.
3. If pinging a Windows machine, sometimes security setting prevent responding to a ping request.

Comments

TerryAris (author)2016-11-29

I am trying this system, but each time I try to ssh into my Apple, I get a request for a password that I cannot satisfy. I have tried both pi passwords, my computer password and I have recreated my ssh password, all to no avail. Do you have any suggestions as to what I can do next?

Thank-you for any help.

DavideM27 (author)2016-02-24

Thank you very very much

amackenzie5 (author)2015-01-05

I'd suggest an alternative, where instead of assigning it a static IP (who knows if that's taken by another device), you instead configure your router to always hand it the same IP (from DHCP config) based on it's Mac address.

CraigMarston (author)amackenzie52015-08-21

I agree with you amackenzie5 — I had already set this up so it also meant that I could miss out a large chunk of this instructable. I just need to make a list of IP numbers as I make more of them static..!

CraigMarston (author)2015-08-21

I found this very easy to do, having previously failed with a different set of instructions! Thanks :-)

svaidhun (author)2014-06-03

Thanks for this awesome tutorial. Works smooth.

I connected my Pi to the router. I'm able to access it if I connect my PC via ethernet to my router.

But it doesn't work, if I connect my PC via wifi :( Any help?

ZRob314 (author)svaidhun2014-06-03

Can you ping the PC from the Pi or Pi from the PC when
using Wifi on both? If not, can you
confirm that they are on the same network?
(First three octets of the IP address are the same for example 192.168.1.XXX)

meceduran (author)ZRob3142014-12-09

If I am using the a wifi-dongle on my raspberry pi, how would you go about getting a static IP address?

eltel (author)2014-10-07

A really good tutorial for a noob, thanks a mil.

jdevs (author)2014-08-13

Thanks for the super easy setup, this was by far the quickest way to get my Pi on the network (and now connect to my Pi via putty from Windows). Worked like a charm.

MrWareWolf (author)2013-06-23

This could all be pared down to only 'step 6'..

(Most people already have working ethernet, which helps their pi to update properly, access content, and access the local network content as well..)

Alternately, it could be broken into two separate things: A) Setup your ethernet port properly on your pi. B) Install XRDP on your pi, for remote control from Windows/Linux desktops.

Great content any way you cut it.

Thanks!

agulesin (author)MrWareWolf2013-07-31

Good job it isn't, for those newbies like myself who haven't even got used to the Raspberry's system as yet... ;-)

rbahlman1 (author)2013-06-09

Solved my keyboard problem thanks .

AndyGadget (author)2013-05-27

Useful - I had no idea you could use remote desktop to talk to the Pi.
I've been using a SSH connection with PuTTY. I had a play with VNC for the graphical desktop but it was a bit clunky. (I'm getting something together for the LiveBots site.)

AndyGadget (author)AndyGadget2013-05-29

I've now done this, but in another way by installing XRDP (sudo apt-get install xrdp) which installs a RDP compatible server to the Pi. Much nicer than VNC.

ZRob314 (author)AndyGadget2013-05-30

I will add this step to the Instructable. XRDP is what I always use, but you are correct it must be installed first.