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 192.168.2.25            # Defines the static ip address
gateway 192.168.2.1              # Defines the gateway to use (choose the IP address of your modem)
netmask 255.255.255.0     # Defines the subnet mask

network 192.168.2.0             # Defines the network family
broadcast 192.168.2.255    # 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 .