0

I want to send some data from a SIM808 to a MQTT broker, which is node red installed on my raspberry pi 4.

How can I get the node red to receive and send MQTT outside the local network?

I've seen a lot of tutorials but they are about purchasing a third party server host, which I don't want to do. I've already achieved MQTT with an esp32 over my local network, but I have no idea for doing that outside local network.

Also I want to mention that it was suggested that for doing so, I needed to have a VPN. I decided to install WireGuard, and for some reason it just blocked all the raspberry pi internet traffic.

Another question is that in my router I have this options for the port forwarding, but how do I use them?

My raspberry pi is at 192.168.0.18 and the nodered port is at 1883, can anyone help me with that?

Port Forwarding

DavidPostill
  • 153,128
  • 77
  • 353
  • 394

1 Answers1

1

ZeroTier is what you want

https://www.zerotier.com/

It's a peer-to-peer (using your machines as peers) mesh VPN.

It's free for personal use.

Basically you install it on your MQTT server and on your RPi, create a private network via the ZeroTier web interface (after signing up) and join the devices to said network 1. on the client device using zerotier-one join <NETWORK_ID> and 2. by allowing them access in the web portal.

This will give them a new IP address in addition to their other LAN IP address. This new one behaves like a LAN. So point your RPI at the MQTT servers new ZeroTier address (after making sure the MQTT server is also listening on that address or 0.0.0.0) and it will Just Work™ as long as both devices have an internet connection.

It's all encrypted so it's safe enough.

Hope that helps!

Note: wireguard could be used, but it's more of a conventional VPN and requires more routing config to get split tunneling working.

EDIT: Also for the love of dog and all that is moldy do not forward the MQTT port using your router. That puts it on the public internet. Even if you have security on MQTT people can still pound the hell out of the service.

mashuptwice
  • 2,929
  • 2
  • 12
  • 25
Insanemal
  • 929
  • 3
  • 9
  • 1
    Upvote for zerotier. It is the easiest method (I know of) for setting up a VPN. Way easier to add new clients than with wireguard. – mashuptwice Nov 27 '22 at 16:04
  • Oh thanks for the formatting fixes :D I'm still getting my head around the markdown used here! Yeah it's a lot less messing around to get working and doesn't need fancy routing either. It's just like you've plugged in an extra network adapter. – Insanemal Nov 27 '22 at 16:13
  • 1
    You might want to checkout the [markdown editing help](https://stackoverflow.com/editing-help). Syntax is the same on stackoverflow. – mashuptwice Nov 27 '22 at 16:53
  • Thanks for the recommendation, but I searched it up and it isn't possible to use it in a sim808, or in the ESP32 (Where I want to use it). Maybe I didn't research in the right place, but all my research concluded that zerotier isn't developed yet on microcontrollers, so is there any alternative? – your_missing_semicolon Dec 05 '22 at 01:33