Re: Multiple outgoing addresses for squid? [linux multihoming gateway] FIX

From: Eliezer Croitoru <eliezer_at_ngtech.co.il>
Date: Tue, 03 Apr 2012 16:15:55 +0300

a fix on the specific lines:
On 03/04/2012 15:39, Eliezer Croitoru wrote:
>
> ________
> +------------+ /
> | | |
> +-------------+ Provider 1 +-------
> __ | | | /
> ___/ \_ +------+-------+ +------------+ |
> _/ \__ | if1 | /
> / \ | | |
> | Local network -----+ Linux router |
> | Internet
> \_ __/ | | |
> \__ __/ | if2 | \
> \___/ +------+-------+ +------------+ |
> | | | \
> +-------------+ Provider 2 +-------
> | | |
> +------------+ \________
>
> There are usually two questions given this setup.
> There are usually two questions given this setup.
> #start
> #ISP1
> #eth0 – IP 192.168.10.137 / Gateway 192.168.10.201
> #ISP2
> #eth1 – IP 192.168.11.155 / Gateway 192.168.11.201
> #LAN
> #eth2 - IP 172.16.1.1
> #Simple Configuration
> #First, we need to add two lines to /etc/iproute2/rt_tables
#T1 for isp1
#T2 for isp2
100 T1
101 T2
>
> #And then set up the routing for those tables.
>
> ip route add 127.0.0.0/8 dev lo table T1
> ip route add 172.16.1.0/24 dev eth0 table T1
> ip route add 192.168.10.0/24 dev eth1 src 192.168.10.137 table T1
> ip route add default via 192.168.10.201 table T1
>
> ip route add 127.0.0.0/8 dev lo table T2
> ip route add 172.16.1.0/24 dev eth0 table T2
> ip route add 192.168.11.0/24 dev eth2 src 192.168.11.155 table T2
> ip route add default via 192.168.11.201 table T2
>
> ip rule add from 192.168.10.137 table T1
>
> ip rule add from 192.168.11.155 table T2
>
> ip route del default
>
> ip route append default scope global nexthop via 192.168.11.201 dev eth1
> weight 1 nexthop via 192.168.10.201 dev eth0 weight 1
>
> #in case you do want specific destination to be routed throuth specific
> link such as ISP1 dns servers or just faster link to specific network
> use the next command
>
> #to send specific destination using ISP1 link
> ip rule del to 8.8.8.8 table T2
> #or to send using ISP2 link
> ip rule add to 8.8.8.8/32 table T2
>
> #in order to remove the rule just use:
> ip rule del to 8.8.8.8 table T1
> #or
> ip rule del to 8.8.8.8 table T2
>
> #in case you want to see the list of rules\route you specified use the
> command:
> ip rule ls

ip you do want to see how the Round Robin is working use the command:
ip route get "some ip with or without mask"

for me the output was like that:
suse-basic:~ # ip route get 8.8.8.8
8.8.8.8 via 192.168.10.201 dev eth0 src 192.168.10.137
     cache ipid 0xca0a
suse-basic:~ # ip route get 8.8.4.4
8.8.4.4 via 192.168.11.201 dev eth1 src 192.168.11.155
     cache

which means the first 8.8.8.8 route is using the 192.168.10.201 gateway
and the second 8.8.4.4 route is using the 192.168.11.201 gateway

>
>
> #you can also use a "from" and not to rule.
> like
> ip rule add from 172.16.1.120 table T2
>
> #end

-- 
Eliezer Croitoru
https://www1.ngtech.co.il
IT consulting for Nonprofit organizations
eliezer <at> ngtech.co.il
Received on Tue Apr 03 2012 - 13:16:02 MDT

This archive was generated by hypermail 2.2.0 : Tue Apr 03 2012 - 12:00:04 MDT