Managing NetworkManager.conf using command line?

Latest response

Are there NM commands to manage the settings in NetworkManager.conf?

I'm hoping to find a native cli method of setting dns=none

Responses

Hello, take a look at nmcli. There is an intro in the Networking Guide here Network Configuration Using NetworkManager's CLI (nmcli).

The "general" subcommand of nmcli only covers status, hostname, permissions and logging. There does not seem to be a documented way to tell NetworkManager "don't ever touch /etc/resolv.conf" with any of those. The other subcommands all edit individual connections or network devices.

Plain old text editing tools to the rescue:

sed -i.bak -e '/^dns=/d' -e '/^\[main\]/adns=none' /etc/NetworkManager/NetworkManager.conf
systemctl restart NetworkManager

In other words, edit NetworkManager.conf with sed, creating a backup with a .bak suffix, as follows:

  • if there is already a line that begins with 'dns=', delete it.

  • after that, add a line with 'dns=none' right after the line with '[main]'

Then restart NetworkManager to ensure the new settings take effect.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.