Cannot set ndots with nmcli.

Latest response

Hi All,
I am using RHEL 8.6. (But even on RHEL 9 I have the same problem)
I need to use ndots option for nslookup.
On my servers, I use nmcli settings with NetworkManager keyfiles; I do not use old ifcfg scripts (/etc/sysconfig/network-scripts/).
Thus I have added ndots option with command :
nmcli connection modify ens192 ipv4.dns-options "ndots:5"
It adds well ndots:5 option to active connection, and I can see it with nmcli -p connection show ens192.
Then I reload and restart network services, even reboot the server, I still cannot resolve host
But when I do nslookup command like => nslookup -ndots:5 it resolves the host.
How to correctly enable ndots in nslookup ?
I cannot manually add this option to /etc/resolv.conf, because my /etc/resolv.conf is automatically Generated from NetworkManager, and I need to keep it as such. I've even tried dns-options paragraph in NetworkManager conf files - no luck.
Actually, what I really need is, to find where and how to put ndots option in NetworkManager conf files.
Can you help me?


Your steps work fine for me with NetworkManager-1.40.16-4.el8_8 and NetworkManager-1.42.2-6.el9_2:

# nmcli con show net0 | grep ipv4.dns-options
ipv4.dns-options:                       ndots:5


# Generated by NetworkManager
search local
options ndots:5

My /etc/resolv.conf is an actual file, not a symlink. This is required so NM manages the contents, as described in man NetworkManager.conf section dns. Make sure your NM config files do not have something like dns=none. Check with:

# grep -RHn dns /etc/NetworkManager/

Hi JB, Thanks very much, very helpful; But unfortunately, It does not work; I have NetworkManager-1.36.0-15.el8_6 on both RHEL8 and 9. I've tested adding dns-options=ndots:5; in [ipv4] section, but /etc/resolv.conf stays same after reloading and restaring NetworkManager.. no inclusion of dns-options=ndots:5

And yes, I have

cat /etc/Network-Manager/conf.d/dns.conf

[main] dns=default

All, Finally found, I had to add => options=ndots:5 in [global-dns] section in /etc/Network-Manager/conf.d/dns.conf Thanks JB for the hint