On Thu, Feb 16, 2006 at 10:49:39AM +0000, Alec Berryman wrote:
> Bernd Schoeller on 2006-02-16 10:22:00 +0100:
> 
> > If I use supersede (in dhclient.conf) or dhclient.conf.tail, this work
> > fine, but the information gathered by dhclient is lost.
> 
> You want 'prepend'.

Nope, also prepend messes with my existing resolv.conf file, instead
of storing the received DNS information in a new file.

Just for the logs, and as I have found no 'easy/predefined' way of
doing it, I have created a copy of /sbin/dhclient-script to
/sbin/dhclient-script.pdnsd and changed the following function:

----------------------------------------------------------------------
add_new_resolv_conf() {
        # XXX Old code did not create/update resolv.conf unless both
        # $new_domain_name and $new_domain_name_servers were provided.  PR
        # #3135 reported some ISPs only provide $new_domain_name_servers and
        # thus broke the script. This code creates the resolv.conf if either
        # are provided.

        RESOLV_CONF_NAME=/etc/resolv.conf.wan

        rm -f /etc/resolv.conf.std

        if [ -n "$new_domain_name" ]; then
                echo "search $new_domain_name" >>/etc/resolv.conf.std
        fi

        if [ -n "$new_domain_name_servers" ]; then
                for nameserver in $new_domain_name_servers; do
                        echo "nameserver $nameserver" >>/etc/resolv.conf.std
                done
        fi

        if [ -f /etc/resolv.conf.std ]; then
                if [ -f /etc/resolv.conf.tail ]; then
                        cat /etc/resolv.conf.tail >>/etc/resolv.conf.std
                fi

                # In case (e.g. during OpenBSD installs) /etc/resolv.conf
                # is a symbolic link, take care to preserve the link and write
                # the new data in the correct location.

                if [ -f $RESOLV_CONF_NAME ]; then
                        cat $RESOLV_CONF_NAME > /etc/resolv.conf.save
                fi
                cat /etc/resolv.conf.std > $RESOLV_CONF_NAME
                rm -f /etc/resolv.conf.std

                # Try to ensure correct ownership and permissions.
                chown -RL root:wheel $RESOLV_CONF_NAME
                chmod -RL 644 $RESOLV_CONF_NAME

                return 0
        fi

        return 1
}
----------------------------------------------------------------------

This will store the DNS resolv.conf configuration in
/etc/resolv.conf.wan and won't mess the preinstalled resolv.conf
file. 

In dhclient.conf, I have added the following entry:

script "/sbin/dhclient-script.pdnsd";

The server section in pdnsd.conf now looks like the following:

server {
        label= "dialup";
        file = "/etc/resolv.conf.wan"; 
        proxy_only=on;
        timeout=4;
        uptest=if;
        interface = sis0;
        interval=10;
        purge_cache=off;
        preset=off;
}

Thanks for the hints,
Bernd

Reply via email to