Pi server wireless 4G modem static IP system

Can someone point me in the right direction for this project.

I need to have an internet connection in a shed on a property. The internet connection should be wireless, ie not copper cable connection to the internet network. It has to be low cost hardware and communication plan.

I intend setting up a raspberry pi to act as a server which will connect to the internet modem. I would like to use Ethernet connection between Pi and modem through a switch if possible, rather than wifi connection between modem and Pi.

I would like to have the modem to have a static IP address so that I can initiate communicate to the Pi over the internet from outside.

The pi will be Ethernet connected to many other devices via Ethernet connection which will include many sensors and actuators. So the Pi needs to collect the sensor signals and send then periodically to some server on the internet. Similarly a server on the internet needs to be able to send messages to the pi to send messages to actuators etc.and request sensor information.

I would like to use some hardware module as the modem. And I would want to program the Pi in C language calling operating system services to provide this functionality.

I do not think this is a very difficult project but there is a very large deep hole in my knowledge in just this area. Can some one point me in the right direction as to some YTube videos that would be helpful, advise me on modem hardware or what such devices are called, about sim cards and what technology is required and what kind of plans are available from who?

Sorry this is such an open ended question.


Hey Clem,

Very interesting project, here are my quick notes on how to get started with this one and a couple of tutorials. Also, it’s worth noting that in essentially every private network your router/modem/switch i.e. connection to the larger network of the internet has at least two IP addresses (usually public and private) so if you’re setting up your own website (note regulations in your area as well as the laws your ISP has in regards to hosting a site online as it can leave your network exposed) you’ll need to find an ISP that’ll allow hosting, then port forward an Apache server or similar setup (maybe using FTP or SMTP protocols for files and emails running on a similar client) as for a tutorial, the best I found was on instructables, I’ve linked it for you below. If there’s anything else that we can do for you please let us know!

Core Electronics | Support

Hi Clem73666

From what I can tell there are multiple aspects to this project. So, I will break it down in my post.

Outside internet connection: From the sounds of things if you don’t have a phone line or DSL line running to the property the connection will need to be via the mobile networks. Companies such as telstra and optus offer modems, that allow connectivity to these mobile networks, whilst also have the normal features of a router, i.e. Ethernet ports. (see telstra smart modem as an exmaple here: https://www.telstra.com.au/internet/extras/get-wifi#wifi-smart-booster)

Static IP address: Within the local network of the router you can assign a static IP address, however for devices wanting to connect to your pi outside the local network you will need to contact your ISP and setup a static IP address for the router itself.

Hardware Module Modem If you wanted a gateway to interface with your sensors and servos, this may be appropriate, it is loRaWan, so they all could be wireless, then interface back to your pi: https://core-electronics.com.au/laird-sentrius-rg191-lorawan-gateway-au915-as923-compatible.html

PI Server and Sensor Reading: Unless you want to go for a home automation style setup, which may actually be a lot easier to configure (see: https://www.home-assistant.io/hassio/), you will have to do a fair bit of programming yourself. To get a server up and running I would recommend Bryce’s video from above or taking a look at this tutorial: https://maker.pro/raspberry-pi/tutorial/how-to-control-servo-motors-through-a-raspberry-pi-and-flask

Hope this helps, its definitely got a lot of different aspects to it!

1 Like

Hey Clem,
from an IT Security perspective, you want to avoid opening the Pi to the internet if possible.

I would be looking for a VPN capable 4G router or see if the Pi can establish the VPN to your internet server.
This way static IP wouldn’t be required.

Take a look at cradlepoint or teltonika

1 Like

Hey Clem,

I have a similar set up at home with a Pi running OpenHab and am planning more of the same (with sensors, as you describe) in the country. Up there, I’ll be using satellite NBN, but there’s still the difficulty of a static IP. Most non-commercial providers don’t provide the option of a static IP; you’ll find it’ll likely remain static for some time, but a simple drop in connection will result in a new IP being issued (hours / days / months later).

You can get around this limitation by using a Dynamic DNS service - essentially providing your network with a domain name. Works like this:

  • Register with a service (I use no-ip.com) and get a domain name (eg. clemsshed.net)
  • Install a script on your Pi that the service provides
  • The script runs (eg. daily) and connects to the DynDNS, updating the service’s record of your IP
  • When you connect, you’ll be connecting to the domain name and not the IP

No-Ip.com has a free offering; the drawback is that you have to login and validate the service every 30 days. For me, it’s only a minor inconvenience.

To the point raised by @Dominic62117 - there are inherent risks in opening up your Pi to the open internet. If you decide to proceed that way, do your research on securing it - things like Fail2Ban, an appropriately configured firewall, basic things like changing your default password, using non-standard ports, etc. None of that is entirely foolproof, but it’ll certainly eliminate a chunk of risk. I’ve not tried setting up a VPN before - if that looks to be straightforward enough and suits your needs, I’d probably lean that way too.


1 Like

As others have pointed out, a static IP on a 4G service is not very common. Is the ‘internet server’ going to have a single server with a fixed IP or DNS entry?

I use a tool called autossh to create VPN-like connections to devices that don’t have static IPs. It also removes the need to directly open ports on any of the Pis to the internet.

By using SSH tunnels, I can access services on the remote Pi (of a service hosted on the other end of the SSH tunnel) as if it is local. MQTT is probably a good starting point for your research.

In my case, I use MQTT to handle sending sensor data from a few Wemos nodes around the house and one of those Wemos kits has been connected to an RF module. This gives me the ability to trigger 433mhz RF commands via MQTT.

1 Like


Getting a static IP on the Mobile Broad Band network wont come easy or cheap.
For remote assess IP address purposes using a ‘cheap’ standard data sim recommend using DYNDNS Dynamic DNS Service like (https://account.dyn.com/dns/dyndns/) have free options for 5-10 hosts.
Had equipment updating DYNDNS for years and its reliable enough!
Will need modem/router that has DYNDNS update client built in, or via software running on Pi. But get a modem that does it is best!

Sending messages back and forth, recommend looking at some Azure services like Azure Service Bus (few different types) etc over rolling your own, when AUTH/Security will take a bit of effort.


1 Like