Page 1 of 1

Connect to IP camera using RPI3 and LTE 4G dongle

Posted: Wed Nov 28, 2018 2:00 pm
by mestereaga
Hello everybody,

I have to monitor an isolated area and this came up to the following setup:
- rpi3B+
- zte mf823 4G dongle
- IP camera using P2P / DDNS with

So the IP camera is connected to RPI through Ethernet cable, so I'm trying to link this connection to internet via my 4G dongle (guess what, I have no idea how I can do this). After few searches I found out the following site: https://esther.codes/post-pi_router_story/ which is great, it has few common points, but it still don't solve my problem.
What I understand is that I have to install / configure a dhcp server on my rpi, then I have the share the internet between USB dongle and my IP camera. So lets say I'll do that, then is my camera reachable via DDNS or P2P from an external network? that is possible using a standard wifi/ lan router if there is activated the uPnP feature or configuring the Port Forwarding for my camera. How can I do this on RPI ?
If is somebody who did something similar, I'll appreciate any guidance and information.

Thanks in advance,
Andrei M.

Re: Connect to IP camera using RPI3 and LTE 4G dongle

Posted: Wed Dec 05, 2018 8:22 am
by mestereaga
Hi,
Few updates about this project: it is working, but there are few problems, especially the DHCP configuration seems wrong.
The idea is to have IP camera connected to rpi via eth0 and this interface shares internet connection with usb0, which is the modem interface, so in this way I can access the camera.
So following the https://esther.codes/post-pi_router_story/ I did the next configuration:

DHCP server: /etc/udhcpd.conf

Code: Select all

start           192.168.1.20
end             192.168.1.254

interface       eth0

remaining       yes

# Sets the DNS to use, here it points to the FDN resolvers
opt     dns     80.67.169.12  80.67.169.40
option  subnet  255.255.255.0
opt     router  192.168.1.1
opt     lease   864000          # 10 days of seconds
Also I configured the eth0 interface modifying the following file: /etc/network/interfaces

Code: Select all

auto eth0
iface eth0 inet static
    address 192.168.1.1
    netmask 255.255.255.0
And then I shared the internet connection between usb0 (this is the interface that is installed by modem) and eth0 using the following iptables rules:

Code: Select all

sudo iptables \
  -t nat -A POSTROUTING -o usb0 -j MASQUERADE
sudo iptables \
  -A FORWARD -i usb0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables \
  -A FORWARD -i eth0 -o usb0 -j ACCEPT
So this setup almost does fine but there are few things:
- the usb0 interface is down when eth0 is configured to use static ip: I can do ifup usb0 and everything seems fine, I got internet connection but I still prefer to avoid this ugly workaround.
- sometimes there is a DNS problem, I can ping sites using the DNS name (e.g. ping www.google.com), but the browser can't reach that address. The solution was to edit the /etc/resolv.conf file, so I changed the nameserver from 192.168.1.1 to 8.8.8.8. Previously it was working for days with 192.168.1.1.

In conclusion I can reach my camera using FREEIP DDNS from any network and this is really fine, but I think my RPI network configuration is not right and this can lead to other unexpected situations and this can be a problem for my project.
I'll really appreciate if you can have a look over this.
Andrei