18.6. Setting Up Dial-on-Demand

You don't want to babysit a shared dial-up connection, or leave it on all the time; you want it to connect itself on demand, like when a user clicks on a web browser or checks email, and disconnect after a period of inactivity.

First, get WvDial and ppp working reliably, as we covered in the previous recipes.

Next, create a file called /etc/ppp/peers/demand so that it looks like this, naming your own Dialer section, modem port, and user login:

	noauth
	name wvdial
	usepeerdns
	connect "/usr/bin/wvdial --chat ISP1"
	/dev/ttyS2
	115200
	modem
	crtscts
	defaultroute
	noipdefault
	user alrac@isp.net
	idle 300
	persist
	demand
	logfd 6

Now, you can start up your new demand-dial server with the pon command, naming the configuration file you just created:

	# pon demand

It will not dial up right away, but will wait for a user to initiate a link by trying to connect to the Internet. Test this by pinging some web sites, opening a web browser, or checking email. You can verify that the pppd daemon has started with ps:

	$ ps ax | grep pppd
	 6506 ?        Ss     0:00 /usr/sbin/pppd call demand

Shut down the link with poff:

	# poff

The /etc/ppp/peers/demand file can be named anything you like.

pon means "pppd on" and poff means "pppd off."

The demand option prepares the pppd link; it configures the interface (ppp0), then stops short of connecting. Then, when packets start moving, such as checking email, pppd dials in and establishes the connection.

The persist option keeps the link open even when packets are no longer flowing over the link.

idle300 means that the connection will close after 300 seconds of inactivity. You can set this to any value, or not use it at all if you want maximum availability.

You may do all of this with ppp alone, and not use WvDial. I like WvDial because it is easy to use. WvDial assumes that most modems understand the Hayes AT command set. ppp was created in the days when modem commands were not standard, so its structure and configuration are more complex.