epcim
10/20/2015 - 1:42 PM

inet-dual-isp.howto.sh

inet-dual-isp.howto.sh

#!/bin/bash

. ~/hg2g/howto/howto_ifconfig-info $1
GW=$BCAST

# I do not use the Gentoo net scripts, so I start the interface here
/sbin/ifconfig $DEV $IP netmask $MASK
/sbin/ip route add $IP/32 dev $DEV src $IP table 1
/sbin/ip route add default via $GW table 1
/sbin/ip rule add from $IP table 1

T1DEV=$DEV
T1GW=$GW
route del default gw $GW
route del default gw $GW

. ~/hg2g/howto/howto_ifconfig-info $2
#$GW=172.25.25.254
$GW=$BCAST

# I do not use the Gentoo net scripts, so I start the interface here
/sbin/ifconfig $DEV $IP netmask $MASK
/sbin/ip route add $IP/24 dev $DEV src $IP table 2
/sbin/ip route add default via $GW table 2
/sbin/ip rule add from $IP table 2

T2DEV=$DEV
T2GW=$GW
route del default gw $GW
route del default gw $GW

/sbin/ip route add default scope global \
  nexthop via $T1GW dev $T1DEV weight 1 \
  nexthop via $T2GW dev $T2DEV weight 2
# cable modem is 3 times faster than my dsl

##################################
# This method is not recommended #
##################################
# Wipe out the file and give it the first nameserver
#echo "nameserver 192.168.0.1" > /etc/resolv.conf
# Add the second nameserver afterwards
#echo "nameserver bbb.bbb.bbb.bbb" >> /etc/resolv.conf