Hi all,
Recently, I have installed dnrd to avoid problems with changing DNS
servers when using several providers. I have found that dnrd was not
properly integrated with pppd I had (both from Debian Potato, thus:
dnrd v. 2.6-1, pppd v. 2.3.11-1.4). The problem was that the script
/etc/ppp/ip-up.d/0dnrd did not use DNS1 and DNS2 set by pppd when
usepeerdns option was used and also /etc/ppp/resolv files were not used
when usepeerdns option was not on.
So I wrote a new /etc/ppp/ip-up.d/0dnrd and I want to share it with you.
Before I decided to submit it, I checked for a new version of dnrd -
maybe it is already improved. Indeed, there was a new version, 2.7-1,
which was "aware" of pppd's usepeerdns. But the usage of static DNS
adresses for various providers is still not there. Therefore I send
you my version of /etc/ppp/ip-up.d/0dnrd which covers both ways of DNS
assignment. Additionally, I have removed one bug in the original file:
the quotes around DNS variables in for loop are removed. With the quotes,
dnrd is started as dnrd -s -s -s -s if DNS variables are not defined.
Pawel Konieczny
#!/bin/sh
# Exit if package was removed but not purged.
test -x /usr/sbin/dnrd || exit 0
case "$PPP_IFACE" in
ippp0) #dnrd -s 123.45.67.89
;;
ppp*)
DNS=
# use ppp/resolv
if [ -f /etc/ppp/resolv/$PPP_IPPARAM ]; then
DNS="$DNS$(cat /etc/ppp/resolv/$PPP_IPPARAM |
awk '$1 == "nameserver" { printf " -s %s", $2 }')"
fi
# Since version 2.3.7 of the ppp daemon, the option
# "usepeerdns" sets environment variables $DNS1 and $DNS2.
for ns in $DNS1 $DNS2 $MS_DNS1 $MS_DNS2 ; do
DNS="$DNS -s $ns"
done
# Uncomment the following lines if you want to use automatically
# assigned DNS servers.
if [ -n "$DNS" ]; then
dnrd $DNS
fi
;;
esac