#!/bin/sh # store network addresses in seperate file ROUTE_FILE=suBrisVegastlist.txt ROUTES=`cat $ROUTE_FILE` GATEWAY=192.168.6.254 DEVICE=eth0 DNS1=203.4.14.19 DNS2=203.4.17.19 DNS_LOCAL=192.168.2.254 RESOLVE_CONF=/etc/resolv.conf TLA_connect() { ifup $DEVICE cat << EOF > $RESOLVE_CONF nameserver $DNS1 nameserver $DNS2 search corp.bigcompany.org search host1.bigcompany.com.au EOF for ROUTE in $ROUTES do route add -net $ROUTE gw $GATEWAY dev $DEVICE done } TLA_disconnect() { ifdown $DEVICE cat << EOF > $RESOLVE_CONF nameserver $DNS_LOCAL search jamesmcdonald.id.au EOF # not needed if you take eth0 down # for ROUTE in $ROUTES # do # route del -net $ROUTE gw $GATEWAY dev $DEVICE # done } case $1 in "start" ) TLA_connect ;; "stop" ) TLA_disconnect ;; "restart" ) TLA_disconnect TLA_connect ;; * ) echo "Usage TLA.sh [start | stop | restart]" ;; esac