Networking Forums

Networking Forums > Computer Networking > Linux Networking > PPP on demand

Reply
Thread Tools Display Modes

PPP on demand

 
 
Hermes
Guest
Posts: n/a

 
      04-27-2004, 10:42 PM
My application calls "gethostbyname" to get the IP address
of a host. I have pppd setup for on-demand dialing, but the
following is happening:

1) I run the application and it is unable to connect. The
application finishes immediately.
2) After the application finishes, pppd dials automatically and
connects to my ISP. So, on-demand dialup is kind of working.
3) If I run the application again, it works fine and reports the
IP address returned by gethostbyname.
4) After a while, the connection times out and is dropped (good)
5) If I run the application again, the gethostbyname system call
will pause program execution and only resume after the
on demand dialup connection is re-established (which is the
desired behaviour).

Any suggestion is welcome. I've been trying to fix this
for more than three days now...

FYI, the file /proc/sys/net/ipv4/ip_dynaddr exists and contains
a '1' character.

Here is my /etc/ppp/options file:

crtscts
asyncmap
defaultroute
demand
dump
idle 60
ipcp-accept-local
ipcp-accept-remote
lcp-echo-failure 4
lcp-echo-interval 30
lock
noauth
noipdefault
passive
proxyarp
show-password
debug
kdebug 10
usepeerdns
remotename modem
defaultroute
defaultroute

Kernel version: 2.4.20.
pppd version: How do I get this? Anyway, it supports
the on-demand dialup.

Thanks!
-H


 
Reply With Quote
 
 
 
 
Clifford Kite
Guest
Posts: n/a

 
      04-28-2004, 01:13 AM
Hermes <(E-Mail Removed)> wrote:
> My application calls "gethostbyname" to get the IP address
> of a host. I have pppd setup for on-demand dialing, but the
> following is happening:


> 1) I run the application and it is unable to connect. The
> application finishes immediately.


Immediately is pretty fast.

> 2) After the application finishes, pppd dials automatically and
> connects to my ISP. So, on-demand dialup is kind of working.
> 3) If I run the application again, it works fine and reports the
> IP address returned by gethostbyname.
> 4) After a while, the connection times out and is dropped (good)
> 5) If I run the application again, the gethostbyname system call
> will pause program execution and only resume after the
> on demand dialup connection is re-established (which is the
> desired behaviour).


> Any suggestion is welcome. I've been trying to fix this
> for more than three days now...


You can *try* adding

options attempts:5 rotate

to /etc/resolv.conf . This should keep the application trying DNS server
lookups, especially if you have more than one nameserver IP address. You
might want to checkout "man 5 resolver" for other options.

> FYI, the file /proc/sys/net/ipv4/ip_dynaddr exists and contains
> a '1' character.


> Here is my /etc/ppp/options file:


> crtscts
> asyncmap
> defaultroute
> demand
> dump
> idle 60
> ipcp-accept-local
> ipcp-accept-remote
> lcp-echo-failure 4
> lcp-echo-interval 30
> lock
> noauth
> noipdefault
> passive
> proxyarp
> show-password
> debug
> kdebug 10


The kdebug option is useless for pppd version 2.4.1 or greater.

> usepeerdns
> remotename modem


Beats me as to why you use remotename, much less with a value of "modem."
Unless you must authenticate with MS CHAP.

> defaultroute
> defaultroute


The two above now makes 3 defaultroute entries. ?

> Kernel version: 2.4.20.
> pppd version: How do I get this? Anyway, it supports
> the on-demand dialup.


pppd --version

--
Clifford Kite Email: "echo xvgr_yvahk-(E-Mail Removed)|rot13"
PPP-Q&A links, downloads: http://ckite.no-ip.net/
/* The signal-to-noise ratio is too low in many [news] groups to make
* them good candidates for archiving.
* --- Mike Moraes, Answers to FAQs about Usenet */
 
Reply With Quote
 
Hermes
Guest
Posts: n/a

 
      04-28-2004, 10:27 PM
Clifford Kite wrote:

<snip>
> You can *try* adding
>
> options attempts:5 rotate
>
> to /etc/resolv.conf . This should keep the application trying DNS server
> lookups, especially if you have more than one nameserver IP address. You
> might want to checkout "man 5 resolver" for other options.

