I want to forward a port from my remote vps to my domestic server and I am quite a newbie with iptables.

The problem is that I am using a dynamic dns service to reach my home server from the internet so I don't have a fixed ip and iptables doesn't like urls.

The rules I am willing to use are these:

-t nat -A PREROUTING -p tcp -i eth0 -d xxx.xxx.xxx.xxx --dport 8888 -j DNAT --to myhome.tld:80
-A FORWARD -p tcp -i eth0 -d myhome.tld --dport 80 -j ACCEPT

Of course I recevie a Error BAD IP ADDRESS because of myhome.tld.

What can I do?

link|improve this question

44% accept rate
feedback

2 Answers

This will not work as iptables needs fixed ip addresses.

I'd suggest either running a VPN between the machines or having a watchdog that will reapply the rules when your home address changes.

link|improve this answer
+1 for VPN. This results in consistent iptables rules, as your VPN internal IP address won't change. It also means if you are offline, your VPS isn't forwarding traffic to some other person's home connection. – Daniel Lawson Feb 13 '11 at 20:14
feedback

Try using Shorewall to build your firewall. It will expand DNS for you with caveats. (DNS must be reachable during startup.) There are notes in the documentation. You will need a trigger to reload the firewall when your IP address changes. The DHCP clients have hooks where you can do this.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.