1

So I am trying to realize the following Setup with a Raspberry Pi 3 B+ (latest Stretch Lite):

Modbus TCP/IP Device with a static IP Adress connected to the Raspi Pi via Ethernet.
Raspberry Pi Communicates to the Modbus Device.
Raspberry Pi functions as a Wifi Webserver to display a couple of PHP Websites.
The Webserver makes the Modbus device accessible over Wifi, with its static IP Adress.

The Modbus Communication is already up and running, using the libmodmus package (great package, props to the developer)

The PHP Webserver is also working flawlessly, using dnsmasq and hostapd.

To realize the accessible Modbus device, I plan to use a eth0 to wlan0 bridge, and try to get this running without the Webserver, and then try to combine both functionalities into the Raspi.
Two Problems are in my way in the moment:

  1. Most Manuals online are outdated, using /etc/network/interfaces, while stretch wants most things to be handled over the /etc/dhcpcd/dhcpcd.conf file.
    f.e. I tried using the Raspberry Wifi AP/Bridge, but had no success creating the bridge.

  2. Even if I get the Bridge to work, I need DHCPCD to handle the Webserver and connected devices, so it can't be shut off to let /network/interfaces handle the bridge.

I hope i displayed my problem well and somebody can help me. If any additional information is needed, just let me know and I will provide it.

EDIT

My Setup should look like the following:

                           RPi
          wifi    ┌──────bridge───────────┐   Modbus TCP/IP
(various <.~.~.~> │(wlan0) br0 (eth0)     │ <--------------> Device
devices) <.~.~.~> |(wlan0) ap0 (webserver)|
      \                                                       /
   IP: DHCP                                              IP: static

Any Device Connected to the Wifi Should be able to contact the static IP of the Modbus device, as well as the Webserver

The Raspberry should be able to contact the Modbus device too

Every solution on StackExcahnge or other websites didint work for me, they either:

  • disabled the webserver

  • didnt properly bridge

  • disabled Raspberrys Communication with the Modbus device

1 Answers1

1

You are talking about hostapd and dnsmasq, so I guess you have an access point running on the RasPi. The Modbus TCP/IP Device (what ever it is) is wired connected to the RasPi. If and how there is an internet connection available is unclear.

I assume, devices connected to the access point (RasPi with web server) should have access to the Modbus device and vice versa. This can be done with a bridge so that all devices connected to the RasPi use the same broadcast domain and the same ip address range (and may get an ip address from a DHCP server running on the broadcast domain, if needed but not setup in the following example).

You are looking for an up to date solution, so you can use systemd-networkd without the need to use additional helpers like dhcpcd, ifupdown, hostapd, dnsmasq and bridge utils. You can just look at How to connect a ethernet device(having its own static I.p and netmask) wirelessly by my laptop? how to do it. Just replace that "sensor" with your "Modbus device".

If you have the bridge running then it is easy to setup the web server to use the bridges outside ip address (10.0.0.13 in the example) as interface to listen and serve. Then all devices connected to the access point and the Modbus device have access to the web server.


Reference:
(1) Setting up a Raspberry Pi as an access point - the easy way

Ingo
  • 42,107
  • 20
  • 85
  • 197