<snip>

Clifford,

You pointed me in the right direction. I get the desired behavior by
creating a resolv.conf file with the following content:

nameserver 206.12.28.13
options attempts:5

However, this is not an acceptable solution because in reality the ISP
provides the DNS servers to use and I don't have the DNS before connection.
What should I put in the file instead of nameserver x.x.x.x, if the ISP
provides the name servers dinamically?

If I try without the nameserver line or with "nameserver 0", it doesn't
work (same original behavior).

Thanks!
-H
 
Reply With Quote
 
Clifford Kite
Guest
Posts: n/a

 
      04-29-2004, 03:34 PM
Hermes <(E-Mail Removed)> wrote:

> You pointed me in the right direction. I get the desired behavior by
> creating a resolv.conf file with the following content:


> nameserver 206.12.28.13
> options attempts:5


> However, this is not an acceptable solution because in reality the ISP
> provides the DNS servers to use and I don't have the DNS before connection.


The IP addresses of DNS name servers very seldom change.

> What should I put in the file instead of nameserver x.x.x.x, if the ISP
> provides the name servers dinamically?


Sounds like RH and friends. If pppd is configured with the option
usepeerdns and the ISP agrees to provide name server address(es)
within PPP negotiations then pppd creates or overwrites the file
/etc/ppp/resolv.conf. Some distributions link /etc/resolv.conf to
that file, or perhaps replace /etc/resolv.conf with it. In either
case any options in /etc/resolv.conf very likely go away.

There may be an option for a distribution configuration script to
disable using "dynamic DNS" for PPP. In that case, configure to
disable and put the name server addresses from /etc/ppp/resolv.conf
(there should be at least two - if not the ISP web pages *should*
provide at least two name server addresses) in /etc/resolv.conf,
along with the options that I suggested.

This would be the best thing to do when using demand pppd.

--
Clifford Kite Email: "echo xvgr_yvahk-(E-Mail Removed)|rot13"
PPP-Q&A links, downloads: http://ckite.no-ip.net/
/* The generation of random numbers is too important to be left
to chance. */
 
Reply With Quote
 
Hermes
Guest
Posts: n/a

 
      04-29-2004, 06:15 PM
> > What should I put in the file instead of nameserver x.x.x.x, if the ISP
> > provides the name servers dinamically?

>
> Sounds like RH and friends. If pppd is configured with the option
> usepeerdns and the ISP agrees to provide name server address(es)
> within PPP negotiations then pppd creates or overwrites the file
> /etc/ppp/resolv.conf. Some distributions link /etc/resolv.conf to
> that file, or perhaps replace /etc/resolv.conf with it. In either
> case any options in /etc/resolv.conf very likely go away.
>
> There may be an option for a distribution configuration script to
> disable using "dynamic DNS" for PPP. In that case, configure to
> disable and put the name server addresses from /etc/ppp/resolv.conf
> (there should be at least two - if not the ISP web pages *should*
> provide at least two name server addresses) in /etc/resolv.conf,
> along with the options that I suggested.
>
> This would be the best thing to do when using demand pppd.


Understood.

I'm using Slackware, and I inherited this from a departing contractor.
This project is a linux box that will be used by generic user of an
actual product. It has an application with a screen that allows users
to configure the modem connection. I'm trying to make it as easy as
possible for the user, since this box may be used by absolute
beginners.

Indeed, /etc/resolv.conf is a symbolic link to /etc/ppp/resolv.conf,
and I don't know how to avoid that if I want to use dynamic DNS.
I'd have to be notified by pppd that it got the DNS IPs and stuff them
in /etc/resolv.conf. Maybe I should poll the /etc/ppp/resolv.conf
to see when pppd adds the DNS IPs or poll the DNS1 and DNS2
environment variables to obtain those IPs?

As it is a linux box, I have total control over all the scripts, no
restriction so I'm open to any idea.

