PPPD DEMAND OPTION By: David Efflandt tech@de-srv.com Based on news posting of: Les Hazelton There do not appear to be detailed instructions or example of how to use demand dialing ppp with the pppd package. I was previously using diald in RedHat 5.2, but had trouble getting it to work in RedHat 6.1. So this is information I got from a news post of Les Hazelton about using the pppd demand option, modified for my use, and it works in RedHat Linux 6.1. One disadvantage of ppp demand dialing is that it does not have the control and monitoring pipes that can be used with diald. Note: Attempting to use a manual pppd connection on the same modem while pppd is already running in demand mode will not work (likewise if diald is running). Without a more elegant solution 'killall pppd' will kill the demand pppd. For diald see 'man diald' and related man pages about controlling it. Does anyone know why command line switches for following do not work if I change them to single dash like "-c"? If I do, bash complains that binary modifier is missing in the first if statement. Single dashes worked in Linux for Les Hazelton who I derived this from. --- /usr/sbin/ppp-auto --- #!/bin/sh if [ "$1" = "--c" ]; then killall pppd 2>/dev/null case `ps x` in pppd) sleep 1;; esac rm -f /var/lock/LCK..* /var/run/ppp*.pid rm -f /etc/ppp/report-chat sleep 1 # Use real IP's in following (or best guess): (/usr/sbin/pppd 10.0.0.1:10.0.0.2 call isp connect \ "/usr/sbin/chat -v -r /etc/ppp/report-chat -f /etc/ppp/ppp.chatscript") \ || exit 1 # Use real domain and nameserver IP's in following echo "domain isp.con" > /etc/resolv.conf echo "nameserver 192.168.1.34" >> /etc/resolv.conf echo "nameserver 192.168.1.35" >> /etc/resolv.conf echo "Enabled passive on demand ppp" exit 0 elif [ "$1" = "--l" ]; then clear 2>/dev/null tail -n 24 /var/log/messages | cut -d' ' -f5- | tr -d ^M exit 0 fi echo "Command was: $0 $@" echo "USAGE: ppp-auto --c " echo " ppp-auto --l " echo " " # last line --- /etc/ppp/ppp.chatscript TIMEOUT 10 ABORT ERROR ABORT BUSY ABORT "NO CARRIER" ABORT "NO DIALTONE" REPORT CONNECT "" "ATZ" OK "ATDT555-1212" TIMEOUT 60 CONNECT --- /etc/ppp/peers/isp --- /dev/ttyS0 115200 crtscts defaultroute lock passive demand hide-password idle 900 ipcp-accept-local ipcp-accept-remote noipdefault asyncmap a0000 name ppp0 user efflandt ipparam isp.com usepeerdns # end of options Note: This uses existing pap-secrets for 'ppp0' connection set up with the netcfg tool in RedHat. The ipparam and usepeerdns is used by ip-up.local to set /etc/resolv.conf with the domain name ($6) and nameservers ($DNS1, $DNS2) when it actually dials out. --- /etc/ppp/ip-up.local (or ip-up on non-RedHat) --- #!/bin/bash # The environment is cleared before executing this script # so the path must be reset PATH=/usr/sbin:/sbin:/usr/bin:/bin export PATH case $6 in # LAN connection (no DNS) my-lan ) echo "search" > /etc/resolv.conf sleep 1 /sbin/route add -net 192.168.0.0 netmask 255.255.0.0 $1;; # ISP isp.com | compuserve.com ) echo "domain $6" > /etc/resolv.conf echo "nameserver $DNS1" >> /etc/resolv.conf if [ $DNS2 ] ; then echo "nameserver $DNS2" >> /etc/resolv.conf fi sleep 1;; esac # last line