Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

using IPtables in Linux DNAT, I can redirect all traffic to an IP address but that is not what I want. Instead of redirecting to an IP address I want to redirect all traffic to a domain name, i.e. all traffic coming to a server with a public IP of 70.x.x.x needs to be redirected to home.dyndns.org

I tried adding a domain name dor destination into a iptables rule but I believe it only accepts IP addresses. Is there any other way of achieving this?

share|improve this question

2 Answers 2

There is no way to achieve this, except for with certain services (e.g. HTTP via HTTPd's mod_rewrite).

share|improve this answer
    
Exactly. Although Apache and mod_rewrite would be too bloated for this... I'd just spool up Nginx as Apache is a bit of a memory hog for something this simple. –  Taylor Jasko May 14 '12 at 4:07
    
Any idea on Squid proxy server? Could I use Squid to do this? If I do an apache redirect service it will only redirect port 80, right? in that case wouldn't Nginx do it differently or Nginx will also only redirect port 80? –  kim Khan May 14 '12 at 5:16

iptables doesn't support this. You can use hostnames in rules, but they get resolved when the rule is added, not when it is evaluated. Your only option to do this at the IP layer is to add a cronjob to regularly flush and reconfigure iptables in order to deal with the changing IP.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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