How to configure static IP in an industrial Raspberry Pi Panel PC

Learn how to do it in Raspberry Pi with Raspbian operating system for permanent applications
July 12, 2019 by
How to configure static IP in an industrial Raspberry Pi Panel PC
Boot & Work Corp. S.L., Support Team

Introduction

In this post, we will see how to configure a static IP in Raspberry Pi Panel PC working with Raspbian operating system through the command console.

In many occasions, we will not want to dedicate our Raspberry Pi to a “normal” computer with screen and keyboard, but we will dedicate it to permanent applications

Examples of permanent applications are, among many others, a file server, a web server, home automation applications such as controlling lights, making an alarm, or a thermostat, and even when making robots.

In these cases, having a static IP is a very important requirement, if not almost essential, to connect with our Raspberry at all times from another device.

Requirements

Does your project require a dynamic or static IP?

Through the IP address, we can connect with our device in a simple way.

This IP can be:

  • Dynamic, it can change every time we reboot the device.

  • Static, remains fixed between restarts.

In many cases, our devices are connected to the local network through a dynamically assigned IP provided by the DHCP (Dynamic Host Configuration Protocol). 

In this case, our router acts as a DHCP server and assigns us an IP address within a range of addresses.

Dynamic IP addresses by DHCP have the advantage of giving us the freedom of not having to configure the devices or make sure that each one has a different IP. Simply, turn on your computer, laptop, your mobile, your (… whatever …) and the router is assigned IP without you to worry about anything.

However, normally if we have a permanent installation we will want the IP address to be fixed. Because you will not be thankful that you are going to access your files, or turn on the lights of your house, and you can not connect because the IP has changed, right?

Configuration

To configure a static IP, we must ensure that it is outside the DHCP range (you will have to verify it in the configuration of your router) and that no other device is assigned the same IP.

To configure a static IP in Raspian we must edit the file /etc/dhcpcd.conf with the command:

sudo nano /etc/dhcpcd.conf
        
    

If we look at the content of the file, we will see some commented lines (they begin with '#') that have an example of static IP configuration:

# Example static IP configuration:
#interface eth0
#static ip_address=192.168.0.10/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
#static routers=192.168.0.1
#static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1

To create our own static IP address, for example for the WiFi interface (wlan0), we copy the commented fragment and modify it so that it looks like this.

interface wlan0
static ip_address=192.168.1.200/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1

Being,

  • interface = Name of the interface that we want to configure

  • static ip_address = Fixed address we want (leave the / 24 at the end)

  • static routers = Address of the gateway (of the router)

  • static domain_name_servers = Address of the DND server (usually the router). If we want more than one DNS server, you can add them separator for a space.

Then we save the changes by pressing 'Ctrl + X' and then confirming with 'Y' and 'Enter'. Now we restart the Raspberry Pi with the command:

sudo reboot
        
    

Finally, we verify that, effectively, we have the IP that we have configured running with the command.

ifconfig wlan0
        
    

And we already have the static IP configuration.


​Search in our Blog

How to configure static IP in an industrial Raspberry Pi Panel PC
Boot & Work Corp. S.L., Support Team July 12, 2019
Share this post

Looking for your ideal Programmable Logic Controller?

Take a look at this product comparison with other industrial controllers Arduino-based. 

We are comparing inputs, outputs, communications and other features with the ones of the relevant brands.


Industrial PLC comparison >>>