8 Replies Latest reply on May 7, 2019 8:53 AM by mender331

    Raspberry pi IP camera using USB 3G Modem

    bhuvan

      Hi guys

       

      I am looking to build a video monitoring system using raspberry pi. I used the motion software, and it worked well with ethernet.

       

      Now, I am want to get it working with a 3G USB dongle. I am using a ZTE MF70 3G modem.

       

      The problem is that with a 3G dongle, the IP address keeps on changing. How can I overcome this problem ? Is there a software or something to do so. I want the camera to always use the same IP address and port.

       

      Or is there anything other than motion that I can use ??

       

      Please help.

        • Re: Raspberry pi IP camera using USB 3G Modem
          crosseyejack

          OK. Going to explain why this won't be as simple as you are thinking first. But I will give you some light at the end of the tunnel if you can make it to the end of the post. I want to try and help you understand the problem you are facing so you will be better tooled up to deal with the problem.

           

          This will be Network dependent. Sure there are virtual networks that can offer public facing or VPN connections for mobile connections (M2M - Machine to Machine) but I'm guessing you are going to be sticking to more public mobile networks.

           

          In the UK Ever Mobile network I have used use something called Carrier Grade Network Address Translation. Basically Its like your router at home but for the whole network (Well they normally use a few, but to keep it simple lets pretend they just use one, like who most people only have one router at home). This CGNAT is the public facing internet connection and allows the devices connected behind it to access the internet though Address Translation. Just like how most home connections only have one Public IP address but can have many devices connected to it.

           

          This offers the network a number of benefits.

          1) With IPv4 addresses running low it allows them to give internet access to many many devices using just a tiny handful of IP addresses

          2) (In the UK at least) Mobile internet providers have to provide an adult content filter with this filter turned on by default if you have yet to prove you are over the age of 18 (You can pick up pre-paid sim cards for pennies in pretty much any corner store in the UK with no ID check) can having all the internet connected devices connected via an NAT makes it much easier to provide such a filter (Just like how your home router can offer website filtering if you look in its management control panel).

          3) It basically provides a free firewall for the connected devices with the added bonus of making it much harder to run servers off mobile connections. With no port forwarding set no outside device can say to your network provider "Hey I wish to connect to your customers mobile phone which just so happens to be running lighttpd".


          "But Jimmy... My mobile phone supports push messaging so when I get an email, a facebook notification or my friends nagging me to play candy crush my phone beeps right away heck even SMS's come through right away..."

          To conquer the "Behind the NAT" problem there have been many solutions. First lets get SMS out of the way, SMS pushes are actually a part of the network connection your mobile device has with the network. They are pushed by the network and have nothing to do with the CGNAT.

          But yes, there are ways to get data from the internet onto your device almost instantly. This is done by using persistent connections. What happens is that your phone once its connected to your Network Provider and figured out it has an internet connection will open an persistent keep alive connection with the people who are provided such "Push Message" systems, listen for any new messages and just keep the connection alive and make sure the connection hasn't dropped, it will send a little heartbeat message every so often.

          Once a new notification or push message is due to be sent to your device it is first sent to your push message provider who then finds which of its open connections it has is your device and says to it "Hey wake up, I've got data for you".

           

          And its this you need to replicate. Now I've not done this in a while so I am more than rusty but what it sounds like you need is something called "Reverse SSH Tunneling" It involves having another machine running (Which could be a machine at home running on wired broadband connection which you can open the ports too or a cheap VPS) which sits there listening for the connection from the mobile connected raspberry pi. You can then connect to this publicly accessible machine from anywhere else on the internet and access the content you seek (It doesn't just have to be video but anything really). Once you have got the basics down while creating this system at home, you can then put in some simple scripts that will a) connect automatically on boot to your "relay" machine b) make sure the connection stays up by sending a small handshake every so often and forcing a reconnect if the connection drops.

           

          EDIT: If you happen to be on a mobile provide that doesn't put you behind a CGNAT then you could use https://duckdns.org/ for a free DDNS service. They have simple to use scripts that will help you auto update the DDNS from the pi. https://duckdns.org/install.jsp Personally I have my own hosted server and domain names so I just use nsupdate and dnssec keys to update my own DDNS. But note. if you are behind a CGNAT you will have to deal with the port forwarding issue.

          • Re: Raspberry pi IP camera using USB 3G Modem
            kadamana

            some device not support on raspberry pi, such as 3g modem , powered hub, web cam etc

              • Re: Raspberry pi IP camera using USB 3G Modem
                crosseyejack

                But a wide selection are. As OP as posted that their project is working well on home ethernet and that they are getting an internet connection but changing IP on their 3g modem I think that OP already has working devices but is just trying to access said devices via the 3G connection.

                 

                OP Just a random idea that popped into my head. What you could do is have the webcam stream to a server such as a rtsp ingress server and trigger the upload via a email trigger.

              • Re: Raspberry pi IP camera using USB 3G Modem
                christhetech

                Try http://www.noip.com/ they give you a static domain name and update their system when your IP address changes.

                  • Re: Raspberry pi IP camera using USB 3G Modem
                    crosseyejack

                    The only problem with NoIP is they are currently being subjected to a temporary restraining order by Microsoft http://blogs.technet.com/b/microsoft_blog/archive/2014/06/30/microsoft-takes-on-global-cybercrime-epidemic-in-tenth-malware-disruption.aspx Hopefully its only temporary but many of NoIP's domain names are currently pointing to Microsofts DNS Servers and not NoIP's so these domains can not be updated by users of the service.

                     

                    dig @8.8.8.8 NS no-ip.biz

                     

                    ; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> @8.8.8.8 NS no-ip.biz

                    ; (1 server found)

                    ;; global options: +cmd

                    ;; Got answer:

                    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 33427

                    ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0

                     

                    ;; QUESTION SECTION:

                    ;no-ip.biz.                     IN      NS

                     

                    ;; ANSWER SECTION:

                    no-ip.biz.              12423   IN      NS      ns8.microsoftinternetsafety.net.

                    no-ip.biz.              12423   IN      NS      ns7.microsoftinternetsafety.net.

                     

                    ;; Query time: 32 msec

                    ;; SERVER: 8.8.8.8#53(8.8.8.8)

                    ;; WHEN: Wed Jul  2 11:33:34 2014

                    ;; MSG SIZE  rcvd: 90

                  • Re: Raspberry pi IP camera using USB 3G Modem
                    mender331

                    You can use motion eye with carrier grade nat if you install remote3.it (used to be called weaved)