mnichols1202
Posts: 2
Joined: Thu Oct 25, 2018 5:42 pm

raspbian DSN Suffix resolvconf

Fri Oct 26, 2018 1:04 am

Hello All,

My first post!
Writing a business app for our company. C# - MONO - Raspberry Pi 3B/ 3B+ - Raspbian Stretch - so far so good...with one exception.
The concept is we will send an end user a Raspberry Pi and they will connect the pi to their network and it will get assigned an address via DHCP.
Then the app will retrieve the DNS Suffix and "phone home" to securely download the apps config for that customers network. That way i can send a raspberry pi without having to pre-configure it.

On a regular Debian Stretch Distro (non PI) the resolv.conf is auto created and looks something like this:
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 192.168.2.46
nameserver 192.168.2.36
domain mycustomersdomain.local
search mycustomersdomain.local



However on the Pi(raspbian) the autocreated resolv.conf looks like this:
# Generated by resolvconf
domain mycustomersdomain.local
nameserver 192.168.2.46
nameserver 192.168.2.36


Without the search line in the resolv.conf the Dns Suffix returns a null string.
if i manually add the search line my app works and all is well (until the next reboot of course).

i need resolvconf to automatically populate the search line for the MONO (C#.NET) Network class to pick up the DNS Suffix.

all the answers I've found deal with solving connectivity issues or how you can manually add to the resolv.conf file so it doesn't get overwritten.

my issue is, i need it to be dynamic...it seems to correctly find and populate the "domain" i just need it to populate the "search" as well.
anyone have any insight?

Mike

epoch1970
Posts: 3804
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: raspbian DSN Suffix resolvconf

Fri Oct 26, 2018 10:02 am

Search is not mandatory and often not sent by DHCP servers. If your Pi has a static network configuration you can define "static domain_name" and "static domain_search" in dhcpcd.conf and that should be propagated into resolv.conf

Search makes the client side resolver repeatedly add values from the search list to an unqualified host name and query name servers for the resulting fqdn.
On the server side, dns cache/forwarders can be configured to add a domain in case they receive an unqualified query.

I don't know C# but I doubt it absolutely requires search to be present. Perhaps you're expected to build the fqdn yourself.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

mnichols1202
Posts: 2
Joined: Thu Oct 25, 2018 5:42 pm

Re: raspbian DSN Suffix resolvconf

Fri Oct 26, 2018 8:47 pm

Thanks for the reply epoch1970!

I did however "fix" this in the meantime (at least this worked for me).
Rasbpian apparently uses openresolv to do the dhcp/resolv.conf stuff.

so i remove the default openresolv package
sudo apt purge openresolv
and then just added the resolvconf package in its place.
sudo apt-get install resolvconf

reboot and voila!!! populated search string :)

epoch1970
Posts: 3804
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: raspbian DSN Suffix resolvconf

Sat Oct 27, 2018 8:24 am

Fine then.
Still, I would worry about requiring the search stanza to be present. Your code should be able to work with the domain stanza alone: you will sooner or later encounter cases where “search” is not defined.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Return to “Troubleshooting”