Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I wish to forward a persistent HTTP request through a different public IP. It connects to the server and stays connected as the server continuously streams data.

This needs to be transparent to the application; the routing logic needs to be limited to just making the HTTP connection to a target port number (or host:port).

I'm considering having a Squid service listening on a LAN IP but on several ports; if the application connects to port A, forward the request through nic A; for port B connections, forward through nic B; and so on.

Is this a suitable task for Squid? And where I could find some hints about the configuration? I got lost reading the Squid documentation finding for anything related to this (specifically how to map local ports->different output NICs).

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Yes, it's possible with Squid.

http_port 3128
http_port 3129
http_port 3130

acl port1 myport 3128
acl port2 myport 3129
acl port3 myport 3130

tcp_outgoing_address x.x.x.1 port1
tcp_outgoing_address x.x.x.2 port2
tcp_outgoing_address x.x.x.3 port3

If you have differents gateway per IP address you also have to configure source routing:

ip rule add from x.x.x.1 table 10
ip rule add from x.x.x.2 table 11

ip route add table 10 default via GW1
ip route add table 11 default via GW2

ip route add default via GW3

In squid.conf, it's important to set:

server_persistent_connections off

Or my procedudore wouldn't work.

share|improve this answer
    
For some reason the outgoing IP gets sticky for a time and then it is refreshed. Weird. Thank you anyway! –  luisfarzati May 4 '12 at 18:30
    
Set "server_persistent_connections off" –  diegows May 4 '12 at 20:03
    
thanks! I'll try that. –  luisfarzati May 4 '12 at 20:06

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.