All of this was very helpful. I now have my server running with two PPPOE accounts and load balancing between them. (For torrents the highest speed I've seen is 958 kBytes/s.)
I even got creative and did the same for my eth0 and wan0 since NetworkManager activates both devices. Here's the main part:
Code:
########################################################
# Do a check for multiple routes on single Network
########################################################
DefaultRouteIP=$(/sbin/ip route | grep "default via" | awk {'print $3'});
DefaultRoute=$(/sbin/ip route | grep "default via" | awk {'print $5'});
DefaultMask=$(/sbin/ip route | grep "scope link" | grep "$DefaultRoute" | awk {'print $1'})
let TotalRoutes=$(/sbin/ip route | grep "scope link" | grep "$DefaultMask" | wc -l)
if [ $TotalRoutes -gt 1 -a "$DefaultRouteIP" != "" ] ; then
echo "Found Routes: $TotalRoutes" >> /var/log/cf_register.log
BuildCMD="/sbin/ip route change default equalize scope global"
for routeDev in $(/sbin/ip route | grep "scope link" | grep "$DefaultMask" | awk {'print $3'} | sort -u) ; do
if [ "$(echo $routeDev | tr -d '[:digit:]')" == "wlan" ] ; then
BuildCMD=$BuildCMD" nexthop via $DefaultRouteIP dev $routeDev weight 1";
else
BuildCMD=$BuildCMD" nexthop via $DefaultRouteIP dev $routeDev weight 2";
fi
done
$BuildCMD;
/sbin/ip route flush cache
fi
#############################################################
# Do a check for multiple ppp routes
# As in we have multiple dial in or pppoe accounts active
#############################################################
let TotalRoutes=$(/sbin/ip route | grep "scope link" | grep "ppp" | wc -l)
if [ $TotalRoutes -gt 1 ] ; then
echo "Found Routes: $TotalRoutes" >> /var/log/cf_register.log
BuildCMD="/sbin/ip route change default equalize scope global"
for routeDev in $(/sbin/ip route | grep "scope link" | grep "ppp" | awk -F"dev" {'print $2'} | awk {'print $1'} | sort -u) ; do
BuildCMD=$BuildCMD" nexthop dev $routeDev weight 1";
done
$BuildCMD;
/sbin/ip route flush cache
fi
I just inserted this code into the /etc/NetworkManager/dispatcher.d/ folder and it runs every time NetworkManager changes.
code in dispatcher.d:
Code:
#!/bin/bash
export LC_ALL=C
echo "Triggered: $(date) $*" 1>> /var/log/cf_register_nm.log 2>&1
if [ "$2" == "down" ]; then
/usr/bin/cf_register.sh display 1>> /var/log/cf_register_nm.log 2>&1
fi
if [ "$2" == "up" ]; then
/usr/bin/cf_register.sh display 1>> /var/log/cf_sendmail_nm.log 2>&1
fi