Super User is a question and answer site for computer enthusiasts and power users. 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 this network configuration (see picture and details bellow): Picture1

R1 and R2 are two routers linux with CentOS, each with 2 NICs (LAN and ISP). Now all web trafic goes trough R1 and a vpn trough R2 (R2->R3).

All i want to know is how to redirect all requests to a web server on some port (let's say 8080) trough R2 (ISP2) and keep all internet trough R1 (ISP1)(see next image):


All answers are good if guide me in the right direction. Thank you.

UPDATE: - using @Brian answer as starting point i found this answer and this

Thank you all.

share|improve this question
Are you really doing NAT on both R1 and R2? Which router (NAT gateway) do your LAN clients use as their default route? Does the web server in question have a static IP address? Do you mind if all traffic to that IP address (not just port 8080) goes via R2? Depending on your answers to these questions, there may be ways to solve it with routing. Otherwise, you might have to do something like block connections to port 8080 except from a web proxy machine, and configure all your LAN clients to use the web proxy for port 8080 connections. – Spiff Sep 25 '13 at 21:15
R1 is default gateway. WebServer have static IP address (public IP I think i must configure a proxy because i want all internet trafic to R1 and to this web server trough R2. – DGA Sep 25 '13 at 21:25
If you want all traffic for that web server's IP address to go via R2, then Brian's answer should work for you. – Spiff Sep 25 '13 at 21:35
up vote 1 down vote accepted

If you don't mind sending all traffic and not just that for port 8080 adding a route on your LAN that goes through R2 for the web server IP address(s) will work.

Destination: web server IP public, gateway, netmask

If you need just port 8080 traffic redirected then some iptables rules on R1 can be used to redirect that traffic that hits R1 so it goes through R2.

share|improve this answer
i want all internet trafic to R1 and to this web server trough R2 – DGA Sep 25 '13 at 21:26
I think you are right. I have shorewall as firewall and i can use "packet marking" to send 8080 trafic to R2 gateway. I'll test later and i'll be back with a conclusion. Thank you both. – DGA Sep 25 '13 at 21:54

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.