Suatu ketika speedy di kantor melemot. Padahal lagi butuh buat upload attachment. Akhirnya akses internet saya ganti pake IM2. Terkadang IM2 kalau dipake di kantor bisa lebih cepat daripada speedy milik kantor. Cuma kendalanya jadi males gonta-ganti koneksi. Cabut kabel LAN, trus pasang modem IM2, cabut modem, trus pasang kabel LAN lagi.

Merepotkan -_-’

Belum lagi kalo dibutuhkan untuk mengakses ke server kantor ketika lagi make koneksi IM2. Harus ganti ke jaringan kantor lagi. Jadi kepikiran gimana kalau bisa pake dua-dua koneksi tersebut. Speedy kantor aktif, IM2 juga aktif. Jadinya gk kerepotan cabut pasang modem atau kabel LAN lagi.

Setelah ndukun (baca : nggoogling) sana-sini, akhirnya menemukan sebuah metode yang namanya Load Balancing. Apa itu load balancing? Load balancing itu kurang lebih memanfaatkan dua atau lebih koneksi agar kualitas koneksi yang dihasilkan menjadi lebih baik.

Setelah ndukun, tanya-tanya juga ke master SBY, Suyono Bambang Yudoyono. Berikut adalah bash script yang saya gunakan :

#!/bin/bash
# Get IP addresses of our devices:

ip1=`ifconfig ppp0 | grep inet | awk ‘{ print $2 }’ | awk -F: ‘{ print $2 }’`
ip2=`ifconfig eth0 | grep inet | awk ‘{ print $2 }’ | awk -F: ‘{ print $2 }’`

### Definition of routes ###

# Check if tables exists, if not -> create them:
if [ -z "`cat /etc/iproute2/rt_tables | grep '^251'`" ] ; then
echo “251 ppp0″ >> /etc/iproute2/rt_tables
fi
if [ -z "`cat /etc/iproute2/rt_tables | grep '^252'`" ] ; then
echo “252 eth0″ >> /etc/iproute2/rt_tables
fi

# Define routing tables:
ip route add default via 10.64.64.64 table ppp0 dev ppp0 #10.64.64.64 default gateway buat ppp
ip route add default via 10.126.15.3 table eth0 dev eth0 #10.126.15.3 default gateway speedy kantor

# Create rules:
ip rule add from $ip1 table ppp0
ip rule add from $ip2 table eth0

# If we already have a ‘nexthop’ route, delete it:
if [ ! -z "`ip route show table main | grep 'nexthop'`" ] ; then
ip route del default scope global
fi

# Balance links based on routes:
ip route add default scope global nexthop via 10.64.64.64 dev ppp0 weight 1 nexthop via 10.126.15.3 dev eth0 weight 2

# Flush cache table:
ip route flush cache

echo “Tancap Gaaaan!!!”

# All done…

Untuk nameserver, saya biasanya memakai Opendns (208.67.222.222, 208.67.220.220)