I have a Dell server with Ubuntu 11.10 Server installed on it. The server has 3 Ethernet cards eth0, eth1 and eth2.
I have two ISPs say ISP1, ISP2
eth0 has a public IP (provided by ISP1 - we require to access this service from outside our LAN) eth1 is connected to the LAN (via switch) with 192.168.X.X subnet eth2 gets a dynamic IP (via DHCP provided by ISP2) with 172.16.x.x subnet
I want to load balance (making it fault-tolerant at the same time) the two internet connections. I found the following script online to help my cause:
#!/bin/bash -v #IPs of device connected to the internet IP1=119.my.pub.ip #Public IP provided by ISP1 #dynamically alloted IP provided by ISP2 IP2=`ifconfig | awk -F: '/172.16./ {print $2}' | awk '{ORS=" "; print $1}' | awk '{print $2}'` #Your Gateways (type route in terminal it should be in the same line as default) P1=119.my.pu.gat #gateway provided by ISP1 P2=172.16.1.1 #gateway provided by ISP2 #Your Subnets P0_NET=192.168.0.0/16 #local network subnet, P1_NET=119.82.90.0/28 # Part of your gateway P2_NET=172.16.1.0/24 #Part of your gateway # NICs your internet interfaces IF1=eth0 IF2=eth2 IF0=eth1 ip route add $P1_NET dev $IF1 src $IP1 table T1 ip route add default via $P1 table T1 ip route add $P2_NET dev $IF2 src $IP2 table T2 ip route add default via $P2 table T2 ip route add $P1_NET dev $IF1 src $IP1 ip route add $P2_NET dev $IF2 src $IP2 ip rule add from $IP1 table T1 ip rule add from $IP2 table T2 ip route add $P0_NET dev $IF0 table T1 ip route add $P2_NET dev $IF2 table T1 ip route add 127.0.0.0/8 dev lo table T1 ip route add $P0_NET dev $IF0 table T2 ip route add $P1_NET dev $IF1 table T2 ip route add 127.0.0.0/8 dev lo table T2 ip route add default scope global nexthop via $P1 dev $IF1 weight 1 nexthop via $P2 dev $IF2 weight 1
I do not fully understand the script. Hence, in case the above code does not work, what is the best way to restore the machine to its original configuration ? What files need to be backed up prior to running this script?