Weird one here. I’m looking to set my HA Green to have more than one IP address on my network. Is there a way to do this?
Background, if anyone is wondering why I’d want to do this: I have a remote control that can connect directly to an Emulated Roku in Home Assistant, and I’d like to make several Emulated Rokus so the remote can control one device with each. Typically multiple Emulated Rokus are distinguished with different ports under the same IP address, but through an issue with my remote it only recognizes them under port 8060. Someone on another forum got around this by setting a different IP address for each Emulated Roku, and I’m hoping to do the same. They were able to do it with Docker, but I have a HA Green so their method won’t work for me.
It's not just setting multiple IPs to HA, Mike... Each instance of the CONTAINER running your software needs a different IP. (that's why docker can do that.)
The way Ha exposes external services that's not happening. They all get proxies to the HA base addr. And any addr ha owns so if you manage to multi home HA (also see all the issues on the forum on that subject - HA is designed for flat networks...) you'd be broadcasting the same service on all ha IPs serving that port [0.0.0.0:port] so you're back in the same boat.
You'll have to separate the container for that and have it obtain an external isolated ip... I do not think there is a way to do that, at all?, easily... That will stick... In HAOS. (running HAOS on your green I assume?) HAOS isn't designed for complicated network configs. It can do some but what you're asking for is... Complex in HAOS at best. (read: I wouldn't want to try to battle that dragon)
How does one device using different IPs get to work out which IP session belongs to which instance of the app? Ain't going to happen (by design) - TCP networking doesn't work that way.
Examine your Roku requirements for alternative approaches. Is multiple instance of Roku running on your green the optimum path to achieve what you really want? Maybe that can be modified to do what you want, or try a different integration/app.
Is UDP preferred (broadcast rather than point to point)? Does it support that? How to differentiate each controller?
Under linux it is necessary ** to have multiple IP addresses assigned to the same machine, this can be done in a number of ways:
Multiple network cards.
IP Aliasing - for example ip addr add 192.168.1.20/24 dev eth0
As part of the docker networking stack (IPs for the docker container can be exposed directly to the LAN)
If you want to use the same TCP port with multiple IP addresses, where you handle each separately you have a few options.
When a process wants to bind() a port, the structure has both IP address and port, often processes bind the “wildcard” IP (0.0.0.0) which effectively binds them to all available IPs.
However it is possible to bind a specific IP, hence only SYN packets for that specific IP/port combo will pass though the OS networking and be delivered to the application.
The first option is for a single process to create multiple (listening) sockets and bind them to different IPs, since they are different sockets they can be handled separately.
Alternatively you can have two processes where both bind the same port but each is explicit about which IP it is binding, hence Linux takes care of delivering the data from each socket to the correct process, based on the IP address.
Those two processes could be running on the host or they could be dockerized and/or dockerized into different containers as long as the system is configured correctly, there is nothing stopping you from having different behavior based on which IP address is being used.
You can also use PAT (Port Address Translation) either on the linux machine itself (iptables) or in upstream networking gear - that doesn’t really get you much in the way of additional functionality but it can (sometimes) be easier to setup.
** - There are also some “tricks” with arp and promiscuous mode to remove this requirement, but that is beyond the scope of this explanation.
TL;DR Support for multiple TCP sockets on the same port - differing by IP address, is built into Linux.
If you have already put in the time to run Dockerized HA, the incremental difficultly is minimal.
My issue was blaming it on “TCP Networking” - that isn’t the issue - the issue is that HA Green is a product that is designed for those that don’t want to spend time** configuring more complex networking.
** - No judgment there, everyone is free to spend their time on things that are important to them, I suspect that a significant chunk of the more complex HOME networks have aspects that are more of a hobby than an actual requirement.