Host website with Raspberrypi and SIM7600E-H

Hi everyone

I saw the video about the Waveshare SIM7600G-H 4G HAT for Raspberry pi. I figured you might be able to help me further.

I am trying to host a website with the RaspberryPi 4 B and a SIM7600E-H.

The problem: I am only able to access my php site locally not from outside the network.

There are many tutorials online on how to setup web hosting on raspberrypi with a router. It is necessary to do port forwarding. However there are no guides or tutorials on how to do this with the SIM7600X Series Modem. Maybe the SIM7600X Series does not allow this kind of access from outside the network. How to setup SIM7600X like a router to forward the HTTP port 80?

I found a guide from SIMCOM SIM7500_SIM7600_Series_HTTP(S)_Application Note_V3.00.
In these instructions the followign commands are given which I input in minicom

I start HTTP service with AT+HTTPINIT
Response–>OK

I set the URL with AT+HTTPPARA=“URL”,“http://192.168.225.49” (192.168.225.49 is my raspberry pi IP)
Response—>OK

I send HTTP GET request with AT+HTTPACTION=0
Response–>OK

I read the HTTP response header with AT+HTTPHEAD
Response—>ERROR +HTTPACTION: 0,714,0

-My Firewall “ufw” is disabled
-SSH is enabled
-Apache2 server is also enabled

Can you please help. Im really clueless at the moment. Maybe the SIM7600 modem does not support access from outside network?

Regards Elias

Hi Elias,
I don’t know much about the SIM7600E-H but I have just had a quick read up and I see it allows you to connect your pi to the mobile phone network. So it will show as an additional interface on the Pi just like the Ethernet port. I have a fairly good handle on how TCP/IP works and the ping and tracert commands are your friends. Your firewall functionality is in the operating system and not the modem. If the modem connects directly to the internet you won’t have a router. If you have the GUI configured you should be able to learn how to allow outside connections are configured. You can do this from the command line but I have always found it more confusing.

The 192.168.225.49 IP address you quote is a private address and you cannot communicate directly with that IP address from the internet. Do you also have a LAN cable connected?
If you think you are connected to the internet via this modem get to a command line on your Pi and do a ping 8.8.8.8. (Googles DNS server)
If that gets a response then your network is connected.
Next do a tracert 8.8.8.8
Not sure if tracert has been removed from Linux. It may be traceroute
(I don’t have a Pi in front of me at the moment)
This should show you every network interface between you and Google’s DNS server. You may get timeouts on some interfaces if they deny ping requests. The take home from this command is your public IP address is in the list. It will be the first one that doesn’t start with 192.168.
Some mobile phone networks don’t assign public IP address to mobile phones. You will get one in the 10.x.x.x range. This means that the telephone company is also using NAT and if this is the case your device will not be accessible from the internet.
See if you can get the tracert command to work and post the results here.
If you have a public IP you should be able to find a tutorial on configuring inbound connections on a Raspberry Pi.
Be careful you don’t confuse yourself if you have the LAN cable connected at the same time. I’m wondering where your Pi gets that 192.168 address from?
Hope this helps
David

1 Like

Make sure the SIM7600 modem is configured properly to allow incoming traffic on port 80.

1 Like

As mentioned by David mobile networks use NAT. Without a unique IP address port forwarding is not possible.

1 Like

Hi David
Thanks a lot for the explanation and the instructions. I posted this topic in other forums and was getting no responses so I appreciate your support.

I have nothing connected to the network socket of the RaspberryPi. The Sim7600 is connected via USB. With the sim7600 connected, if I type “ifconfig” in lxterminal, I get eth0, lo and usb0. With the Sim7600 disconnected the usb0, where I read the IP 192.168.225.49 from, disapears. I saw from the tutorials on how to connect the sim7600 that this is normal.

I can ping 8.8.8.8. I was also able to do traceroute 8.8.8.8. and here is the output:

