Two devices on same IP - not at the same time !
-
Just a quick question, I have two Raspberry pi's and wondered if it's possible to assign the same IP for each on their respective MAC's. So I can swap one to the other without have to reassign all the devices that connect to it (them). Therefore, same IP different MAC not at the same time. The idea is for testing and a cold backup if one fails - I would power it up and swap plugs.
-
First off, go ahead and try it!
Though I would set the static IP for each Pi internal to them. The IP should be outside of the range of what the DHCP server hands out to devices. Say the DHCP range is 192.168.1.100 to 192.168.1.200 the IP of the Pi's should be below 192.168.1.100 or above 192.168.1.200
And as long as only one of the Pi's is connected, your idea should work.
This is part of the fun of doing Home Lab experiments. Learning by trying and doing.
Take Care and Enjoy!
-
@frankm Thanks, I thought I would ask before messing things up again ! That's what I have now static IP's for everything but if a PI goes down I can swap over to another with minimal fuss. Most of the IOT things that connect need an IP rather than a hostname - I've tried.
-
@randombits
With static IPs that's not a problem.The IP-MAC assignments are stored in the ARP table of each device in an L2 network. If a MAC was gone, when a device wants to connect to it, it sends a new ARP request for the IP and gets the new MAC and updates its ARP table.
-
@randombits The only issue you might have is cached arp - but depending on the device arp cache normally isn't very long.
So say my pc was talking to this IP, and it knows the mac is aa:bb:cc:00:00:01
Now you change that out for other one and its mac is say aa:bb:cc:00:00:02, until my pc cache expires you would have problems talking to that IP.. When its cache expires it would re arp for that IP and get the new mac of the replacement device.
Its highly unlikely you would run into this because arp caches are normally very low, but depending on the os or settings it could be longer. Pfsense on freebsd I believe defaults to a 20 min cache for example. Windows should be under 1 minute. Iot devices I would think should be be low - but if you when you swap in the other device if you have problems - reboot the client device trying to talk to it - this would force a loss of any arp cache.
-
@johnpoz That's a good point I didn't think about ARP renewals
-
@randombits I have not looked into what Pis do - and would guess depends on what OS your actually running on them. But its possible it could/should also send out a gratuitous arp.
This is basically the device just telling the network on its own, hey if your looking for IP address x.x.x.x - that is me, here is my mac.
This should update any cache..
But sure arp cache should be something you should be aware of when you swap in the other device, that if you have any issues talking to it - make sure to check the cache on the device trying to talk to it, that its cache is not pointing the first devices mac.