#!/bin/sh #If your distro doesn't load it automatically uncomment the next line. #modprobe ppp_generic # Start point to point over ethernet to the ADSL modem /usr/sbin/pptp 10.0.0.138 file /etc/ppp/options.adsl 2>&1 >/var/log/adsl-pptp.log & # Grace connect time before proceeding sleep 5 #We have 2 interfaces to the outside world. # 10.0.0.150 is the ethernet to the adsl modem (eth2) # 1.0.0.123 is the pppoe to the adsl modem (ppp0) # 2.0.0.123 is the expensive but reliable line (eth0) # 10.0.1.123 is the internal lan (eth1) # The default route is pointing to the expensive but reliable line # output of ip route list # 1.0.0.1 dev ppp0 proto kernel scope link src 1.0.0.123 # 2.0.0.1 dev eth0 proto kernel scope link src 2.0.0.123 # 10.0.0.0/24 dev eth2 proto kernel scope link src 10.0.0.150 # 10.0.1.0/24 dev eth1 proto kernel scope link src 10.0.1.123 # 127.0.0.0/8 dev lo scope link # default via 2.0.0.123 dev eth0 # Add a new identifier to the routing table if it does not exist yet. # echo "200 adsl" >> /etc/iproute2/rt_tables # echo "201 lan" >> /etc/iproute2/rt_tables # Shuffle the ip routing to do the rule based routing # anything you bind to this interface will go out over this interface ip rule add from 1.0.0.123 table adsl ip route add default via 1.0.0.123 dev ppp0 table adsl # The internal lan machine 10.0.1.111 will now be routed out over the fast adsl line # the rest will still be routed over the reliable but expensive line ip rule add from 10.0.1.111 table lan ip route add default via 1.0.0.123 dev ppp0 table lan # Flush the cache make sure the routing switches ip route flush cache # The output of ip rule list after these commands # 0: from all lookup local # 32764: from 10.0.1.111 lookup lan # 32765: from 1.0.0.123 lookup adsl # 32766: from all lookup main # 32767: from all lookup 253