From your suggestion, I see you line up with the others
in opposing the use of dynamic DNS since it is <SARCASM> an
infidel Micro$oft invention to make the user's life easier and any
Micro$oft invention is evil, by definition </SARCASM>. However,
imagine a nursing home caregiver trying to use this box having to
figure out the DNS numbers to input on the screen. If the
ISP provides dynamic DNS, I'd rather use it, regardless of
ideology, wouldn't you? OTOH, if support for this feature in
pppd is crippled, too bad. I'll have to force the user to enter the
DNS server IP addresses and live with that, the product won't be
as user friendly as it could. I hope you get my point. Of course if
this were my own private system, I wouldn't have spent one minute
of my time (any repliers' time) asking this in a newsgroup.

Anyway, what is the logic in usepeerdns requiring an initial DNS to be
present in resolv.conf, if the whole point is not needing a DNS
beforehand?

Thanks!
-H


 
Reply With Quote
 
Floyd L. Davidson
Guest
Posts: n/a

 
      04-29-2004, 07:19 PM
"Hermes" <(E-Mail Removed)> wrote:
>
>Indeed, /etc/resolv.conf is a symbolic link to /etc/ppp/resolv.conf,
>and I don't know how to avoid that if I want to use dynamic DNS.
>I'd have to be notified by pppd that it got the DNS IPs and stuff them
>in /etc/resolv.conf. Maybe I should poll the /etc/ppp/resolv.conf
>to see when pppd adds the DNS IPs or poll the DNS1 and DNS2
>environment variables to obtain those IPs?


If you are concerned that pppd may not be able to correctly
populate the /etc/ppp/resolv.conf file if the ISP doesn't supply
the information, there are other ways to accomplish that which
allow for error checking. Read the man page for pppd, and look
at the description of the /usepeerdns/ option. Note that in
addition to the /etc/ppp/resolv.conf file, the IP addresses of
the DNS servers are also used to call the /etc/ppp/ip-up script.
That script can verify that the DNS server addresses are
provided, and then modify, or not, the /etc/resolv.conf file.
Search on /ip-up/ in the pppd man page and you will find various
information.

>As it is a linux box, I have total control over all the scripts, no
>restriction so I'm open to any idea.


I'm not sure just where I stole this, but here is the very
minimal ip-up script that I use,

#!/bin/sh
#
# ip-up
#
# The keyword "usepeerdns" for pppd causes this script
# to be executed when a ppp connection is made. One or
# two DNS server IP addresses are provided in environment
# variables DNS1 and DNS2. Also /etc/ppp/resolv.conf
# is written with appropriate entries.
#

if [ -n "${DNS1}" -o -n "${DNS2}" ]
then
> /etc/resolv.conf

if [ -n "${DNS1}" ]
then
echo "nameserver ${DNS1}" >> /etc/resolv.conf
fi
if [ -n "${DNS2}" ]
then
echo "nameserver ${DNS2}" >> /etc/resolv.conf
fi
fi

Obviously you might want to add a few things, such as a default
name server from a different organization just in case the ISP
has a problem.


>From your suggestion, I see you line up with the others
>in opposing the use of dynamic DNS since it is <SARCASM> an
>infidel Micro$oft invention to make the user's life easier and any
>Micro$oft invention is evil, by definition </SARCASM>. However,
>imagine a nursing home caregiver trying to use this box having to
>figure out the DNS numbers to input on the screen.


Without any sarcasm at all, I'll grant that almost anything from
Microsoft is questionable. However, "dynamic DNS" is the only
reasonable way to configure a dialup pppd link *if* you are
going to use the ISP's DNS servers. The suggestion that "they
are almost never changed" is true, but merely points out that
therefore when they do change the confusion over what has gone
wrong is going to significant. (I've had that happen to me
*several* times, so I'm not convinced that it is actually that
rare anyway!)

The real problem, from my perspective, is that only 3 DNS
servers can be listed in /etc/resolv.conf, instead of the dozen
or so that I would like to put there!

>If the
>ISP provides dynamic DNS, I'd rather use it, regardless of
>ideology, wouldn't you? OTOH, if support for this feature in
>pppd is crippled, too bad.


It is hardly crippled. But I'm wondering why you haven't read
the man page for pppd rather that spending time posting
guesses... ;-)

