18.6. Setting Up Dial-on-Demand
Problem
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.
Solution
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 demandIt 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 demandShut down the link with poff:
# poffDiscussion
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access