Subject: Re: PPP problems
To: None <netbsd-help@NetBSD.org>
From: James K. Lowden <jklowden@schemamania.org>
List: netbsd-help
Date: 02/08/2005 21:32:53
On Mon, 07 Feb 2005 17:02:09 -0300, Andre Leao Macedo
<alm_nospam-netbsd@yahoo.com.br> wrote:
> James K. Lowden wrote:
> > 
> > I'm a little behind in my NetBSD list reading, so I just came across
> > your message today.  Have you had any further luck?  
> 
> Just to check, is there an easy way to update /etc/resolv.conf when the 
> ppp link is up? I saw there is usepeerdns in pppd, that may pass DNS1 
> and DNS2 to the ip-up script, but I am really not good with shell
> scripts...

It sounds like you've got things pretty much working.  :-)

'man pppd' tells us that the usepeerdns option causes /etc/ppp/resolv.conf
to be created, where we'll find DNS1 and DNS2.  So if we add those
nameservers to /etc/resolv.conf, we're done.  

My favorite way to prepend something to a file is with diff(1) and
patch(1).  I haven't seen my technique advertized elsewhere, so I'm sure
there are better ways....  Here's what I found in my old ip-up:

#!/bin/sh
...
RESOLV=/etc/resolv.conf
(cat /etc/ppp/resolv.conf; grep -v ^nameserver $RESOLV) \
        | diff -u $RESOLV - | patch

That says: catenate /etc/ppp/resolv.conf and the non-nameserver lines of
/etc/resolv.conf.  Let diff(1) compare that to /etc/resolv.conf.  By
feeding diff's output to patch(1), we modify /etc/resolv.conf while
preserving as much as possible.  
 

HTH.  

--jkl