1

I have an interesting question for you. I search several stack forum to find an answer but I could not able to find anything completely related. I have a rpi and I am using this device as sensor data collector. Let's say its ip address is 192.168.1.10 (eth0). It constantly sends the sensor data to a server, so I can not change ip of it.

Also I have a camera, which connects with ip link. Let's say it connects with 192.168.1.20. I want this camera to connect my network; however, I have to establish just one connection with both rpi and camera. So I am aiming to connect the camera to RPi by ethernet to usb converter(eth1) and set a switch configuration on my RPi to continue sending both sensor and camera data on eth0.

Basically, I want to build an ip switch on rpi, which is going to send sensor data by 192.168.1.10 ip address and camera data from eth1 by 192.168.1.20 ip address.

Is it possible? or what are the suggestions, which can help me?

ps: I have no wlan connection, so wlan related ports are not possible. ex: wlan0.

2
  • Is this the scenario; Your Raspberry is connected to a router/firewall with eth0, and the Camera is connected to eth1 on the Raspberry Pi?
    – MatsK
    Aug 8, 2017 at 11:13
  • Similar actually, eth0 is connected to a device, which acts as a router, however; it has no dhcp protocol.
    – HVK
    Aug 8, 2017 at 17:01

1 Answer 1

1

To solve this you can use bridge-utils. With bridge-utils you can bridge two or several interfaces together.

  1. Install sudo apt-get install bridge-utils

  2. Edit /etc/network/interfaces so it will look like somthing like this

iface eth0 inet manual

iface eth1 inet manual

# Bridge setup iface br0 inet static bridge_ports eth0 eth1 address 192.168.1.10 broadcast 192.168.1.255 netmask 255.255.255.0 gateway 192.168.1.1

And then restart the network service service networking restart

This will bridge eth0 and eth1 into a bridge br0 and set the IP adr. on the br0 to 192.168.1.10 and blank the IP ad. on eth0 and eth1.

Router | | +--------------+ +--------+ | | Raspberry Pi | | | | | 192.168.1.10 | | Camera | | | br0 | | | | +--+------+----+ +----+---+ | eth0| |eth1 | | | | | \-------- \---------------

4
  • I believe this will help me a lot, but I have a question for you, how can I access the camera from a device, which connected to the router with 192.168.1.20 ip? I believe I have access to the data on rpi by 192.168.1.10 but I did not understand how to connect camera from a device on the router by 192.168.1.20 ip. Consider that, I will connect a pc to the router (pc ip is irrelevant) and I want to see camera interface on that pc, when I write 192.168.1.20 on a browser. How can I add this step to the steps you explained above?
    – HVK
    Aug 8, 2017 at 19:03
  • The bridge is a switch (two ports only), so the traffic on eth0 is the same as on eth1. As the schema in my answer shows, you connect the camera to eth1 on the Raspberry Pi and give the camera the IP 192.168.1.20
    – MatsK
    Aug 8, 2017 at 19:28
  • Dude you are awesome, thank you very much for spending your time on my question.
    – HVK
    Aug 8, 2017 at 20:06
  • Your welcome, always happy to help a fellow Linux/Raspberry Pi nerd ;-)
    – MatsK
    Aug 8, 2017 at 20:40

Your Answer

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.