[Buildroot] Problem with multi interface support in udhcpc script?

Danomi Manchego danomimanchego123 at gmail.com
Tue Jan 21 15:23:12 UTC 2014


Peter,

On Tue, Jan 21, 2014 at 6:49 AM, Peter Korsgaard <jacmet at uclibc.org> wrote:
> Ahh, so we need to add per-interface domain comments and generate a
> 'search' line with all domains. As you say, the last search line "wins"
> (also verified in uClibc code), we could perhaps just so something
> similar to the nameservers, E.G.:
>
> nameserver ... # eth0
> search foo # eth0
> nameserver ... # eth1
> search bar # eth1
> search foo bar # COMBINED

Rather than relying on the last search line winning for the future, I
was thinking that the per-interface search lines should be comments,
something like:

nameserver ... # eth0
#search foo # eth0
nameserver ... # eth1
#search bar # eth1
search foo bar

(Of course, you can replace "#search" with whatever you want.)

Also, if you run the little libresolv program that I sent earlier,
then you'll see that the "#" and "COMBINED" show up as search domains
- at least, I do, with both my Ubuntu 12.04 machine and with my
embedded target compiled with CodeSourcery 2009q1-203.  So I do not
think that it is safe to have a comment on the aggregated search line.
 Therefore, if you must identify the combined search line then you
might want to to grep for '^search '.  I was thinking that perhaps it
would be better to just regenerate the whole thing each time - for
example:

        TMPFILE=$(mktemp)
        grep -vE "# $interface\$" $RESOLV_CONF > $TMPFILE
        sed -i '/^search /d' $RESOLV_CONF

        [ -n "$domain" ] && echo "#search $domain # $interface" >> $TMPFILE
        for i in $dns ; do
            echo "nameserver $i # $interface" >> $TMPFILE
        done

        echo "search $(grep '#search ' $TMPFILE | sed 's/^#search
//;s/ # .*$//' | xargs)" >> $TMPFILE

        mv $TMPFILE $RESOLV_CONF

However, there is still a problem with this strategy - the order of
the name servers and the search domains affect how DNS queries are
made.  Catting lines to the end of a file will make server and search
domain priority a function of when DHCP info is acquired, not
planning.  So I ended up funneling all DNS info to our project's
network app rather than relying on this script to do it for us, to
roll my own "resolvconf".  But then, incremental improvement is still
improvement, so changing the way this scipt is now may still be a good
thing.

Danomi -



More information about the buildroot mailing list