Using Pi as the man in the middle between internal and external resources - raspberry-pi

I got a job recently where I have to make sure that the company's internet is able to connect to the media streaming system installed inside the server room. However due to some limitations, just by connecting it to the router is not a solution. Therefore, I've setup a Raspberry Pi which will allows me to connect the server room's intranet to the company's internet. Currently, I can use both resources on that Pi due to the interface wlan0 and eth0.
I was wondering if possible that I could access the media streaming system's GUI through the PI inside the company's internet.

Related

A standalone Rasp pi running a web server. Possible?

I have a rasp pi 3 which controls an irrigation system. The pi is headless, and is controlled via the home network by running a Tomcat server, which creates a UI. Mostly, the irrigation system is automatic, but I can log in to the Tomcat server to see the log of its activities, or change settings, or update the planting plan or manually control the sprinklers.
Now I'd like something similar, but in a place where there is no internet available. That is, I'd like to use the pi as a standalone web server, so that I can access the UI using a browser on my phone. I've looked through the rasp pi documentation, but it describes setting up access points, which seem to depend on a wired connection between the pi and the router. I've read about connecting via SSH to a standalone setup, but that article said that support for a standalone server isn't available.
Is what I'm looking for possible?
Thanks,
John

Create a web server using gsm module

I am using raspberry pi
I am using signalR to send data to my client browser.
If my raspberry is on the same network via Ethernet or WiFi then I can get it to work.
If I now disconnect Ethernet and WiFi and switch on my gsm module I get assigned a dhcp address like 10.126.88.4 etc
If I now go to a client browser and type that ip address in the browser it will eventually time-out and upon investigation I find the raspberry pi has been assigned a different IP address.
This happens every time I refresh the browser.
After googling I find that it is the network providers doing this to stop the gsm being used as a server gateway.
One of the solutions is to use a proxy server but I could potentially have a lot of data passing through and
my initial idea was to have client browser talking directly to the raspberry pi device using gsm and thus not going through my own server.
Is there a solution to my predicament?

2 router in cascade with 2 DHCP and remote access

The installation is in a holidays house (so no permanent internet access)
I have a 4g-Routerm (ROUTER-1 = huawei B525-b23) that enable the internet access. I switch it on one day a week.
I have another router (ROUTER-2 = GL-MT300N-V2).
ROUTER-2 is always plugged on electricity.
On ROUTER-2 is connected through ethernet port a Raspberry-Pi3 (with Home Assistant on it).
On ROUTER-2 is connected through WIFI a Camera IP
ROUTER-1 and ROUTER-2 are connected together through ethernet.
When ROUTER-1 is not plug to electricity, none have acces to internet, but it's not an issue.
The camera save picture on the Rapbery Pi3, the Home Assistat is recording some sensor data.
When I switch on the electricity on the ROUTER-1, everyone have access to internet.
What I want is to have remote Access to my router-2 and my Rasberry and my Camera when ROUTER-1 is online
How should I do ?
Hi I can think of two solutions for this setup but both involve buying a second hand cheap router.
I think the use of a single router would make this setup a lot easier. Any router would work that supports:a USB 4g Modem to be attached to it, and has support for setting up a openvpn server and you need to be OK with leaving the Internet on all the time just make sure you dont have any services running that use up bandwidth and you should be ok. You can can connect both raspberry pi and IP camera to that router. Setup Openvpn server open the UDP port required and download the certificates, You should be able to vpn into your network and manage it through SSH or something remotely.
The second option is tailored to you but still requires swapping the 4G Modem with another one that supports these things: Wake on LAN, openvpn server, supports ssh into it over LAN and either has 4G support through a sim card slot or a usb port with modem support.
You can then have it setup so this new Router-1 is switched off with wake on lan configured on it and the raspberry pi to send the magic packet. You can use something like this to get an idea of how WoL https://www.lifewire.com/wake-on-lan-4149800. You can use cron on your raspberry pi to send WoL signal to Router 1 once a week which would eventually give you internet access once the router is up. You have to setup a vpn server on it and forward the required port and download the certificates. When your scheduled WoL cron runs make sure you are able to connect through vpn then access network resources you wish, at the end when you are done you can ssh into the router-1 and turn it off.
I hope this helps. I had a look at the router models you are using and it doesnt leave you with many options. You can get cheap second hand routers online that support everything that is required.

