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 have a rule similar to this:

iptables -t nat -I PREROUTING -p tcp --dport 80 -s -j DNAT --to-destination

which redirects all http requests from 1.5 host to 1.2.. I want to make so it works only for one URL - to redirect only if user on 1.5 accesses for example. Is it possible without using proxy?

share|improve this question

By default, I would say it is not possible. BUT you can check if the --string option of iptables can help you

share|improve this answer
tried with string but it doesn't match anything – Mr. BeatMasta Jun 26 '12 at 9:54
I add like -m string --string '' it doesn't act like it is supposed to – Mr. BeatMasta Jun 26 '12 at 9:54

iptables/netfilter is a firewall and it is not designed to look at URLs, but you can try using string module if you want to look for specific string in the packet.

You can restrict the rule to specific IP addresses if that is applicable in your case and the web server rarely changes its name-IP mapping.

share|improve this answer
how can I set it for ip instead of then? – Mr. BeatMasta Jun 26 '12 at 8:31
@Mr.BeatMasta: For cases like, it will not be easy as google has several IPs and they are changing. You need to specify destination using -d option. – Khaled Jun 26 '12 at 8:50
Yup exactly. Actually I've tried that, but it didn't work, though ip was not changed... could you provide an example for my case, please? maybe i've done sth wrong. – Mr. BeatMasta Jun 26 '12 at 9:30

Your Answer


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.