ICT
 
 
home search Contact
Lmarsden is a non-profit information site

How to give your Raspberry Pi a Static IP Address

 

The following is done in terminal, 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 accessing terminal:

Start by checking the IP onfiguration of your RPi:

ifconfig

or

ifconfig eth0

 

To set a static IP address you will need to ask your teacher to allocate you an IP address on the network. This acts much the same as a phone number and there can only be one on the network:

 

Your teacher will give you a number like: 172.18.0.2xx

 

To set this IP address you will ned to start by editing the dhcpcd.conf file:

sudo nano /etc/dhcpcd.conf

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=172.18.0.150/24
static routers=172.180.0.250
static domain_name_servers=172.180.0.250

 

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 - you can get this from your teacher. (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) - to be updated to the schools.
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 be updated to the schools.

 

To exit the editor, press ctrl+x

To save your changes press the letter “Y” then hit enter

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

sudo reboot

You can double check by typing

ifconfig

or

ifconfig eth0

 

Notes:

#School
#interface eth0
#static ip_address=172.18.0.200/24
#static routers=172.18.0.254
#static domain_name_servers=172.18.0.250

#Home
interface eth0
static ip_address=192.168.0.200/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1

 

 

 

Focus Point

 

 

Information