Help with VPS and port forwarding with tailscale

Hello everybody

Here is my use case:
2 houses :
Each house has a network with 4g router and home assistant within hassio and tailscale add-on

I bought a simple vps server for redirections from any computer , especially computer without tailscale program installed

The goal is to enter [Public IP address of vps]:8123 to access home assistant in one house.

With one redirection VPS works fine with iptables and redirection of port 8123 to port 8123 of house 1 Tailscale IP address

Iptable -A PREROUTING -i eth0 -o tailscale0 -m TCP --dport 8123 -j DNAT --to-destination [tailscale IP home assistant 1]:8123

Iptable -A POSTROUTING -d [tailscale IP home assistant 1]/32 -o tailscale0 -p tcp -m tcp --dport 8123 -j SNAT --to-source [tailscale IP vps server]

But on the same VPS , when I try iptable with port 8124 to redirect to house 2 home assistant port 8123 it doesn’t work.

Iptable -A PREROUTING -i eth0 -o tailscale0 -m TCP --dport 8124 -j DNAT --to-destination [tailscale IP home assistant 2]:8123

Iptable -A POSTROUTING -d [tailscale IP home assistant 2]/32 -o tailscale0 -p tcp -m tcp --dport 8124 -j SNAT --to-source [tailscale IP vps server]

Any suggestion / idea to resolve this situation and to have

[Public IP address of vps]:8123 pointing to home assistant house 1 port 8123

and

[Public IP address of vps]:8124 pointing to home assistant house 2 port 8124

Or any other port if it could works ?

Hey folks,

I ran into a similar issue while setting up port forwarding on my VPS with Tailscale to access two Home Assistant instances. Here’s what worked for me:

The problem was in the POSTROUTING rule for the second house. You’re forwarding port 8124 on the VPS to port 8123 on Home Assistant, but the SNAT rule should reference the destination port of the Home Assistant instance (8123), not the VPS port (8124).

Here are the corrected rules:

# For House 1 (Port 8123 → 8123)
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 8123 -j DNAT --to-destination [Tailscale_IP_1]:8123
sudo iptables -t nat -A POSTROUTING -d [Tailscale_IP_1]/32 -p tcp --dport 8123 -j SNAT --to-source [VPS_Tailscale_IP]

# For House 2 (Port 8124 → 8123)
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 8124 -j DNAT --to-destination [Tailscale_IP_2]:8123
sudo iptables -t nat -A POSTROUTING -d [Tailscale_IP_2]/32 -p tcp --dport 8123 -j SNAT --to-source [VPS_Tailscale_IP]

Also, make sure:

  • IP forwarding is enabled: sysctl -w net.ipv4.ip_forward=1
  • The VPS firewall (like UFW) allows ports 8123 and 8124.

This should give you:

  • VPS_Public_IP:8123 → House 1 HA
  • VPS_Public_IP:8124 → House 2 HA

Hope this helps!