Raspberry Pi and IP: How-to Set a Static IP Address

Setting up an static IP address on a Raspberry Pi (RPi) is a good idea if the RPi will host any services such as an OpenVPN server, a live-steam Webcam, or any other projects people have come up with.  In addition to this, it is also useful to always know what address the Pi lives at.

Requirements For This Walkthrough

Materials

  1. Local network
  2. Mac
  3. Raspberry Pi  running Raspbian “wheezy”
  4. HDMI Cable (*optional)
  5. Keyboard (*optional)
  6. Mouse (*optional)
  7. Monitor with HDMI input (*optional)

*If the Raspberry Pi is set up as a headless machine, you will not need a monitor, keyboard, or mouse–just another computer, which would be used to access it remotely over the network via SSH.

Downloads

  1. None

Knowledge, Skills, and Abilities

  1. Ability to naviagate throughout a computer OS
  2. Knowledge of basic computer terminology
  3. Ability and confidence to enter commands in the Terminal

Assign A Static IP Address to the Raspberry Pi

Make a Backup of the Existing Network Config File

sudo cp /etc/network/interfaces /etc/network/interfaces.orig

Disable DHCP and Configure a Static IP Address

sudo vi /etc/network/interfaces

Change the line iface eth0 inet dhcp  to:

iface eth0 inet static address 192.168.1.150 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.254

Reboot the device to apply the settings:

sudo reboot