A Raspberry PLC answers at 10.10.10.20 on eth0 and at 10.10.11.20 on eth1. On the Industrial Shields image, these factory addresses are defined in /etc/network/interfaces.d/eth0_1 and eth1_1: to change one, edit its address line and reboot. To give the PLC an address of your plant network, use nmcli on Bookworm, or dhcpcd.conf on older images, and check the result with ip a.
This guide is specific to the Raspberry PLC and its two Ethernet ports. For a TouchBerry Pi Panel PC or any Raspberry Pi, the general method is in how to set a static IP address with nmcli, nmtui or dhcpcd.conf.
The first version of this post only edited dhcpcd.conf. That method works on images up to Bullseye, but the current Raspberry PLC ships with Debian Bookworm 64-bit, where dhcpcd is not used.
- Step 1ConnectKeyboard and screen, or SSH to 10.10.10.20
- Step 2CheckAddresses and system version
- Step 3ChangeFactory address or plant address
- Step 4Connect againSSH to the new address and ip a
The factory addresses of a Raspberry PLC
| Port | Factory address | Defined in |
|---|---|---|
eth0 | 10.10.10.20/24 | /etc/network/interfaces.d/eth0_1 |
eth1 | 10.10.11.20/24 | /etc/network/interfaces.d/eth1_1 |
These addresses are aliases called eth0:1 and eth1:1: a second address on each port. The install.sh script of Industrial Shields creates the two files.
The main address of each port is a different setting. NetworkManager manages it on Bookworm, and dhcpcd on older images. By default it asks for an address with DHCP.
So the same port can have two addresses: the factory one, to connect from a laptop, and one of your network. You can change either of them.
Step 1: connect to the Raspberry PLC
There are two ways:
- Keyboard and screen. Connect a USB keyboard and an HDMI screen, log in and open a terminal.
- SSH. Give your PC an address of the same network, but not the same address, for example
10.10.10.10with mask255.255.255.0. Connect the cable from the PC toeth0and open a terminal on the PC.
ssh [email protected]
Log in with the user and password of your image. On the image of the screenshot they are pi and raspberry, and the system itself warns that this is a security risk. Change the password with passwd.
Step 2: check the addresses and the system
ip a show eth0
cat /etc/os-release
ls /etc/network/interfaces.d/
In the output of ip a, the factory address appears with the label eth0:1. An address 169.254.x.x means that no DHCP server answered on that port, which is normal with a cable straight to a PC.
The line VERSION_CODENAME of /etc/os-release tells you which method applies:
| Release | Main address of the port | Factory address |
|---|---|---|
| Bookworm (Debian 12) | NetworkManager: nmcli | eth0_1 and eth1_1 |
| Bullseye (Debian 11) and older | dhcpcd: /etc/dhcpcd.conf | eth0_1 and eth1_1 |
Step 3, option A: change the factory address
Use it when you only need another fixed address on the port, for example 10.10.10.19 for a second PLC on the same laptop network. It works the same on Bookworm and on older images, because the file is read by ifupdown, not by NetworkManager or dhcpcd.
sudo nano /etc/network/interfaces.d/eth0_1
Change the address line and keep the mask:
auto eth0:1
allow-hotplug eth0:1
iface eth0:1 inet static
address 10.10.10.19
netmask 255.255.255.0
Save with Ctrl+O, exit with Ctrl+X and reboot:
sudo reboot
For eth1, edit eth1_1 in the same way. Write down the new address: you need it to connect by SSH.
Step 3, option B: an address of your plant network (Bookworm)
Use it when the PLC goes into a network with a router, a SCADA or other PLCs. On Bookworm, NetworkManager manages the main address of each port. List the connections:
nmcli connection show
The connection of eth0 is usually Wired connection 1, and the one of eth1 is Wired connection 2. Check the DEVICE column and use the name that you see.
Set the address, the gateway and the DNS server, and reboot:
sudo nmcli connection modify "Wired connection 1" ipv4.method manual ipv4.addresses 192.168.1.50/24 ipv4.gateway 192.168.1.1 ipv4.dns 192.168.1.1
sudo reboot
The change is saved in the connection and stays after each reboot. After the reboot, check with ip a show eth0 that the port has the new address and, if you keep the file eth0_1, also 10.10.10.20.
Give a gateway only to the port that goes to the router. For the second port, for example a machine network, set only the address:
sudo nmcli connection modify "Wired connection 2" ipv4.method manual ipv4.addresses 192.168.2.50/24
sudo reboot
If your plant network uses 10.10.10.0/24 or 10.10.11.0/24, first change or disable the factory address (option A), so that the same subnet is not on two ports. To use the nmtui menu or go back to DHCP, see the general guide.
Older images (Bullseye and earlier): dhcpcd.conf
Raspberry PLC images up to Bullseye use dhcpcd. This is the method of the first version of this post, and it only works there: on Bookworm, editing dhcpcd.conf does nothing.
sudo nano /etc/dhcpcd.conf
The file has a commented example:
Remove the # from the lines that you need and write your values. The first version of this post set 10.10.10.19 on eth0:
Only two lines are required:
interface eth0
static ip_address=10.10.10.19/24
static routers is the gateway of your network: add it only if there is a router, with its real address. static domain_name_servers is the DNS server, and the IPv6 line can stay commented.
In this example the new address is in the same network as the factory one, so the first version disabled 10.10.10.20 by commenting all the lines of eth0_1:
Save the files and reboot with sudo reboot.
Step 4: connect again and check
Connect to the new address. The PC must be in the same subnet:
ssh [email protected]
The first time, SSH asks if you trust the device at the new address. Type yes.
If SSH says REMOTE HOST IDENTIFICATION HAS CHANGED, another device used that address before. Remove the old key and connect again:
ssh-keygen -R 10.10.10.19
Then check the address on the PLC:
ip a show eth0
If you cannot connect, use the keyboard and the screen. Check the addresses with ip a and correct the file or the connection.
FAQ about the IP address of a Raspberry PLC
Can I remove the factory address 10.10.10.20?
Yes. Comment all the lines of eth0_1 and reboot. Before you do it, make sure you have another way to reach the PLC: an address of your network, or a keyboard and a screen.
Why does my change in dhcpcd.conf do nothing?
Because the PLC runs Bookworm, where dhcpcd is not used. Use nmcli for the main address, or the file eth0_1 for the factory address.
Is /etc/network/interfaces still used?
Only for the factory addresses, through the files of /etc/network/interfaces.d/ that the Industrial Shields image installs. The main address of the port is set with NetworkManager or dhcpcd.
Can the PLC get its address from a DHCP server?
Yes, that is the default for the main address. In a plant, a fixed address or a DHCP reservation in the router is safer, because a SCADA or a client finds the PLC by its address.
Related guides
- Static IP address on a TouchBerry Pi or Raspberry PLC with nmcli, nmtui or dhcpcd.conf
- Installing an operating system in the Raspberry PLC
- TCP server with Node.js and TCP client with Node.js
The Raspberry PLC family has two Ethernet ports and Debian Bookworm 64-bit preinstalled.
Take it further
With two Ethernet ports, a Raspberry PLC can sit between a machine network and the plant network. These pages show it in real projects.
Case study
Solar tracker data gateway with a Raspberry PLC
A Raspberry PLC per block collects the data of the tracker rows and passes it to the plant SCADA.
Read the case study
PLC Solution Library
TCP socket between Python and Node-RED on a Raspberry PLC
A Python control process and a Node-RED dashboard exchange encoder data and start, stop and exit commands over TCP.
See the example