traceroute to 8.8.8.8. (8.8.8.8.), 30 hops max, 60 byte packets
1 mobileap.qualcomm.com (192.168.225.1) 2.913 ms 2.945 ms 3.065 ms
2 * * *
3 * * *
4 212.161.253.226 (212.161.253.226) 82.325 ms 82.362 ms 82.014 ms
5 * * *
6 zur01pe20.100ge2-0-0.bb.sunrise.net (212.161.247.129) 79.118 ms 73.595 ms
zur01pe20.100ge3-0-0.bb.sunrise.net (212.161.247.131) 82.557 ms
7 195.141.239.98 (195.141.239.98) 76.096 ms 26.237 ms 25.944 ms
8 * * *
9 dns.google (8.8.8.8.) 45.521 ms 39.039 ms 48.861 ms

So, my public IP is 212.161.253.226?

There is a guide with all the commands to configure the SIM7600 (SIM7500_SIM7600_Series_AT_Command_Manual_V3.00.pdf)
There is a whole list with commands to configure TCPIP. The only thing I tried was AT+NETOPEN which starts the TCPIP service. It made no difference. Maybe I need to configure TCPIP via the minicom terminal with these “AT+” commands?

Best regards
Elias

Hi Lia
Thank you for your feedback.
Do you know how to go about this?

Do I need to use the “AT+” commands onver the minicom terminal?
I have been looking at the commands described in SIM7500_SIM7600_Series_AT_Command_Manual_V3.00.pdf

There is a whole list to set HTTP parameters.
I have tried AT+HTTPPARA=“URL”,“http://192.168.225.40:80” which is my private IP and no success. Port 80 is default

Best regards
Elias

This line holds the answer.

1 mobileap.qualcomm.com (192.168.225.1) 2.913 ms

This address is assigned to you from a dhcp server on the telcos network. To save on public ip’s they share one with a couple of hundred users by using NAT.

I’m not sure who Qualcomm.com , that’s a private IP address but the response time is really quick so it’s probably on your local device.

The next two hops time out that’s not unusual.
They just don’t respond to ping requests.

so it’s looking to me like your not going to be able to publish a web page with this device.

I could of course be missing something
David

1 Like

Hi David

Thank you for you feedback. This would explain why i cannot find any documentation on this online.

Can you please clarify. Is the problem my provider? If I find another provider which does not work with NAT IP sharing i might get it to work or is the problem the sim7600 which only allows phone network therefore it cannot work?

Is there a raspberrypi HAT which can be used for my propose or is a router the only option?

Best Regards
Elias

As far as I am aware all mobile network providers use NAT. They do this to avoid the expense of buying IP addresses and also to stop public access to the service. So to use port forwarding you need a unique IP address as provided by an internet service provider. I am aware of one aussie broadband service provider who uses CGNAT so even the NBN can be problematical.

1 Like

Hi Elias,
I don’t know about other providers but I know Telstra uses NAT in this way.
The problem is not with the hardware it’s the provider.
You can get a router with a SIM card in it but you have just moved the problem to the router. The Wide Area Network (WAN) interface of the router would be assigned a private IP address by your provider. So the only real solution is to connect the device to the internet in a different way. If your device is in range of a wifi network you could connect to that and then configure port forwarding on that router providing that router has a public IP on the WAN side. Most home internet connections do.
I have done this with a Pi where the pi is on a remote control car. You can control the car like a Mars Rover by typing commands on a web page.
What kind of information is going to be on the web page that you hope to publish?
A more complex solution would be to send the information periodically from your pi to a web server somewhere else with a public IP that could then publish the page.
David

EDIT
Actually 192.168.225.1 is the first hop on the way to the internet.
Often the .1 on the end is used by convention for the router / default gateway on a network. The 192.168.1.40 address you mention above is assigned to the interface on your device but this can change as dhcp chooses these addresses from a pool of available addresses.
None of this matters much as they are all private addresses that are not routable on the internet. If you add a router at your place you are creating a private network behind a private network and you can’t forward ports on the ISP’s router. You can create outbound traffic on your device that can receive responses from the internet but the traffic can’t originate on the internet and find your private IP.

1 Like

Hi David
Thank you for the great explanation.

I dont have a home network. I only have phone network. Which means I will have to go differently about my project.

Wow a mars rover, sounds like an exciting project. I also strugle with the commands from the website to the pi. I was working with the commands exec and exec_shell without success. Finnally I simply had the Python script on my Pi running in a loop and checking if a certain GPIO is high. Over the website I then set this GPIO to high and I had my controll over the Pi this way.

