Redirect http using iptables for an ip range
6,219
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
Author by
Daniel
Updated on September 18, 2022Comments
-
Daniel over 1 year
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?
-
Daniel over 11 yearsThanks 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.