Create a Static IP For Raspberry Pi


Making a Static IP With Raspberry Pi

This tutorial explains how to create a static ip address for your Raspberry Pi.

The file for which you will edit is called 'interfaces' It is located within the /etc/network folder.

Why do I want to do this? There are many reasons why you may want to create a static ip address for a Raspberry Pi. Some of the reasons could be that you want to run a web site on a Raspberry Pi or run a cluster of Raspberry Pis. If you attempt to so this with dhcp, dynamic changing ips will make port forwarding and other setups a hassle that will need ongoing changes. Also, if you have several customized Raspberry Pis, you may like to ssh into any one of them with known ips in order to be efficient.

To access the interfaces file,

1) Open the file.

 root# cd /etc/network root# vi interfaces 
2) Alter the code to resemble the code displayed below. The top block of code shows a static ip connection while the second block shows code for a wireless connection and Ethernet connection using DHCP. By default, the second block of code is installed with a Raspian distro.  
 auto eth0 iface eth0 inet static address 192.168.0.118 netmask 255.255.255.0 gateway 192.168.0.1