I am trying to monitor my mailbox. My Idea was to have the raspberry pi with a camera module and a motion sensor, detect when the mailman brings my mail and then take a photo of the mail inside the mailbox. I want to have a website where this photos are uploaded to. I also want to be able to tell the Pi to take a photo remotly over the same website. This is why I use this SIM7600 4g HAT. I cannot connect via wifi to my outside mailbox and certanly I will not be able to lay a network cable through a window over to the mailbox.

I think these will be my options:

  1. Host the website online. I will have to research unexpensive online webserver hosts. If you can recommend one please do so.
  2. Talk to my provider to possibly get a modem with a fix IP adress
  3. VPN tunnel. If its possible without port forwarding i.e. private IP.

With all these IOT projects now a days I wonder how these are set up. Are the nb-IOT network any different? Or do these also operate with NAT and in this case they are only for monitoring purposes since inbound traffic would also not be possible on those projects… Or did I miss something?

Best regards Elias

Thinking more about this you probably need to break your project into smaller chunks that you can complete one at a time.
Your lack of alternate internet connection is going to make the web page idea hard to achieve without a lot of complexity.
So now that I understand what your are trying to achieve and thinking about the hardware you already have I had a better idea.
The Sim7600 is capable of making phone calls, sending sms messages and this probably includes MMS aka pictures. So you can send stuff directly to your mobile phone.
Start off simple by trying to send yourself a “Hello World” text message while it’s all on your desk. Then figure out how you can trigger this from your mailbox. “You’ve Got Mail”. A simple micro switch on the mail slot will do that.
Powering the Pi continuously is also going to be a challenge. You will need to think about putting it to sleep when nothing is going on and how to wake it up when something happens. I have done this with a Pi Pico not sure how you could do it with a full Raspberry pi but I’m sure your not going to be the first one to want that.
You won’t need to run it all the time as you are no longer trying to publish web pages.
Remember keep to small doable pieces. I think these ideas will get you moving even if not what you originally planned.
David

3 Likes

Hi Elias, Welcome to the forums!!!

It sound like David’s on the right track with the service being on a Carrier Grade NAT.
I ran into a similar issue with my home internet connection and my servers.

You may like to contact your provider to see if you’re able to Opt Out of the CG NAT and get a public IP for your service. I know Aussie Broadband doesn’t charge to opt out but you only get a dynamic public IP which will either require monitoring the IP for when it changes or have a Dynamic DNS system set up to be able to route the traffic automatically.
Your provider may be able to offer a Static public IP which might require additional payment to get that on your service.

1 Like

Hi David

I was able to setup a online webserver to which I can send the photos I take with my raspberry pi. I am now able to send the photos with the FTP python commands directly to the file manager of my online web server. So now I have the stand alone system that I wanted in regards to network.

However I find your Idea with the sms interesting. I will try to setup the SMS like you said to tell me “You have got mail”. Then I dont need to check continuously the website if there is any new mail.

In regards to power I have a 7800mAh Li-Ion battery which I will charge with a 5W solar panel (15cm x 29cm) that I can stick to the outside of the mailbox. I will look into having the raspberrypi in sleep mode aswell.

Best regards
Elias

Hi Aaron

Thank you for your feedback. I will ask my provider about the static IP address.

I ordered a nb-IOT capable sim card. Until now I was working with the normal mobilephone network sim card. I wonder if the nb-IOT will be capable of sending my data to the online web server I have now the same way a normal network connection or mobile network connection does.

Best regards
Elias

1 Like

Hi Elias,
Well done getting a web server and ftp server to work.
There are a few thing to learn to get that all going.
Best way to tell if your solar panel will provide enough power is to give it a test and see what happens.
I’m keen to know how the pi will go taking photos inside your mail box.
I’m thinking the range is close and the light is low. But I bet you are already thinking about these things.:cowboy_hat_face:
The NAT problem only stops inbound connections from the internet. Outbound connections should just work. Keep it to simple steps. It’s easy to get discouraged if you add to much all at once and can’t figure out why it doesn’t work.
David :cowboy_hat_face: