StinkiePhish n00b

Joined: 30 Jul 2004 Posts: 10
|
Posted: Mon May 09, 2005 10:06 pm Post subject: Multipath uplink - Same Gateways=Problem? |
|
|
Hello Again,
I have successfully set up a multipath router with 4 DSL modems which receive IP's dynamically. I started this discussion here: https://forums.gentoo.org/viewtopic-t-286976-start-0-postdays-0-postorder-asc-highlight-.html Basically, with some kernel patches, iproute2, and SNAT routing with iptables, users on the LAN experience load balancing over the connections.
Everything has been working beautifully, until two of the DSL connections were assigned IP addresses that gave them the same gateway. Suddenly, outbound traffic was irratic and HTTP pages were loading at random speeds. I guessed that pages were loading from the good connections (or the Squid cache) but the server was getting confused with the two addresses with the same gateway. Please excuse the personification of the server for simplicity, although it's easy to have an emotional attachment with a Gentoo server.
I ran into this same problem originally setting this system up. I had PPPoE occur on the SBC DSL routers and perform NAT. Yes, it would be a NAT (the modem to server) within a NAT (server to LAN). I statically assigned the server's 4 ethernet cards 192.168.0.x addresses, as the modems are hardcoded to each have the address 192.168.0.1.
eth0 is connected to the LAN with IP 192.168.1.1, and everyone internally has 192.168.1.x addresses.
The routing tables (roughly) looked like this:
eth1 192.168.0.2 to gateway 192.168.0.1
eth2 192.168.0.3 to gateway 192.168.0.1
eth3 192.168.0.4 to gateway 192.168.0.1
eth4 192.168.0.5 to gateway 192.168.0.1
Nothing worked with this setup. So I had the server negotiate the PPPoE connections with rp-pppoe and pull the external addresses. The routing scripts pull the IP's from ifconfig and setup the routing tables. Like I said, this was working beautifully until two of the addresses were set to use the same gateway, and the previous experience above led me to believe that it was the similar gateway causing the problems.
Is this an impossible setup to use PPPoE on the SBC modems, with the same hardcoded IP but different physical hardware? This, at least I believe, would mean that the routing scripts won't have to be occassionally updated because the IPs and gateways of the external ethernet cards would be static. Why are (if this is correct observation by me) the duplicate gateways causing all of this to fail?
For reference, here is my script for the routing, currently working assuming that I have four connections with four different gateways. Pieced together from many different sources. Thank you to everyone that has contributed.
Code: | #!/bin/bash
### Set Variables ###
# Link 1
EXTIF1=ppp0
EXTIP1=$(ifconfig ppp0 | grep 'inet addr:' | awk '{print $2}' | sed -e 's/.*://')
EXTM1=24
EXTGW1=$(ifconfig ppp0 | grep 'inet addr:' | awk '{print $3}' | sed -e 's/.*://')
# Link 2
EXTIF2=ppp1
EXTIP2=$(ifconfig ppp1 | grep 'inet addr:' | awk '{print $2}' | sed -e 's/.*://')
EXTM2=24
EXTGW2=$(ifconfig ppp1 | grep 'inet addr:' | awk '{print $3}' | sed -e 's/.*://')
# Link 3
EXTIF3=ppp2
EXTIP3=$(ifconfig ppp2 | grep 'inet addr:' | awk '{print $2}' | sed -e 's/.*://')
EXTM3=24
EXTGW3=$(ifconfig ppp2 | grep 'inet addr:' | awk '{print $2}' | sed -e 's/.*://')
# Link 4
EXTIF4=ppp3
EXTIP4=$(ifconfig ppp3 | grep 'inet addr:' | awk '{print $2}' | sed -e 's/.*://')
EXTM4=24
EXTGW4=$(ifconfig ppp3 | grep 'inet addr:' | awk '{print $2}' | sed -e 's/.*://')
##### ROUTING #####
# Remove all old rules and routes
echo " del table main"
ip rule del table main
echo " del from 0/0 table 180"
ip rule del from 0/0 table 180
echo " del from ext1 table 201"
ip rule del from ${EXTIP1}/${EXTM1} table 201
echo " del from ext2 table 202"
ip rule del from ${EXTIP2}/${EXTM2} table 202
echo " del from ext3 table 203"
ip rule del from ${EXTIP3}/${EXTM3} table 203
echo " del from ext4 table 204"
ip rule del from ${EXTIP4}/${EXTM4} table 204
echo " del table 222"
ip rule del table 222
# Flush tables
echo " flush table 180"
ip route flush table 180
echo " flush table 201"
ip route flush table 201
echo " flush table 202"
ip route flush table 202
echo " flush table 203"
ip route flush table 203
echo " flush table 204"
ip route flush table 204
echo " flush table 222"
ip route flush table 222
echo " flush table 180"
ip route flush cache table 180
echo " del default via gateway1"
ip route del default via ${EXTGW1} dev ${EXTIF1} src ${EXTIP1} table 201
echo " del default via gateway2"
ip route del default via ${EXTGW2} dev ${EXTIF2} src ${EXTIP2} table 202
echo " del default via gateway3"
ip route del default via ${EXTGW3} dev ${EXTIF3} src ${EXTIP3} table 203
echo " del default via gateway4"
ip route del default via ${EXTGW4} dev ${EXTIF4} src ${EXTIP4} table 204
echo " del default equalize table 222"
ip route del default equalize table 222
# Bring up internal network
echo " bringing up internal network"
ip link set eth0 up
ip addr add 192.168.1.1/24 brd + dev eth0
ip rule add prio 50 table main
ip route del default table main
ip route add prio 180 from 0/0 table 180
#ip link set ${EXTIF1} up
#ip addr flush dev ${EXTIF1}
#ip addr add ${ETHIP1}/${EXTM1} brd 69.212.104.255 dev ${EXTIF1}
#ip link set ${EXTIF2} up
#ip addr flush dev ${EXTIF2}
#ip addr add ${ETH2IP}/${EXTM2} brd 69.212.101.255 dev ${EXTIF2}
#ip link set ${EXTIF3} up
#ip addr flush dev ${EXTIF3}
#ip addr add ${ETH3IP}/${EXTM3} brd 69.214.226.255 dev ${EXTIF3}
#ip link set ${EXTIF4} up
#ip addr flush dev {EXTIF4}
#ip addr add ${ETH4IP}/${EXTM4} brd 69.214.233.255 dev ${EXTIF4}
ip rule add prio 201 from ${EXTIP1}/${EXTM1} table 201
ip route add default via ${EXTGW1} dev ${EXTIF1} src ${EXTIP1} proto static table 201
ip route append prohibit default table 201 metric 1 proto static
ip rule add prio 202 from ${EXTIP2}/${EXTM2} table 202
ip route add default via ${EXTGW2} dev ${EXTIF2} src ${EXTIP2} proto static table 202
ip route append prohibit default table 202 metric 1 proto static
ip rule add prio 203 from ${EXTIP3}/${EXTM3} table 203
ip route add default via ${EXTGW3} dev ${EXTIF3} src ${EXTIP3} proto static table 203
ip route append prohibit default table 203 metric 1 proto static
ip rule add prio 204 from ${EXTIP4}/${EXTM4} table 204
ip route add default via ${EXTGW4} dev ${EXTIF4} src ${EXTIP4} proto static table 204
ip route append prohibit default table 204 metric 1 proto static
#ip route add 192.168.0.0/24 dev eth1 src 192.168.0.2 table 201
#ip route add 192.168.0.0/24 dev eth2 src 192.168.0.3 table 202
#ip route add 192.168.0.0/24 dev eth3 src 192.168.0.4 table 203
#ip route add 192.168.0.0/24 dev eth4 src 192.168.0.5 table 204
ip rule add prio 222 table 222
ip route add default equalize table 222 proto static \
nexthop via ${EXTGW1} dev ${EXTIF1} \
nexthop via ${EXTGW2} dev ${EXTIF2} \
nexthop via ${EXTGW3} dev ${EXTIF3} \
nexthop via ${EXTGW4} dev ${EXTIF4}
ip route flush cache |
|
|