Rick Moen wrote:
> When the nameserver is ready to serve it should 
> do the equivalent of this sh script:
> 
>    NAME="unbound"
>    echo "nameserver 127.0.0.1" | /sbin/resolvconf -a lo."$NAME"
> 
> and when it is no longer ready to serve it should do:
> 
>    /sbin/resolvconf -d lo."$NAME"

hm, as resolvconf is Priority: optional, i suppose the hypothetical sh
script should instead do something like:

    NAME="unbound"
    if [ -x "/sbin/resolvconf" ]; then
        echo "nameserver 127.0.0.1" | /sbin/resolvconf -a lo."$NAME"
    fi

but unbound is not necessarily listening on 127.0.0.1; it's not
necessarily even listening on a single IP address.

to take my desktop as an example:

    unbound    3024  unbound    3u  IPv4 1099831      0t0  UDP 216.27.162.2:53 
    unbound    3024  unbound    4u  IPv4 1099833      0t0  TCP 216.27.162.2:53 
(LISTEN)
    unbound    3024  unbound    5u  IPv6 1099835      0t0  UDP 
[2001:470:7:208::2]:53 
    unbound    3024  unbound    6u  IPv6 1099837      0t0  TCP 
[2001:470:7:208::2]:53 (LISTEN)

it appears resolvconf wants both an interface name and an IP address.
it looks like i'd have to do something like:

    NAME="unbound"
    PID="$(cat /var/run/unbound.pid)"

    # get the first IPv4 listening address
    ADDR=$(ss -f inet -pnl | grep "\"unbound\",$PID" | awk '{print$3}' | head 
-1 | cut -f1 -d:)

    # get the interface name
    IFACE=$(ip addr show to $ADDR | head -1 | cut -f2 -d' ' | cut -f1 -d:)

    if [ -x "/usr/sbin/resolvconf" ]; then
        echo "nameserver $ADDR" | /sbin/resolvconf -a "$IFACE"."$NAME"
    fi

perhaps with a bit more error handling and correctly handling IPv6-only
configurations.  (and should we send more than one listening address to
resolvconf or just one?)  this is starting to look a bit complicated.
should i just cop-out and only do the resolvconf thing if unbound
happens to be listening on 127.0.0.1?

-- 
Robert Edmonds
edmo...@debian.org



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to