0

I have a usual local (192.168.1.x) network with multiple devices and the router with internet connection.

One of the devices is a Raspberry (192.168.1.2) connected via WiFi. It also connected to the IP camera (192.168.4.2) through Ethernet with a different IP (LAN IP 192.168.4.1), basically having two networks as it is shown on the sketch below.

sketch

IP camera has HTTP live-streaming (at http://192.168.4.1), which is accessible on Raspberry, but, obviously, not available for devices in the router network.

Is there a way how to access IP camera page through Raspberry? For instance, by going to http://192.168.1.2 from any device in the router network, which will be somehow tunneled/redirected to the IP camera webpage from it's internal network?

New contributor
djoker16 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
6
  • No. The camera's in a different network, so you need to first create a route on the RasPi so it can forward packets from 192.168.1.0/24 to 192.168.4.0/24 and vice versa, and on your router a rule to forward packets destined to 192.168.4.0/24 to 192.168.2.1 (assuming this is your RasPi's IP address). Then the camera will be reachable on any intranet device with its own IP address. Mar 15 at 10:34
  • The suggestion in Peregrino69's comment would set up proper routing in your network to allow connecting to the camera's address. This might be difficult to configure, and home routers often lack the necessary configuration options. It would also be possible to set up port forwarding on the Raspberry Pi. Is the HTTP port of the Pi unused?
    – Bodo
    Mar 15 at 11:29
  • ... see cloudsigma.com/… or cyberciti.biz/faq/… UFW might be easier to set up than pure iptables.
    – Bodo
    Mar 15 at 11:30
  • @Peregrino69 Thanks. Can you give an advice how to properly configure the packets forwarding? I don't see the role of the router in this situation, looks like just a pure Raspi configuration.
    – djoker16
    Mar 15 at 13:52
  • @Bodo yes, the HTTP port is free on Raspberry
    – djoker16
    Mar 15 at 13:52

2 Answers 2

0

There are lots of ways to achieve this. Although there is probably not much benefit in using a reverse proxy given how the rest of the network is probably configured, it is not much harder than the other approaches, gives a lot more flexbility and should definitely be the starting point for anyone exposing a device like a web cam on the internet.

There's lots of good, http proxy software available. My preference would be nginx over haproxy over apache httpd. OTOH if you are already running squid as a forward proxy, it can do the job too.

nginx config could be as simple as....

server {
  listen 80;
  listen [::]:80;

  server_name _;

  location / {
      proxy_pass http://182.168.1.2/;
  }
}

But you should add authentication, TLS, and whitelist safe URLs if there is any possibility of unfriendly access on the network.

1
  • Thanks! This fully solved my issue.
    – djoker16
    Mar 16 at 14:47
0

One way is to create a static route on the RasPi to 192.168.4.0/24 network, and another in the router so it knows where to send the traffic for the camera.

On RasPi you can use command

ip route add 192.168.4.0/24 dev eth1

... replace eth1 with the interface leading to the camera.

Somewhere in your router settings you have option to configure static routing. The images below are from a TP-Link router, what yours show probably looks a bit different but has the same elements.

router1

router2

You can set 192.168.4.1 as the destination as well. After this the devices in your internal network can reach the camera simply by going to http://192.168.4.1.

Without the static route on the router what will happen is:

  • Client tries to reach 192.168.4.1
  • Because it's in a different network, it will send the packet to its gateway, your router
  • Router doesn't know how to reach 192.168.4.0/24 network, so it will send a message to other routers to inquire if they know the route
  • There are no other routers to respond, so it will drop the packet

Alternatively you could configure a forwarding rule to the RasPi instructing it to forward all traffic to 192.168.1.2 port 80 to 192.168.4.1. Then your internal clients would be able to reach the camera by browsing to 192.168.1.2.

Your Answer

djoker16 is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.