Routing web access on port 8080 trough another gateway

1

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):

Picture2

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.

DGA

Posted 2013-09-25T20:53:49.480

Reputation: 45

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 – 2013-09-25T21:15:52.193

R1 is default gateway. WebServer have static IP address (public IP 181.xxx.xxx.xxx). I think i must configure a proxy because i want all internet trafic to R1 and to this web server trough R2. – DGA – 2013-09-25T21:25:15.097

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 – 2013-09-25T21:35:18.433

Answers

1

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 192.168.1.2, netmask 255.255.255.255

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.

Brian

Posted 2013-09-25T20:53:49.480

Reputation: 8 439

i want all internet trafic to R1 and to this web server trough R2 – DGA – 2013-09-25T21:26:06.787

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 – 2013-09-25T21:54:47.120