>I'll have to force the user to enter the
>DNS server IP addresses and live with that, the product won't be
>as user friendly as it could. I hope you get my point. Of course if
>this were my own private system, I wouldn't have spent one minute
>of my time (any repliers' time) asking this in a newsgroup.
>
>Anyway, what is the logic in usepeerdns requiring an initial DNS to be
>present in resolv.conf, if the whole point is not needing a DNS
>beforehand?
>
>Thanks!
>-H


--
Floyd L. Davidson <http://web.newsguy.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) (E-Mail Removed)
 
Reply With Quote
 
Hermes
Guest
Posts: n/a

 
      04-29-2004, 09:11 PM
Floyd L. Davidson wrote:

> If you are concerned that pppd may not be able to correctly
> populate the /etc/ppp/resolv.conf file if the ISP doesn't supply
> the information, there are other ways to accomplish that which
> allow for error checking. Read the man page for pppd, and look
> at the description of the /usepeerdns/ option. Note that in
> addition to the /etc/ppp/resolv.conf file, the IP addresses of
> the DNS servers are also used to call the /etc/ppp/ip-up script.
> That script can verify that the DNS server addresses are
> provided, and then modify, or not, the /etc/resolv.conf file.
> Search on /ip-up/ in the pppd man page and you will find various
> information.


Actually I had seen that info in the past and forgot about it. It
sure is the solution for the matter of getting notified by pppd when
the DNS IPs are retrieved, thanks!

However, the actual problem I have boils down to this:

1) I want to use dynamic DNS
2) I want the gethostbyname call in my app to stop execution until
pppd has established a connection and retrieved the correct
host's IP address, transparently to the app.

To have that behavior, what I have done so far is:

a) Added usepeerdns to the pppd options
b) Made /etc/resolv.conf a symbolic link to /etc/ppp/resolv.conf

But what happens is:

I) If I leave /etc/ppp/resolv.conf empty or non-existing, the call
to gethostbyname doesn't wait until pppd dials up
II) If I create the file only with "options attempts:5", same behavior
III) If I add "nameserver x.x.x.x" (where x.x.x.x is bogus), the call
to gethostbyname *does* wait but after the dialup happens
it fails to retrieve the host's IP address. Even if I try
to call gethostbyname a second time in the app, it fails. I have
to restart the application, and then it works (since pppd is
already connected)
IV) If "nameserver x.x.x.x" points to one of the DNSs returned
from the ISP (I find that out by looking at resolv.conf's contents),
then everything works fine. But, hey, that's cheating and doesn't
solve my problem...

> Obviously you might want to add a few things, such as a default
> name server from a different organization just in case the ISP
> has a problem.


Might be a less-than-ideal solution I'll end up using...
would you have one such stable DNS I could forever rely upon?

> It is hardly crippled. But I'm wondering why you haven't read
> the man page for pppd rather that spending time posting
> guesses... ;-)


Sorry, I was unjust. In fact, the DNS's are being retrieved and
the ppp/resolv.conf file is generated correctly. I was just looking
for a way to have my gethostbyname call to hold on during dialup,
so that talk about polling DNS was a diversion from the original
subject and I forgot I had read about the ip-up script being
called...

> Ukpeagvik (Barrow, Alaska) (E-Mail Removed)


Brrrr!!! Wrong hemisphere for penguins, no? Duh.

--
Thanks,
-H (Mountain View, California)
 
Reply With Quote
 
Clifford Kite
Guest
Posts: n/a

 
      04-29-2004, 11:22 PM
Hermes <(E-Mail Removed)> wrote:

> I'm using Slackware, and I inherited this from a departing contractor.
> This project is a linux box that will be used by generic user of an
> actual product. It has an application with a screen that allows users
> to configure the modem connection. I'm trying to make it as easy as
> possible for the user, since this box may be used by absolute
> beginners.


If you want GUI configuration tools then Slackware isn't what you need
for a "generic user."

> Indeed, /etc/resolv.conf is a symbolic link to /etc/ppp/resolv.conf,
> and I don't know how to avoid that if I want to use dynamic DNS.
> I'd have to be notified by pppd that it got the DNS IPs and stuff them
> in /etc/resolv.conf. Maybe I should poll the /etc/ppp/resolv.conf
> to see when pppd adds the DNS IPs or poll the DNS1 and DNS2
> environment variables to obtain those IPs?