Google Smart Home integration with my IoT device (clarification needed)

I am looking for some clarification to how Google Smart Home works.
I am looking to integrate my current end device which control lights with Google Smart Home.
My end device is running a very small microcontroller utilizing an RTOS (Linux is not available)
Here is how I see it (Please correct or comment)
To my understanding this requires me to host my own cloud service
which will talk to my current end device?
My cloud service will then talk to Google cloud service.
My cloud service defines the protocol to talk to multiple end devices
Google Smart Home define the protocol to talk to my cloud service
Questions
Is there any method of doing this without having my own cloud Service?
That is a pretty basic summary of things - yes.
The crucial point there is that issuing a command to the Google Home does not have it send out a message on your local network. Google issues any commands from their network - not from your device.
This might seem like a minor detail, but it doesn't need to be a "cloud service" that you control that Google talks to. It does need to be a publicly accessible HTTPS endpoint. This could be a cloud service (and it would be in most cases), a public non-cloud server, or even just a public URL that has a tunnel to your private network (such as with ngrok).
The last is really how you'd get around having your own cloud service - you can setup the control on a local machine, and have a tunnel using ngrok.
I think a specific example may be beneficial: here's how to connect Google Home to your devices using an intermediary service like IFTTT:
Create a recipe (applet) on IFTTT to connect Google Assistant to an ngrok tunnel using the Webhook service. This permits you to define a simple keyword phrase that the Google Home will recognize (like "Hey Google turn on my device"). The applet will then call a webhook - e.g. ngrok - with a custom command that you get to define (like "https://myngroktunnel.ngrok.io/Control.cgi?mydevice=on" ), where myngroktunnel is your ngrok tunnel address (see below #2) and Control.cgi is the CGI script that you have placed on your microcontroller (see below #3).
You would need to install and run ngrok on your microcontroller: this will connect the IFTTT applet to your microcontroller via the ngrok tunnel and give you a publicly-accessible URL that forwards requests to your microcontroller. You would typically forward your ngrok tunnel to a specific port on your microcontroller where you are running a web server (e.g. Apache) with CGI scripts to control your device. There are other secure tunnel services available on the web: ngrok is just one of them. So, you do not have to host your own webservice, but you do have to use a tunnel to a publicly-accessible service.
The web server that you have placed on your microcontroller has CGI scripts that control your device (for example, let's say you have a Control.cgi script that turns your device on or off, given a command string like mydevice=on, e.g. the hook in the IFTTT applet is "/Control.cgi?mycommand=on"
Of course, the RTOS on your microcontroller muse be capable of running ngrok and a web server - this is why many people have chosen to use a single-board computer like the Raspberry Pi or Orange Pi running a form of linux to host and control their devices. Since your device's RTOS is not linux, I would suggest getting a linux device which would then forward the request to your RTOS device over your LAN.

Raspberry Pi as standalone Server for Octoprint

I am working on Octoprint for 3Dprinter. Using Raspberry Pi as server and it is working fine with Raspbian OS.
But the system works only when it is connected to internet. Can I run the same without internet and How I can change the UI.
Technically you don't have to be connected to the internet, but OctoPrint is a web server so in order to connect to it, you need to at least have a LAN connection between your client and your Raspberry Pi. If you just intend to use it from localhost (ie client and server are the same machine) you just need enough networking to allow loopback to work. Which as idstam pointed out isn't a programming question.
On changing the UI, that could be a programming question, but your query is very non-specific. OctoPrint is written in python and has a pretty rich plugin system to allow you to add UI and replace parts of the UI. It is also well documented at http://docs.octoprint.org.