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
- Local network
- Mac
- Raspberry Pi running Raspbian “wheezy”
- HDMI Cable (*optional)
- Keyboard (*optional)
- Mouse (*optional)
- 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
- None
Knowledge, Skills, and Abilities
- Ability to naviagate throughout a computer OS
- Knowledge of basic computer terminology
- 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