Hi - For a while now when I run 
# dhcpcd eth1
I get an IP address OK but no DNS. I've established that a 
/etc/resolv.conf file is not being created when the command is being 
run. 

There's a script invoked at some stage called
/etc/resolvconf/update.d/libc. This is creating a file with all the DNS 
information called /var/run/resolvconf/interfaces/eth1 (or eth2 
depending on the interface raised). However it's not then creating 
/etc/resolv.conf. I can get around this by running my own script to
copy 
the DNS information to /etc/resolv.conf but it would be good to figure 
out why it's not working.

I attach output of my /etc/resolvconf/update.d/libc below if anyone can 
help. I've tried reemerging the package (unsuccessfully).

Thanks, Richard

=== Begin ===

#!/bin/bash
# Copyright 2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

# libc resolv.conf updater

# Written by Roy Marples ([EMAIL PROTECTED])
# Heavily based on Debian resolvconf by Thomas Hood

# Load generic Gentoo functions
source /etc/init.d/functions.sh

[[ $(readlink /etc/resolv.conf 2>/dev/null) \
        != "resolvconf/run/resolv.conf" ]] && exit 0

RESOLVCONF="$(resolvconf -l)"

BASE="/etc/resolvconf/resolv.conf.d/base"
OUR_NS=
if [[ -e ${BASE} ]] ; then
        OUR_NS="$(sed -n -e 's/^[[:space:]]*nameserver[[:space:]]*//p'
"${BASE}")"
fi
OUR_NS="$(uniqify \
        ${OUR_NS} \
        $(echo "${RESOLVCONF}" \
        | sed -n -e 's/^[[:space:]]*nameserver[[:space:]]*//p') \
)"

# libc only allows for 3 nameservers
# truncate after 127 as well
i=0
NS=
for N in ${OUR_NS} ; do
        ((i++))
        NS="${NS} ${N}"
        [[ ${i} == "3" || ${N} == "127."* ]] && break
done

# This is nasty!
# If we have a local nameserver then assume they are intelligent enough
# to be forwarding domain requests to the correct nameserver and not
search
# ones. This means we prefer search then domain, otherwise, we use them
in
# the order given to us.
OUR_SEARCH=
if [[ ${N} == "127."* ]] ; then
        if [[ -e ${BASE} ]] ; then
                OUR_SEARCH="$(sed -n -e 's/^[[:space:]]*search[[:space:]]*//p'
"${BASE}")"
        fi
        OUR_SEARCH="${OUR_SEARCH} $(echo "${RESOLVCONF}" \
                | sed -n 's/^[[:space:]]*search[[:space:]]*//p')"
        if [[ -e ${BASE} ]] ; then
                OUR_SEARCH="${OUR_SEARCH} $(sed -n -e
's/^[[:space:]]*domain[[:space:]]*//p' "${BASE}")"
        fi
        OUR_SEARCH="${OUR_SEARCH} $( echo "${RESOLVCONF}" \
                | sed -n -e 's/^[[:space:]]*domain[[:space:]]*//p')"
else
        if [[ -e ${BASE} ]] ; then
                OUR_SEARCH="$(sed -n -e 's/^[[:space:]]*search[[:space:]]*//p' \
                        -e 's/^[[:space:]]*domain[[:space:]]*//p' "${BASE}")"
        fi
        OUR_SEARCH="${OUR_SEARCH} $(echo "${RESOLVCONF}" \
                | sed -n -e 's/^[[:space:]]*search[[:space:]]*//p' \
                        -e 's/^[[:space:]]*domain[[:space:]]*//p')"
fi

# libc only allows for 6 search domains 
i=0
SEARCH=
for S in $(uniqify ${OUR_SEARCH}) ; do
        ((i++))
        SEARCH="${SEARCH} ${S}"
        [[ ${i} == "6" ]] && break
done
[[ -n ${SEARCH} ]] && SEARCH="search${SEARCH}"

# Hold our new resolv.conf in a variable to save on temporary files
NEWCONF="# Generated by resolvconf\n"
[[ -e /etc/resolvconf/resolv.conf.d/head ]] \
        && NEWCONF="${NEWCONF}$(< /etc/resolvconf/resolv.conf.d/head)\n"
[[ -n ${SEARCH} ]] && NEWCONF="${NEWCONF}${SEARCH}\n"
for N in ${NS} ; do
        NEWCONF="${NEWCONF}nameserver ${N}\n"
done

# Now dump everything else from our resolvs
if [[ -e ${BASE} ]] ; then
        NEWCONF="${NEWCONF}$(sed -e '/^[[:space:]]*$/d' \
                -e '/^[[:space:]]*nameserver[[:space:]]*.*/d' \
                -e '/^[[:space:]]*search[[:space:]]*.*/d' \
                -e '/^[[:space:]]*domain[[:space:]]*.*/d' \
                "${BASE}")" 
fi

# We don't know we're using GNU sed, so we do it like this
NEWCONF="${NEWCONF}$(echo "${RESOLVCONF}" | sed -e '/^[[:space:]]*$/d' \
        -e '/^[[:space:]]*#/d' \
        -e '/^[[:space:]]*nameserver[[:space:]]*.*/d' \
        -e '/^[[:space:]]*search[[:space:]]*.*/d' \
        -e '/^[[:space:]]*domain[[:space:]]*.*/d' \
        )"
[[ -e /etc/resolvconf/resolv.conf.d/tail ]] \
        && NEWCONF="${NEWCONF}$(< /etc/resolvconf/resolv.conf.d/tail)"

# Check if the file has actually changed or not
if [[ -e /etc/resolv.conf ]] ; then
        [[ $(< /etc/resolv.conf) == "$(echo -e "${NEWCONF}")" ]] && exit 0
fi

# Create our resolv.conf now
echo -e "${NEWCONF}" > /etc/resolvconf/run/resolv.conf

# Restart nscd if it's running
if [[ -x /etc/init.d/nscd ]] ; then
        if /etc/init.d/nscd --quiet status ; then
                /etc/init.d/nscd --nodeps --quiet restart
        fi
fi

# Notify users of the resolver
for x in /etc/resolvconf/update-libc.d/* ; do
        [[ -e ${x} ]] && "${x}" "$@"
done

# vim: ts=4 :


-- 
[EMAIL PROTECTED] mailing list

Reply via email to