Skip to main content

Posts

Showing posts from April, 2011

Load balance 2 WAN links BASH script

BASH script to load balance 2 WAN links.
#!/bin/bash # # bal_localLoad-balance internet connection over two local links # # Version:1.0.0 - Fri, Sep 26, 2008 # # Author:Niels Horn #
# Set devices: DEV1=${1-eth0}# default eth0 DEV2=${2-ppp0}# default ppp0
# Get IP addresses of our devices: ip1=`ifconfig $DEV1 | grep inet | awk '{ print $2 }' | awk -F: '{ print $2 }'` ip2=`ifconfig $DEV2 | grep inet | awk '{ print $2 }' | awk -F: '{ print $2 }'`
# Get default gateway for our devices: gw1=`route -n | grep $DEV1 | grep '^0.0.0.0' | awk '{ print $2 }'` gw2=`route -n | grep $DEV2 | grep '^0.0.0.0' | awk '{ print $2 }'`
echo "$DEV1: IP=$ip1 GW=$gw1" echo "$DEV2: IP=$ip2 GW=$gw2"
### Definition of routes ###
# Check if tables exists, if not -> create them: if [ -z "`cat /etc/iproute2/rt_tables | grep '^251'`" ] ; then echo "251rt_dev1" >> /etc/iproute2/rt_tables fi if [ -z "`cat /etc/iproute2…