I have a Debian server with a static IP address. I want to set it up so that if I connect to this server using a specific port, it will redirect that traffic to my home network.
I've got that working using iptables like so:
iptables -t nat -A PREROUTING -p tcp --dport [port] -j DNAT --to [home-ip]:[port]
iptables -t nat -A POSTROUTING -d [home-ip] -j MASQUERADE
The trouble is, my home network has a dynamic IP. As soon as it changes (which happens frequently enough) this will stop working.
However, I have a dynamic DNS name set up for my home IP address.
Is there anyway to use iptables so that it will always redirect this traffic to the IP that my dynamic DNS name resolves to?