2 Home Assistants... same IP

Very odd and hoping someone can help me out here… I am setting up my ‘second’ home assistant instance because I want to migrate my production to a different device, but the fresh install has the same IP of an existing HA - can I have two HA instances sharing the same IP? I’ll explain further…

I am running my ‘Production’ HA instances on virtual machine on my laptop. Fully set up, rock and roll. I want to move Home Assistant to my NAS, as I can support a virtual machine there and it will always be on… which I don’t want to kill my laptop for.

When setting up the second instance of HA via the NAS virtual machine… to my surprise it duplicated the IP address for the new instance to that of my production environment. When I navigate to that IP (I have a tablet on my wall, with my other virtual machine running) it is now in the ‘preparing’ stage of HA.

I don’t want to FUBAR my existing environment by writing over with the new instance… what should I do?

Adding - I navigated to the IP address of the second instance (once again, in the set up stage) and then I powered down the virtual machine on the NAS and navigated back to that IP address… and my production environment shows back up!

Not on the same local network, no.

Are you sure the two instances have the same IPv4 / IPv6 address, or is it just mDNS resolving homeassistant.local to which ever instance gets there first / is active / is cached on the client?

A bare-metal install would not allow two servers running on the same IPv4 + TCP port combination (you’d see an “in use” warning preventing the second from starting). Technically, you can have multiple identical servers running on one host, however the server IP port would need to be different (hence webservers on port 80 and 8080). I’ve never looked to see if HASS can be persuaded to run on anything else than TCP/8123, but doubt you can (and networked integrations would also need port remapping).

On a VM, the hypervisor may also act as an IP router routing internal addresses (VMs) to the LAN. This could allow two instances in different VMs / containers with different INTERNAL IP addresses, both running on TCP/8123. How this is exposed to the LAN is the question - depends on both the hypervisor and how you are resolving/ routing to the instance.

For a while, HASS could appear as http://hassio-2.local:8123/ - details here.

100% sure - it’s weird, I know. Example below:

Laptop/VM with HA IP = X.X.X.123

NAS = X.X.X.456
HA on NAS = X.X.X.123

Some more texture, I had a previous HA running on the NAS that I started over with this morning. On THAT HA the IP matched the NAS (ex. above X.X.X.456) however, when i did the fresh install that’s when it is now using the other IP address - here’s a screenshot of my router. The Laptop with the VM running is what my primary instance is on (you can see it’s connected via WiFi) my NAS, however, is wired in… which is where you can see the second instance of HA.


image

Right - two separate physical devices.

How were the IPv4 addresses allocated? Manual static / central DHCP server / multiple DHCP servers making a mess?

Typical home LANs have a router with a DHCP server which should prevent leasing two devices with the same IPv4. Hacks like using an old router as a WLAN AP / LAN switch without disabling the DHCP server (especially before moving a device which requests its original IPv4 back), or forgetting manual static IPv4 settings can all break stuff.

It is possible to setup multiple machines on the same LAN segment with the same IPv4 address (even same MAC) but the result is likely a mess of lost packets, retransmissions, and very unhappy switches (enterprise kit can automatically lockdown ports to stop this mess).

It is also possible to shoot yourself in the foot, but I’d also not recommend that. :rofl:

I’d manually set the IPv4 of the dev device, and change the HASS hostname (*-dev) to prevent mDNS from confusing things.

If you want to understand what happened, get a 3rd physical device, and try ping / traceroute / nslookup / avahi-browse (or equivalents). Testing from separate hardware might expose the mess of a laptop hypervisor IP router, NAS hypervisor router, and any differences between LAN / WLAN segments.

Thanks man - I just deleted it again and started over, assigned it a new IP address that hasn’t been used. Posted this more for my edification on something I hadn’t seen before. Thanks for your quick responses!

you probably also copied the MAC address when cloning the virtual machine :wink:

You can do two of the same service on the same IP, just use different ports. Default port is 8123.

Just run your second instance with configuration.yaml ona different port

http:
  server_port: 9000

Edit: obviously mdns won’t work. But mdns/bonjour is trash anyway so not like you are missing anything

I do not know what you see as IP address on the HA, but if it has an IP address that start with 172, then you might see the IP address of the internal docker network and these can easily have the same IP as another docker network on another device.

Ahh… two cloned VMs on the same LAN with the same MAC address - that could certainly confuse the LAN DHCP server into giving the same IP lease twice!

That would imply the hypervisors don’t offer full Layer 3 routing (as the VM MAC would be hidden behind the VM host LAN IP + MAC). Certainly, the HASSOS docker containers use internal IPv4 ranges (non-LAN), but not looked at layer 2 with a sniffer. :mage:t2: :nose:t2: :grinning:

It is the main reason that (at least VMWare) asks if you moved or copied the virtual machine after cloning :wink: