Squid traffic to a gateway other than the default

Issues related to configuring your network
Post Reply
dfcamara
Posts: 7
Joined: 2007/04/13 19:24:32
Location: Brazil
Contact:

Squid traffic to a gateway other than the default

Post by dfcamara » 2007/04/28 03:38:03

A have a fresh CentOS 5 server running Apache and Squid. It is connected to the Internet with two ISP lines. eth1 has a public IP address and is connected to a Cyclades router. eth2 has a private IP address and is connected to a D-Link ADSL router.

I would like to serve http pages via Cyclades router (the default gateway) and have all Squid traffic directed to the ADSL router. I'm not interested in load balancing, just want to limit the web surfing to the ADSL line. The ADSL router do the NAT.

In Squid I can set "tcp_outgoing_tos" or "tcp_outgoing_address" to it's traffic, but I don't know how to make it go to the ADSL line.

Thanks for any help.

dfcamara
Posts: 7
Joined: 2007/04/13 19:24:32
Location: Brazil
Contact:

I found a solution

Post by dfcamara » 2007/04/28 23:02:59

In [font=Arial]/etc/squid/squid.conf[/font] a set [font=Arial]tcp_outgoing_address[/font] to the IP address of eth2. Then I created a new routing table in [font=Arial]/etc/iproute2/rt_tables[/font] and a rule and a route in this table:

[code]echo "200 Velox" >> /etc/iproute2/rt_tables
ip rule add from 192.168.30.1 table Velox
ip route add default via 192.168.30.254 dev eth2 table Velox
ip route flush cache[/code]

My problem then was to have the route and rule set after network restarts. I guess the 'initscripts' way to do it was creating the following files in [font=Arial]/etc/sysconfig/network-scripts[/font]:

[code]echo "from 192.168.30.1 table Velox" >> /etc/sysconfig/network-scripts/rule-eth2
echo "default via 192.168.30.254 dev eth2 table Velox" >> /etc/sysconfig/network-scripts/route-eth2[/code]

A note about this solution is that, according to [font=Arial]/usr/share/doc/initscripts-8.45.14.EL/sysconfig.txt[/font] I am using the older syntax in [font=Arial]route-eth2[/font] file. The current syntax doesn't allow me to specify the desired routing table. Maybe this is not the exact solution to the problem.

Well, at least it is working as I wanted.

dfcamara
Posts: 7
Joined: 2007/04/13 19:24:32
Location: Brazil
Contact:

Re: I found a solution

Post by dfcamara » 2007/05/06 19:38:47

See http://lartc.org/howto/lartc.rpdb.multiple-links.html

Post Reply