Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I have a range of ip addresses ( that I want to redirect all outgoing http traffic to an internal webserver. So if someone in that range tried to access any site, the html from my webserver would be returned instead. However, I only want to affect that ip range. What iptables rules do I need on my router to make this happen?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

You can use the iprange module to match a range of addresses. You want to DNAT the packets to your webserver.

iptables --table nat --append PREROUTING --match iprange --src-range --protocol tcp --dport 80 --jump DNAT --to-destination
share|improve this answer
Thanks for the response. It worked for me with one modification; "" should be "". Other wise it blocked a much broader range of ips. – Daniel Jul 30 '12 at 14:28

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.