Configuring networks
This page provides essential guidelines for configuring a network on a multi-interface device to effectively connect with PLCs that use custom IP addresses. A Raspberry Pi is used as example.
Last updated
This page provides essential guidelines for configuring a network on a multi-interface device to effectively connect with PLCs that use custom IP addresses. A Raspberry Pi is used as example.
Last updated
When setting up a Connectivity Gateway, it is required that the Gateway device can communicate with the PLCs that are listed in the SDA Console. The following illustrates a scenario with a Raspberry Pi wired to a network switch, which is also connected to two PLCs.
Since PLC 1 has the IP 192.168.0.1
and PLC 2 has 192.168.0.5
, it is reasonable to say that both are in the network 192.168.0.0/24
. Therefore, the Raspberry Pi needs to join this same network and correctly route the packages to the PLCs. Because our WLAN is 192.168.50.0/24
, there is no route collision.
Pre-Requisites
We are only going to use two modules to make it work, that are normally installed in a fresh Raspberry Pi OS. However, make sure to confirm it by running:
sudo apt update && sudo apt install nano ifupdown
Solution: we are going to use a Linux network interface configuration to set the static IP address 192.168.0.2/24
in the eth0
interface of the Raspberry Pi. To achieve that, create an interface file with the content below.
Explanation:
auto eth0
instructs the system to bring up a network interface during system initialisation, activating it as soon as we power on the Raspberry Pi.
iface eth0
specifies the network interface we are configuring.
inet
uses the address family IPv4.
static
statically configures the selected IP for the eth0
interface, therefore, it does not accept an IP from DHCP.
address 192.168.0.2/24
sets the IP address 192.168.0.2
as the Pi's IP on that Ethernet port, and sets the network 192.168.0.0/24
on that port, too. As a result, all packages within that subnet will be sent to the eth0
interface.
Now, we need to tell the network stack to reload our interface configuration by running:
Another option is to reboot the Raspberry Pi.
Suppose a more complex scenario, in which we add a third PLC. However, the new PLC is in another network 10.0.0.0/24
, that does not coincide with the two other ones.
Luckily, the solution is quite simple: we just add another specification block with an extra IP within that network for the same eth0
interface of the Raspberry Pi. Below, we choose the IP 10.0.0.2
for the Raspberry Pi.
If you miss having more examples in this page, please, contact us.