[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: changing resolve.conf for deferent providers



Micha Feigin writes:
> Is it posible to make the use of deferent resolve.conf for deferent
> providers automatic?

You need to put a script in /etc/ppp/ip-up.d that replaces /etc/resolv.conf
with the one appropriate to the current provider, and another in
/etc/ppp/ip-down to restore resolv.conf.

Here are some scripts and replacement pon to try.  You will need to create
/etc/ppp/resolv and put a "resolv.conf" in it for each provider.  A future
version of pppconfig will set all of this up.

--------------------------------------------------------------------------

#!/bin/sh

# 0dns-up by John Hasler 4 Apr 1999.  You may treat this program as if it
# was in the public domain.

# 0dns-up sets up /etc/resolv.conf for the provider being connected to.  In
# conjunction with pppd's usepeerdns option it also handles dynamic dns.
# It expects to be passed the provider name in $6.

PROVIDER=$6
ETC=/etc
PPPRESOLV=/etc/ppp/resolv
TEMPRESOLV=$ETC/resolv.conf.ppp.temp$$
RESOLVBAK=$ETC/resolv.conf.ppp.bak
RESOLVCONF=$ETC/resolv.conf

# We can do nothing if we have not been passed a provider name via ipparam
# or there is no resolv file for the provider.  We better not do anything
# if resolv.conf.bak already exists.

[ -f "$PPPRESOLV/$PROVIDER" ] && [ ! -f "$RESOLVBAK" ] || ( echo "failed"; exit 0 )

# USEPEERDNS, DNS1, and DNS2 are variables exported by pppd.  Do we have
# usepeerdns and a couple of nameservers?  If so, put a couple of
# nameserver lines in a temp file.

if [ "$USEPEERDNS" ] && [ "$DNS1" ] && [ "$DNS2" ] ; then
    echo -e "nameserver $DNS1 \nnameserver $DNS2" > $TEMPRESOLV
fi

# Append the resolv.conf for this provider to the temp file.  If we are
# using dynamic dns it will be empty or contain any resolver options the
# user added.  Otherwise it will be a complete resolv.conf for this
# provider.

cat $PPPRESOLV/$PROVIDER >> $TEMPRESOLV

# Back up resolv.conf.

cp $RESOLVCONF $RESOLVBAK

# And replace it with the new resolv.conf from the temp file.

mv $TEMPRESOLV $RESOLVCONF

-------------------------------------------------------------------------------

#!/bin/sh

# 0dns-down by John Hasler 4 Apr 1999.  You may treat this program as if it
# was in the public domain.

# 0dns-down takes down what 0dns_up sets up.

ETC=/etc
RESOLVBAK=$ETC/resolv.conf.ppp.bak
RESOLVCONF=$ETC/resolv.conf

[ "$RESOLVBAK" ] && mv $RESOLVBAK $RESOLVCONF


----------------------------------------------------------------------------

#!/bin/sh
/usr/sbin/pppd call ${1:-provider} ipparam ${1:-provider}

-----------------------------------------------------------------------------
-- 
John Hasler                This posting is in the public domain.
john@dhh.gt.org		   Do with it what you will.
Dancing Horse Hill         Make money from it if you can; I don't mind.
Elmwood, Wisconsin         Do not send email advertisements to this address.


Reply to: