2

Currently I'm working on a robotics project. I'm using two different sensors for the project and they are connected to my PC via an ethernet switch. However, these two sensors demand two different static IPs to be set for the computer. I mean,

  • for Sensor 1, I have to set the static IP of the computer as 192.168.1.102
  • for Sensor 2, I have to set the static IP of the computer as 192.168.1.2

However, since my computer has only one ethernet interface, I can only set one of them at a time and cannot get data from both sensors.

Sensors are sending UDP packages to their relevant ROS drivers/packages. And I do not have access to sensors firmwares, so I cannot change the default IP addresses of the sensors.

I do not know much about networking. I hope the problem definition is clear.

Is there a software or hardware trick that I can use and get two sensors work at the same time?

I'm running Ubuntu 16.04 and ROS Kinetic.

1
  • 1
    Please provide your virtual Ethernet adapters from within /etc/sysconfig/network-scripts/, should be as simple as, creating additional virtual adapters
    – Ramhound
    Commented Sep 30, 2020 at 7:28

1 Answer 1

1

You can have multiple addresses on the same ethernet connection, you jus t need to specify one of the addresses to be the "main" one.

Off the top of my head, these two commands should do the trick:

ifconfig eth0 inet 192.168.1.102/24 up
ifconfig eth0:1 inet 192.168.1.2/24 up

For the above to work you need to replace eth0 with the actual name of your ethernet connection. You can get this devicename by looking at ifconfig (no arguements). It most likely start with e.

The above two commands should set both IPs, and they should remain until reboot. If you need it to be persistent across boots, you need to edit the appropriate interface script in /etc/sysconfig/network-scripts/ accordingly.

I am unsure whether Ubuntu has the ifconfig subset of comands installed by default, but if not it's a fairly trivially fixed with an apt-get install.

1
  • Isn't this exactly what Ramhound suggested?
    – Albin
    Commented Sep 30, 2020 at 9:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .