Connect 2 devices with the same IP Address to the same network

dlakelan, lol that's the device I'm using already, got second one lying around somewhere ill dust it off and give it a go.

feels like getting blackmail when all the hardware and code is present but locked so you can't use it unless you pay extra. so if a couple of cheep bits of kit and some mental exercise gets round the problem so be it.

1 Like

really? awesome...

I have two devices with the same ip address (192.168.125.1) which cannot be changed because the maunfacturer wont permit it.

Just as an aside, I'm of the mind to know just who the manufacturer of this dopey kit is. This is precisely the sort of behavior that should be subjected to public shaming.

2 Likes

Its worse than that, if you look above its because they want to CHARGE for changing the IP address. That's just beyond cheeky.

Precisely. All the more reason they should be publicly shamed, for breaking basic functionality.

To the OP: if it's a case of you wouldn't be allowed to reveal the details, or you're concerned about the vendor retaliating in some way, just give us enough clues to find them on our own, and someone who will never be using the product can point them out.

They are a major manufacturer of industrial robots, which we need to maintain a good relationship with. Hence I'll be keeping their name to myself.

did you ever get the $20 NAT box solution working? :nerd_face::bath::person_in_lotus_position:

If you google [industrial robot 192.168.125.1] you'll pretty quickly figure out who has this unfriendly policy.

1 Like

@dlakelan yes i did try it, successfully used a cheap router to change one of the bots ip address. Did run into an issue adding it to my network. Had to focus on other task but will return to it when i have some time and post the results.

@nbriggs I appreciate not posting the name. However anyone who uses industrial robot will recognize that ip address......

1 Like

Sorry for reviving an old post, I wanted to give my solution in case anyone else needs to find a solution for this kind of issue. I managed to solve this by using network namespaces and separate VLANs to isolate each device and NAT each on each virtual interface individually. This is pretty similar to what this guy has been doing for containers: https://blog.christophersmart.com/2020/03/15/using-network-namespaces-with-veth-to-nat-guests-with-overlapping-ips/

What you need to do is to use a managed switch to map each device to a separate port and VLAN, then create a new unmanaged interface for each one in OpenWrt (I used a Raspberry Pi for this purpose, but you could theoretically use any router).

Make sure that the full version of ip is installed using opkg update and opkg install ip-full.

You can then create a virtual Ethernet interface pair for each VLAN, and bind a 802.1q + veth endpoint to a separate namespace.

For each namespace, configure nftables to accept forwarding by default, and add a prerouting and postrouting chain with a DNAT rule and masquerading enabled in both directions (otherwise you'll have to add a static route on your end device). Enable packet forwarding using sysctl net.ipv4.ip_forward=1.

Finally, you need to add these setup steps to a startup script to reconfigure the namespaces automatically after boot, otherwise the configuration won't persist across reboots.

I made the following script to make things easier (since I would have had to repeat the same steps 16 times), you would need to adapt it to your own network configuration (subnets, namespace names, etc...):

#!/bin/sh /etc/rc.common

START=99
VLAN_FIRST=9
NS_FIRST=0
NS_LAST=15

start() {
for i in $(seq $NS_FIRST 1 $NS_LAST); do
	# Create kernel network namespace (ns0)
	ip netns add "ns$i"
	sleep 1

	# Assign eth0.9 to namespace ns0
	ip link set "eth0.$(($VLAN_FIRST+$i))" netns "ns$i"
	sleep 1

	# Bring virtual interface veth0.0 up (host side)
	ip link set "veth$i.0" up
	sleep 1

	# Assign veth0.1 to namespace ns0 (virtual side)
	ip link set "veth$i.1" netns "ns$i"
	sleep 1
	
	# Bring up VLAN interface in ns0 and assign IP 10.0.1.1/24
	ip netns exec "ns$i" ip link set "eth0.$(($VLAN_FIRST+$i))" up
	sleep 1
	ip netns exec "ns$i" ip addr add 10.0.1.1/24 dev "eth0.$(($VLAN_FIRST+$i))"

	# Bring up virtual interface veth0.1 up (in ns0) and assign bridge IP 10.0.240.9/24
	ip netns exec "ns$i" ip link set "veth$i.1" up
	sleep 1
	ip netns exec "ns$i" ip addr add "10.0.240.$(($VLAN_FIRST+$i))/24" dev "veth$i.1"

	# Configure DNAT and masquerading from eth0.9 to veth0.1 using nftables
	ip netns exec "ns$i" nft add table nat
	ip netns exec "ns$i" nft add chain nat FORWARD "{ type filter hook forward priority filter; policy accept; }"
	ip netns exec "ns$i" nft add chain nat POSTROUTING "{ type nat hook postrouting priority 100; }"
	ip netns exec "ns$i" nft add rule nat POSTROUTING masquerade
	ip netns exec "ns$i" nft add chain nat PREROUTING "{ type nat hook prerouting priority -100; }"
	ip netns exec "ns$i" nft add rule nat PREROUTING "iifname veth$i.1 dnat to 10.0.1.251"

	# Enable IPv4 forwarding in the namespace
	ip netns exec "ns$i" sysctl net.ipv4.ip_forward=1
done
}

Hi lux1m,
Thank you for your post. I'm new to openwrt and amateur in networking.
I'm trying to implement a similar network setup using your script but I'm not having success.
The following pic summarize the network I would like to setup.


How would you change your script to support my setup?
Thank you very much.
Ben