Re: two internet connections + filter?

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Saturday, 28 September 2002, at 13:36:27 +0200,
Dworf wrote:

> When i load balance on ADSL + CABLE i want to load balance only lets say FTP, 
> WEB, SMTP and some other ports BUT NOT ssh, telnet and such applications. I 
> want to have ssh and telnet outgoing connections only on my ADSL route. how 
> can i do that? any ideas?
> 
It is easy. Just mark the traffic coming into the Linux router and then
route depending on the marks set. For example:

echo "100    ADSL" >> /etc/iproute2/rt_tables
ip rule add fwmark 1 table ADSL
ip route add table ADSL default via $ADSL_GW_IP
iptables -t mangle -A PREROUTING --protocol tcp --destination-port 22 \
    --jump MARK --set-mark 1

The above does the following: it creates a new routing table called
ADSL, that is populated with just one route, a default one, through your
ADSL router to the Internet. It additionally uses "iptables" to mark
incoming packets going to the SSH well-known port. This traffic gets
marked as "1", the mark matches the added "ip rule", so the packet is
routed checking the table "ADSL".

We configured a very similar setup here some time ago, and is working
fine. Specifically, all traffic is routed along a FR line (costly and
low bandwidth) but HTTP and FTP, that is routed through ADSL (cheap,
high bandwidth). To load balance certain traffic among the two lines we
should need to use something like:
ip route add default nexthop via $ADSL_GW_IP dev $ETH_ADSL weigth 4 \
                     nexthop via $FR_GW_IP   dev $ETH_FR   weight 1

This should direct 80% of connections through ADSL and the remaining 20%
through FR. As route selection is cached, all traffic for a certain TCP
session will go to the same line. UDP traffic will be balanced per-packet.

> and another thing... i was wondering if there is a patch or command or 
> somthing that could check if lets say CABLE line is used more then 80% and 
> ADSL is used less then 10% that the next connection would be made on ADSL?
> 
I don't know if such a command exists (I don't think so). But you could
get something similar with some monitoring and scripting.


Hope this helps, in any case, check the Linux Advanced Routing and
Traffic Shaping HOWTO at lartc.org, becasuse it contains much
information related to what you try to implement.

-- 
Jose Luis Domingo Lopez
Linux Registered User #189436     Debian Linux Woody (Linux 2.4.19-pre6aa1)
_______________________________________________
LARTC mailing list / LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux