Skip to Content
Linux Networking Cookbook
book

Linux Networking Cookbook

by Carla Schroder
November 2007
Beginner
642 pages
15h 43m
English
O'Reilly Media, Inc.
Content preview from Linux Networking Cookbook

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 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

Discussion

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

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Linux Networking Cookbook

Linux Networking Cookbook

Gregory Boyce
Linux Security Cookbook

Linux Security Cookbook

Daniel J. Barrett, Richard E. Silverman, Robert G. Byrnes

Publisher Resources

ISBN: 9780596102487Errata Page