openresolv-discuss

Re: Using openresolv with udhcpc?

Einar Jón

Wed Jul 17 14:10:26 2019

Hi Roy

see inline
I hope this answers your questions. I'm off for 3 week vacation, so
this is not urgent on my side.

On Wed, 17 Jul 2019 at 14:10, Roy Marples <roy@xxxxxxxxxxxx> wrote:
>
> Hi Einar
>
> On 17/07/2019 11:19, Einar Jón wrote:
> > Hi Roy
> >
> > This mostly works for me. I do need extra stuff to make resolv.conf
> > run, but given the files below, my resolv.conf looks like this:
> > # Generated by resolvconf
> > nameserver 3.3.3.3 # /etc/resolvconf/resolv.conf.d/head
> > search xxxxxx.com
> > nameserver 192.168.2.xx
> > nameserver 62.140.138.233
> > nameserver 62.140.140.251
> > nameserver 8.8.8.8
> > nameserver 2.2.2.2 # /etc/resolvconf/resolv.conf.d/tail
> >
> > Bugs:
> > 1) Comments are still weird.
> >    - Stripped in /var/run/resolvconf/interfaces/*.udhcpc files
> >    - Untouched in /etc/resolvconf/resolv.conf.d/head and tail
>
> The head and tail files are added verbatim - not processed at all.
>

Fine. This was more of a test, since I wanted to see what is done.

> However, the resolv.conf files added to resolfconf are not stripped exactly.
> $ resolvconf -l
> # resolv.conf from foo
> nameserver 8.8.8.8 #This is a comment
>
> But they ARE stripped when sent to the subscribers. You can see this here:
> $ resolvconf -v
> DOMAIN=''
> SEARCH=''
> NAMESERVERS='8.8.8.8'
> LOCALNAMESERVERS=''
> DOMAINS=''
>
> There are many reasons for this, but the most prevalent is this - what
> do we write if more than one entry has a comment?
>
> $ resolvconf -l
> # resolv.conf from foo
> nameserver 8.8.8.8 #This is a comment
>
> # resolv.conf from bar
> nameserver 8.8.8.8 #This is a different comment
>
> Which comment should be written to /etc/resolv.conf for the single
> nameserver entry from different sources?
>

The first or the last one, depending on your preference. Or just strip
them properly for /etc/network/interfaces.

>
> >    - "#text" and "#" is skipped in  dns-nameservers lines of
> > /etc/network/interfaces, but the rest is added as a nameserver
> > 2) the last one means that I can't have a space after the # in
> >    dns-nameservers 8.8.8.8 #/etc/network/interfaces.d/wwan0
> > Or I will get a separate
> > nameserver /etc/network/interfaces.d/wwan0
> > Also " dns-nameservers 8.8.8.8 #This is a comment" throws away "#This", but adds
> > nameserver 8.8.8.8
> > nameserver is
> > nameserver a
> > nameserver comment
>
> What shell exactly is /bin/sh for you?
> I tested my fix with recent versions of dash, bash, BSD sh and it seems
> to work fine?

$ ll /bin/sh
lrwxrwxrwx 1 root root 4 Apr 17 14:35 /bin/sh -> bash
$ /bin/sh  --version
GNU bash, version 4.4.18(1)-release (arm-buildroot-linux-gnueabihf)

>
> >
> > Not bugs, but extra steps needed for this to work:
> > 3) I need to create the /var/run/resolvconf/interfaces/*.udhcpc files
> > myself (in a /usr/share/udhcpc/default.script.d/resolvconf) script
>
> You're supposed to pipe the resolv.conf file it would have made to
> resolvconf. The Gentoo netifrc pacakge has a good udhcpc script here:
> https://github.com/gentoo/netifrc/blob/master/sh/udhcpc-hook.sh.in

That's great to know. I'll take a look at that once I'm back from vacation.

>
> > 4) I need to borrow the /etc/network/if-down.d/resolvconf
> > /etc/network/if-up.d/000resolvconf files from the ubuntu package.
>
> It's possible that the comment bug you are seeing is here.
> What is the output of:
> resolvconf -l

$ grep name /etc/network/interfaces.d/wwan0
        dns-nameservers 8.8.8.8 #/etc/network/interfaces.d/wwan0 more text
$ resolvconf -l
# resolv.conf from lo.inet

# resolv.conf from eth0.udhcpc
search xxxxxx.com # eth0
nameserver 192.168.2.xx # eth0

# resolv.conf from eth1.inet

# resolv.conf from eth1.inet6

# resolv.conf from eth1:1.inet

# resolv.conf from eth1:2.inet

# resolv.conf from wwan0.udhcpc
nameserver 62.140.138.233 # wwan0
nameserver 62.140.140.251 # wwan0

# resolv.conf from wwan0.inet
nameserver 8.8.8.8
nameserver #/etc/network/interfaces.d/wwan0
nameserver more
nameserver text

# resolv.conf from eth0.inet

-- 
Regards
Einar Jón

Follow-Ups:
Re: Using openresolv with udhcpc?Roy Marples
References:
Using openresolv with udhcpc?Einar Jón
Re: Using openresolv with udhcpc?Roy Marples
Re: Using openresolv with udhcpc?Einar Jón
Re: Using openresolv with udhcpc?Roy Marples
Archive administrator: postmaster@marples.name