Here's the script I use.
I have an RCA cable modem on eth1.
Things not apparent from the script:
1. My password is in chap/pap secrets.
2. cable.netvision.net.il is in /etc/hosts.
3. I run my own nameserver, hence my permanent resolv.conf.
4. It does not work at boot time.
5. /etc/rc.d/init.d/fwstart contains my firewall rules.
This script was built on the work of others, long forgotten, but not
unapreciated.
The script is provided under the time honored "Caveat Emptor" warranty.
Geoff.
--
Geoffrey S. Mendelson
MobilEye Vision Technologies Ltd, R.M.P.E House, 10 Hartom St. Har Hotzvim
Jerusalem, 91450 Israel Tel: +972-2-5417-356 Cell: +972-55-667-090
Do sysadmins count networked sheep?
#!/bin/bash
USERNAME="****"
PS=`ps -ax | grep dhclient | grep eth1 | awk "{print \\$1}"`
if [ " " != " $PS" ] ; then
echo "killing dhcp client for eth1 psid " $PS
kill -KILL $PS
else
echo "no dhcp client running for eth1 (good)"
fi
PS=`ps -ax | grep cable.netvision.net.il | grep pptp-linux | awk "{print \\$1}"`
if [ " " != " $PS" ] ; then
echo "killing pptp client for netvision psid " $PS
kill -KILL $PS
else
echo "no pptp client running for netvision (good)"
fi
echo "shutting down eth1"
/sbin/ifdown eth1
echo "restarting eth1"
/sbin/ifup eth1
INET=`ifconfig eth1 | grep inet | grep addr | awk "{print \\$2}" | awk -F: "{print
\\$2}"`
echo "IP address from cable modem is " $INET
if [ " " == " $INET" ] ; then
PS=`ps -ax | grep dhclient | grep eth1 | awk "{print \\$1}"`
if [ " " != " $PS" ] ; then
echo "killing dhcp client for eth1 psid " $PS
kill -KILL $PS
echo "giving up"
exit 1
fi
fi
CABLEGW=`cat /etc/dhcpc/dhcpcd-eth1.info | grep GATEWAY | cut -d"=" -f2`
echo "adding route via" $CABLEGW
/sbin/route add -host cable.netvision.net.il dev eth1
echo "starting pptp"
/usr/sbin/pptp-linux cable.netvision.net.il user $USERNAME debug mtu 1452 mru 1452
noauth
echo "waiting 30 seconds"
sleep 30
NEWGW=$(/sbin/ifconfig ppp0 | grep inet | cut -d":" -f3 | tail -1 | cut -d" " -f1)
echo "deleting old default route"
/sbin/route del default dev eth1
#if [ " $NEWGW" == " " ] ; then
# echo "PPTP connection to netvision failed. Giving up."
# exit
# fi
echo "seting default route to "$NEWGW
/sbin/route add default gw $NEWGW
echo "starting firewall"
/etc/rc.d/init.d/fwstart
echo "Fixing resolv.conf"
cp /etc/resolv.conf.save /etc/resolv.conf
NEWLOCAL=$(/sbin/ifconfig ppp0 | grep inet | cut -d":" -f2 | tail -1 | cut -d" " -f1)
echo $NEWLOCAL | su gsm -c "mail -s 'Cable: new ip address $NEWLOCAL' <my email at
work>"
=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]