openresolv-discuss

Re: Using openresolv with udhcpc?

Einar Jón

Wed Jul 17 10:18:55 2019

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
  - "#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

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
4) I need to borrow the /etc/network/if-down.d/resolvconf
/etc/network/if-up.d/000resolvconf files from the ubuntu package.

I would prefer it if comments stay in the resolv.conf for every type
of nameserver.

$ head -100 /var/run/resolvconf/interfaces/*.udhcpc
/etc/network/interfaces.d/wwan0  /etc/resolvconf/resolv.conf.d/*
==> /run/resolvconf/interfaces/eth0.udhcpc <==
search xxxxxx.com # eth0
nameserver 192.168.2.xx # eth0

==> /run/resolvconf/interfaces/wwan0.udhcpc <==
nameserver 62.140.138.233 # wwan0
nameserver 62.140.140.251 # wwan0

==> /etc/network/interfaces.d/wwan0 <==
# wwan0 interface is managed by ifplugd, which will invoke ifup/down
#auto wwan0
iface wwan0 inet dhcp
        post-up service reverse_ssh_tunnel2 start
        pre-down service reverse_ssh_tunnel2 stop
        dns-nameservers 8.8.8.8 #/etc/network/interfaces.d/wwan0

==> /etc/resolvconf/resolv.conf.d/head <==
nameserver 3.3.3.3 # /etc/resolvconf/resolv.conf.d/head

==> /etc/resolvconf/resolv.conf.d/tail <==
nameserver 2.2.2.2 # /etc/resolvconf/resolv.conf.d/tail

On Tue, 9 Jul 2019 at 16:17, Roy Marples <roy@xxxxxxxxxxxx> wrote:
>
> Hi Einar
>
> On 08/07/2019 13:33, Einar Jón wrote:
> > Hello
> >
> > I just discovered openresolv, and I'm trying to get resolvconf to work
> > with udhcpc
> >
> > Openresolv doesn't seem to like the format udhcpc uses:
> > $ cat /etc/resolv.conf
> > search xxxxxxxx.com # eth0
> > nameserver 192.168.2.xx # eth0
> > nameserver 62.140.1xx.xx # wwan0
> > nameserver 62.140.1xx.xx # wwan0
> > ----
> > WIth this:comments at the end of a line become a "nameserver #" and
> > :"nameserver eth0":
> >
> > This silly little script below seems to work, if I also add resolvconf
> > scripts to
> > /etc/network/if-up.d and /etc/network/if-down.d/
> > But I find it silly to write /etc/resolv.conf twice in a non-atomic
> > way. (first udhcpc and then resolvconf)
> > What is the recommended approach? I'd like to keep
> > /usr/share/udhcpc/default.script as is, if possible...
> >
> > $ cat  /usr/share/udhcpc/default.script.d/resolvconf
> > #!/bin/bash
> >
> > # Make udhcpc changes to resolv.conf readable for resolvconf
> >
> > [ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
> > RESOLV_DIR=/var/run/resolvconf/interfaces/
> >
> > case "$1" in
> >      renew|bound)
> >          mkdir -p $RESOLV_DIR
> >          grep $interface /etc/resolv.conf | sed -e "s/#.*//"   >
> > $RESOLV_DIR/$interface.udhcpc
> >          ;;
> > esac
> >
> > exit 0
>
> This should be fixed here:
> https://roy.marples.name/cgit/openresolv.git/commit/?id=e39a20cdc3c55993120714dd50cd201b70dbc4b3
>
> Can you test that please? If it works, I'll make a new release.
>
> Roy



-- 
Regards
Einar Jón
+31 610 957234

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