I'm not sure what "poll" means here. You can use DNS1 and DNS2 in the
/etc/ppp/ip-up script to configure /etc/resolv.conf at each connection.

> As it is a linux box, I have total control over all the scripts, no
> restriction so I'm open to any idea.


I'd suggest trying Floyd Davidson's script with this modification:

Replace the line
> /etc/resolve.conf


with the line
/bin/cp -a /etc/ppp/resolve.conf.db /etc/resolv.conf

where the resolve.conf.db file contains the line
options attempts:5 rotate

but nothing else.

You *will* need nameservers and that option configured in the initial
/etc/resolv.conf or the immediate timeout will occur when it's first
used. Of course if the ISP, as unlikely as it may seem, refuses to dole
out nameserver IP addresses via PPP then things will fall apart.

No guarantee.

> From your suggestion, I see you line up with the others
> in opposing the use of dynamic DNS since it is <SARCASM> an
> infidel Micro$oft invention to make the user's life easier and any
> Micro$oft invention is evil, by definition </SARCASM>. However,
> imagine a nursing home caregiver trying to use this box having to
> figure out the DNS numbers to input on the screen. If the


I didn't mentions MS at all, so you can deduce whatever you want - be it
true or false.

> ISP provides dynamic DNS, I'd rather use it, regardless of
> ideology, wouldn't you? OTOH, if support for this feature in


No.

> pppd is crippled, too bad. I'll have to force the user to enter the
> DNS server IP addresses and live with that, the product won't be
> as user friendly as it could. I hope you get my point. Of course if


If the user is going to use a *nix system then she/he should learn
something about how things are done. The user is certainly in for a
learning experience if they've just used MS, e.g., using ls instead of
dir can be a pain. At least I found it so when I dumped MS for Linux,
but got use to it and have never looked back - except to wonder at MS
marketeering..

> this were my own private system, I wouldn't have spent one minute
> of my time (any repliers' time) asking this in a newsgroup.


> Anyway, what is the logic in usepeerdns requiring an initial DNS to be
> present in resolv.conf, if the whole point is not needing a DNS
> beforehand?


There's no logic in even implementing usepeerdns except to bow to MS ways.
In my mind, and apparently that of the pppd maintainer, there is a limit
to how deeply the bow should be.

--
Clifford Kite Email: "echo xvgr_yvahk-(E-Mail Removed)|rot13"
PPP-Q&A links, downloads: http://ckite.no-ip.net/
/* Emacs vs vi:
Sort of like a Swiss Army knife versus a rapier. */
 
Reply With Quote
 
Hermes
Guest
Posts: n/a

 
      04-30-2004, 02:07 AM
Clifford Kite wrote:

> If you want GUI configuration tools then Slackware isn't what you need
> for a "generic user."


Slackware is only the distro. This box is connected to a TV set and
is controlled by a remote. The user interacts with the application's GUI
interface, and never with the command line.

<snip>

So, here is my "currently final" solution:

1) /etc/resolv.conf is a symlink to /etc/ppp/resolv.conf
2) /etc/ppp/resolv.conf initially contains two valid nameservers
(which hopefully will always be available on the web), plus the
"options attempts:5" line. This makes it work for the first connection.
3) Implemented ip-up script that appends "options attempts:5" to
/etc/ppp/resolv.conf, if DNS1 or DNS2 variable are defined. If
either is defined it means pppd has replaced my original
/etc/ppp/resolv.conf file and I need to put the options line back.

Works fine, now! The to further improvement I'd expect would be to
avoid the initial forced nameserver configuration, since the one I'm using
may disappear at some point...

Thanks, folks, I really appreciate your help!
-H
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[ppp] Two way dial on demand brankok@dkts.co.yu Linux Networking 2 05-25-2005 12:03 PM
bandwidth on demand jas Broadband 0 08-20-2004 05:48 PM
on demand dialling Richard Mayes Linux Networking 2 02-29-2004 04:46 PM
Bandwidth on demand ? Draxen Linux Networking 3 09-11-2003 12:15 PM
demand dialed ppp Ralph Blach Linux Networking 2 09-01-2003 05:39 PM



1 2 3 4 5 6 7 8 9 10 11