Static IP for the Raspberry Pi

Home routers are commonly DHCP meaning that they will assign an IP randomly from an available set to each connected device. This can make things difficult if we need to login remotely (ssh) on our RPi. Thus, we need to set a static/fixed ip for the Pi.

There are two ways to go about this, either setup the router to reserve an IP by the device MAC address or edit the network interface in the RPi to have a fixed IP. We’ll do the latter.

From the top menu, go to Preferences > Add/Remove Software

In the search box found in the top left corner, search for ‘wicd’. Once the results appear, tick the one which is titled ‘wired and wireless network manager — metapackage’. Now click Apply button followed by the OK button. This might take a couple of minutes. Once done, it will look like the screen below. You can close this window.

Once the WICD Network Manager is installed, open it from top menu > Internet > Wicd Network Manager

WICD will show you the current connected network:

Now also open a terminal window side by side (4th icon on the top bar). Also, click on Properties button of the connected wires network.

In the terminal run the following commands:

ifconifg

NB: from now on any terminal commands will look like the one above. Any command with sudo might ask you for the password you just created in the previous step

The current RPi IP Address = 192.168.0.106

Now we need to get more information about our router:

route -n

We need to take note of the Gateway IP (IP of the router)

Gateway IP (Router) = 192.168.0.10

Now map the IP, Netmask and Gateway (router IP) like below:

Ignore the different ip address from the other screenshots

As for the DNS, you can use the following:

DNS server 1: 8.8.8.8

DNS server 2: 4.2.2.2

Once saved, we can test that the changes took effect by disconnecting and re connecting the network. Either at the bottom of WICD or from terminal ‘ifconfig’ command, you can check the ip.

Pro tip: Apart from the IP which the router assigned, you can change the last 3 digits if the IP to your liking as long as they are in the network range and set that as the static IP.

This video goes into detail of setting up static IP with WICD from command line to if you want to delve a bit deeper: https://www.youtube.com/watch?v=3vQumH1iAB0

After you’re happy with your static IP it’s time to restart the Pi. The Pi now will restart in Command Line Mode since that’s how we changed it previously. Next, we’re gonna make sure everything is up to date before we store the Pi away and continue working from our PC/Mac.