Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 --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?

share|improve this question

closed as off-topic by Falcon Momot, Ward, MDMarra, Jenny D, Bryan Jul 6 '13 at 8:19

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about hardware or software used in a home setting are off-topic because they require answers that may not be practical for the business and support professionals here. You should try asking on Super User instead." – Falcon Momot, Ward, MDMarra, Jenny D, Bryan
If this question can be reworded to fit the rules in the help center, please edit the question.

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.

share|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

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.

share|improve this answer

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