Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 redirect all the incoming requests to an URL instead of an IP address how can i archive this.. And when I redirect using IP address the redirection is happening but the redirected IP/URL is not shown in the browser address bar.. how to change this?..

The following are the rules i'm setting,

echo "1" > /proc/sys/net/ipv4/ip_forward

ebtables -t nat -N GUEST

ebtables -t nat -A PREROUTING -i eth0 -j GUEST

ebtables -t nat -N GUEST-REDIRECT

ebtables -t nat -A GUEST-REDIRECT -j mark --mark-set 1 --mark-target CONTINUE

ebtables -t nat -A GUEST-REDIRECT -j redirect

ebtables -t nat -A GUEST -p 0x800 --pkttype-type otherhost --ip-proto 6 --ip-dport 80 -j GUEST-REDIRECT

iptables -t nat -A PREROUTING -p tcp -m mark --mark 1 -j DNAT --to-destination

iptables -t nat -A POSTROUTING -j MASQUERADE

  1. The clients are redirected to the IP but what i want is to redirect the request to a URL[ example: ].

2.When I use the above rules the clients are redirected to the IP but in the address bar of the browser its still showing the requested URL not the redirected one.

share|improve this question
This question makes no sense - you can't convert a URL into an IP address. Turning lead into gold is simpler since they're both elements. Perhaps if you gave an example of what you're trying to achieve (input and output) then you might get a sensible answer. – symcbean Jul 26 '12 at 12:39

If you want the redirected IP/URL to be shown in the browser, you need to send HTTP redirect response to the browser (like 301). Then, the browser will send another request to the new location.

This can not be done using iptables. This needs to be done using any HTTP server/load balancer/proxy.

share|improve this answer
how do i check that my machine is already having HTTP server/load balancer/proxy or not?.. – user1216216 Jul 26 '12 at 13:03

You can't do this with iptables. You're confusing layers in the networking stack: IP is layer 3 in the OSI model, HTTP is layer 7. See

If you want to redirect URL requests you could use Apache together with mod_proxy.

share|improve this answer
But it would be really cool if someone could write an "httptables" module for the Linux kernel! – Colin 't Hart Jul 26 '12 at 12:29
but shall I achieve this by redirect to some other port[say 8080] and execute a program on the redirected port[8080] to redirect?.. – user1216216 Jul 26 '12 at 12:37
@symcbean and I are both unsure what you're trying to do. Please update your question. – Colin 't Hart Jul 26 '12 at 12:51

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.