Give your Raspberry Pi a fixed IP address

Having a fixed (or static) IP address on your Raspberry Pi, comes in handy if you want to access your Raspberry Pi from the internet (for a how to about port forwarding, read this article). As you might want to use ownCloud for instance.

You can give your Raspberry Pi a fixed IP address by editting the network interfaces file.

But first, we are making a backup of the old configuration!

sudo cp /etc/network/interfaces /etc/network/interfaces.bak


Next thing is, editing the network interfaces file:

sudo nano /etc/network/interfaces


Although the IP address you want to use might be different, make your /etc/network/interfaces look like this:

auto eth0                                     # The loopback interface

iface eth0 inet static              # Tells your Raspberry Pi to use a static IP address

address            # Defines the static ip address
gateway              # Defines the gateway to use (choose the IP address of your modem)
netmask     # Defines the subnet mask

network             # Defines the network family
broadcast    # Defines the network family


You can save the adjustments you made to your /etc/network/interfaces file by pressing ctrl o

Press ctrl x to exit


After saving your new settings, you need to activate them by restarting your network components:

sudo /etc/init.d/networking restart


Suggestions for improving this article are welcome, please let me know and drop me a line .