2 gateways out
hi,
first, i'd like to say im so happy this list is finally back up!!!!
my situation is that i have two cable modems connected to two different
2.4.2 boxes.
box A (eth0 x.x.x.x, eth1 10.1.1.1/24)
box B (eth0 x.x.x.x, eth2 10.2.2.1/24)those two connect to a central 2.4.2 machine with 5 nics.
box C (eth0 10.0.0.1/24, eth1 10.1.1.2/24, eth2 10.2.2.2/24, eth3
10.3.3.1/24, eth4 10.4.4.1/24)
10.0.0.0/24 is cisco management subnet
10.1.1.0/24 is only for the box A - box C connection 10.2.2.0/24 is only for the box B - box C connection 10.3.3.0/24 is public MS lan
10.4.4.0/24 is my private lan for my linux servers and personal machines
i masquerade 10.3.3.0/24 and 10.4.4.0/24 at box C, 10.1.1.0/24 at box A,
and 10.2.2.0/24 at box B.
box C will send any outgoing masquerades based upon its default gateway. the cable modems both fail serveral hours a week.
when when goes down, i manually switch box C to the other gateway. when they are both up, only one is used.
obviously, you can see the problem.
the most important thing is to load balence between the two cable modems
and route all traffic out the right way if one of the cable modems goes down.
if possible, possibly even send some packets out one way and some out
aNother (based on payload content and packet tagging?) but this is for my next lesson :)
here are my configs:
(please feel free to point out any errors or possible enhancements to these configs, since i am just starting out with iptables -- and linux routing in general --- ...any suggestions would be appreciated, thanX)
----------------------------------------------------------------------------
----------------------------------------------------------------------------
---------
BOX C:
[root@io /root]# cat masquerade
#!/bin/sh
modprobe ip_tables
modprobe ip_nat_ftp
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe iptable_nat
echo 1 > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -F
/sbin/iptables -P INPUT DROP/sbin/iptables -A INPUT -p tcp --dport 22 -i eth+ -j ACCEPT /sbin/iptables -A INPUT -p tcp --dport 53 -i eth3 -j ACCEPT /sbin/iptables -A INPUT -p tcp --dport 53 -i eth4 -j ACCEPT /sbin/iptables -A INPUT -i eth+ -m state --state ESTABLISHED,RELATED -j ACCEPT/sbin/iptables -A INPUT -i eth+ -p icmp -j ACCEPT /sbin/iptables -A INPUT -i lo -j ACCEPT/sbin/iptables -A INPUT -i eth+ -m state --state NEW,INVALID -j LOG --log-level debug --log-prefix "FIREWALL: Input: "
/sbin/iptables -P FORWARD DROP/sbin/iptables -A FORWARD -o eth0 -j ACCEPT/sbin/iptables -A FORWARD -o eth1 -j ACCEPT/sbin/iptables -A FORWARD -o eth2 -j ACCEPT/sbin/iptables -A FORWARD -i eth3 -j ACCEPT/sbin/iptables -A FORWARD -i eth4 -j ACCEPT
/sbin/iptables -A FORWARD -i eth+ -m state --state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -A FORWARD -o eth+ -j LOG --log-level debug --log-prefix "FIREWALL: Forward-Out: "/sbin/iptables -A FORWARD -i eth+ -j LOG --log-level debug --log-prefix "FIREWALL: Forward-In: "
/sbin/iptables -P OUTPUT ACCEPT
/sbin/iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE
----------------------------------------------------------------------------
-----------------------------------------------------------------
BOX A & B:
[root@matador /root]# cat masquerade
#!/bin/sh
modprobe ip_tables
modprobe ip_nat_ftp
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe iptable_nat
echo 1 > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -F
/sbin/iptables -P INPUT DROP/sbin/iptables -A INPUT -p tcp --dport 22 -i eth+ -j ACCEPT /sbin/iptables -A INPUT -i eth+ -m state --state ESTABLISHED,RELATED -j ACCEPT/sbin/iptables -A INPUT -i eth1 -p icmp -j ACCEPT /sbin/iptables -A INPUT -i lo -j ACCEPT/sbin/iptables -A INPUT -i eth0 -j LOG --log-level debug --log-prefix "FIREWALL: Input: "
/sbin/iptables -P FORWARD DROP/sbin/iptables -A FORWARD -o eth0 -j ACCEPT/sbin/iptables -A FORWARD -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT/sbin/iptables -A FORWARD -i eth1 -j ACCEPT/sbin/iptables -A FORWARD -i eth0 -j LOG --log-level debug --log-prefix "FIREWALL: For-In: Spoof: "/sbin/iptables -A FORWARD -o eth1 -j LOG --log-level debug --log-prefix "FIREWALL: For-Out: Spoof: "
/sbin/iptables -P OUTPUT ACCEPT
/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
----------------------------------------------------------------------------
--------------------------------------------------------------------------
thanks,
Fernando Pando
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://ds9a.nl/2.4Routing/
Quoted 3 lines · Largo Hellenz
hi,
first, i'd like to say im so happy this list is finally back up!!!!
I'm happy too :-)
Quoted 3 lines
those two connect to a central 2.4.2 machine with 5 nics.
box C (eth0 10.0.0.1/24, eth1 10.1.1.2/24, eth2 10.2.2.2/24, eth310.3.3.1/24, eth4 10.4.4.1/24)
Very impressive.
Quoted 3 lines
the most important thing is to load balence between the two cable modems
and route all traffic out the right way if one of the cable modems goes down.
This depends greatly on what's on the other side of the cable modems - are there two separate ISPs?
This situation is very difficult to resolve properly, the best way is to experiment a bit. You will most probably need a cronscript to detect which modems are operating.
Quoted 3 lines
if possible, possibly even send some packets out one way and some out
aNother (based on payload content and packet tagging?) but this is for my next lesson :)
Policy routing does this for you, and may in fact be the best solution. Route part of your customers to one modem, and others to the other, if both are functioning. If you detect that stuff is down, route everybody to the other one.
Quoted 8 lines
[root@io /root]# cat masquerade
#!/bin/shmodprobe
ip_tables
modprobeip_nat_ftp
modprobeip_conntrack
modprobeip_conntrack_ftp
modprobeiptable_nat
Having modules autoload themselves is way easier, bt.
Quoted 3 lines
echo 1 >
/proc/sys/net/ipv4/ip_forward
/sbin/iptables-F
I would advise to change the path, so you can leave out the redundant /sbin on every line.
Regards,
bert
Signature · 8 lines
http://www.PowerDNS.com Versatile DNS Software & Services Trilab The Technology People Netherlabs BV / Rent-a-Nerd.nl - Nerd Available - 'SYN! .. SYN|ACK! .. ACK!' - the mating call of the internet _______________________________________________ LARTC mailing list / [email protected] http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://ds9a.nl/2.4Routing/
Quoted 8 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of bert hubert
Sent: Sunday, September 23, 2001 10:59 AM
To: [email protected]
Subject: Re: [LARTC] 2 gateways ou
Quoted 6 lines
Quoted 3 lines
the most important thing is to load balence between the two cable modems
and route all traffic out the right way if one of the cable modems goes down.This depends greatly on what's on the other side of the cable modems - are there two separate ISPs?
yes. two different providers.
Quoted 3 lines
This situation is very difficult to resolve properly, the best way is to experiment a bit. You will most probably need a cronscript to detect which modems are operating.
so i would ping both of my two gateways via the cronscripts and, if the current
default gateway is down, and the standby is up, then change default gateway?
but what if both are up? is this where policy routing steps in? would policy routing replace any pinging cronscripts?
Quoted 4 lines
Policy routing does this for you, and may in fact be the best solution. Route part of your customers to one modem, and others to the other, if both are functioning. If you detect that stuff is down, route everybody to the other one.
so policy routing dynamically routes based upon available paths on the fly? could anyone provide an example that just cuts traffic equally between the two?
lets say someone was was browsing cars.com and it was 10 hops from one ISP but only 5 from the other.... can policy routing tell those packets to use the shorter path? or is this something that routing daemons are for? or is there another way to solve this puzzle?
Quoted 10 lines
Quoted 8 lines
[root@io /root]# cat masquerade
#!/bin/shmodprobe
ip_tables
modprobeip_nat_ftp
modprobeip_conntrack
modprobeip_conntrack_ftp
modprobeiptable_natHaving modules autoload themselves is way easier, bt.
do you mean droping these commands in an init script so they always come up at boot time? or something else?
thanks,
Fernando Pando
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://ds9a.nl/2.4Routing/
Quoted 4 lines · Largo Hellenz
Quoted 2 lines
This depends greatly on what's on the other side of the cable modems - are there two separate ISPs?
yes. two different providers.
Ok. This rules out a lot of fancy tricks.
Quoted 3 lines
so i would ping both of my two gateways via the cronscripts and, if the current
default gateway is down, and the standby is up, then change default gateway?
With policy routing, you can have multiple default gateways.
Quoted 3 lines
so policy routing dynamically routes based upon available paths on the fly? could anyone provide an example that just cuts traffic equally between the two?
Well, you could try something like this:
# ip route add default nexthop via 10.0.0.1 dev eth0 \ nexthop via 10.0.0.202 dev eth1
Not sure if this is 'sticky'. This might just assign TCP sessions to a single cablemodem, then again, it might not. I would vote against this. Your users would also fall victim to the 'AOL Proxy Problem'. In the midst of browsing a site, they continually appear from two different IP addresses, which may upset loadbalancing tools.
Quoted 4 lines
lets say someone was was browsing cars.com and it was 10 hops from one ISP but only 5 from the other.... can policy routing tell those packets to use the shorter path? or is this something that routing daemons are for? or is there another way to solve this puzzle?
You could try tricks with squid, which has been known to have some kind of support for this. Your best best is to have multiple route tables, and route these tables differently.
This page appears to be relevant:
http://mlarchive.ima.com/linux-net/1999/3495.html
Quoted 2 lines
do you mean droping these commands in an init script so they always come up at boot time? or something else?
These modules can be autoloaded by the kernel. Make sure that you have modutils 2.4.x!
Regards,
bert
Signature · 8 lines
http://www.PowerDNS.com Versatile DNS Software & Services Trilab The Technology People Netherlabs BV / Rent-a-Nerd.nl - Nerd Available - 'SYN! .. SYN|ACK! .. ACK!' - the mating call of the internet _______________________________________________ LARTC mailing list / [email protected] http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://ds9a.nl/2.4Routing/