Return to Level1Techs.com

[Ubuntu] Line order of resolv dot conf?

What is the correct line order for the domain, search and nameserver pieces that make up resolv.conf?

I read through the info here, but couldn’t find a specific answer.
https://manpages.ubuntu.com/manpages/precise/man5/resolv.conf.5.html

Searching the general internet eludes to “it doesn’t matter”, but it sure seems like “programmatically” there would be a definitive “right way” even if it’s generally not followed to specification?

From what I can tell this is a key-value-pair type deal.
I would guess it doesn’t matter either, because programatically it probably just reads in all the lines and searches for the possible keywords in each line, the rest of the line (before or after) being the value.

The autogenerated file on Fedora looks like this:

<keyword> <value>

Which would also make it easier to sort and search through if for some reason you have a ton of entries.

Like he said, i don’t think it matters, as per above, so long as the directives match up the correct key/value pairs you should be good.

Normal convention is

search yourlocaldomain.tld
nameserver x.x.x.x
nameserver y.y.y.y
etc.

but so long as the lines are each individually syntax-correct it should just work whatever order.

Thank you for the replies so far. Unfortunately the answers look to be speculative and not based on interpreting the source code.
I’m hunting for solid supporting documentation that defines what the source code is set up to evaluate. Ideally an official answer as they relate to “domain”, “search”, and “nameserver” properties instead of the wealth of examples on the Internet. Most of those are opinions or someones interpretation. The closest I have found talks about commented out config options of resolv.h.

I honestly don’t get the point of that as long as it works, aside from the file typically being managed by resolveconf and not being handwritten.

I mean if you wanna dig through the source code go for it, if you can even find where it is interpreted.

2 Likes