Take the 2-minute tour ×
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 (10.13.13.10-19) 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 10.13.13.10-10.13.13.19 --protocol tcp --dport 80 --jump DNAT --to-destination 1.2.3.4
share|improve this answer
    
Thanks for the response. It worked for me with one modification; "10.13.13.10-19" should be "10.13.13.10-10.13.13.19". Other wise it blocked a much broader range of ips. –  Daniel Jul 30 '12 at 14:28

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.