Change location of networkmanager config file

Hello,

I have been asked by one of my teammate to modify networkmanager.conf config file to eg. change loglevel or activate connectivity check.

I have read that " The location of the main file and configuration directories may be changed through use of the –config, –config-dir, –system-config-dir, and –intern-config argument for NetworkManager, respectively." (source : https://www.systutorials.com/docs/linux/man/5-NetworkManager.conf/).

Can someone please point me howto specify this? (or if it is not possible !)

Thanks

NB: I can modify our custom OS if needed

I will keep this post updated with my work notes, if it can be usefull for others!
So far, I have found that Systemd is responsible for starting Networkmanager (and many more : balenaOS - Docs).
systemd file is located at /lib/systemd/system/NetworkManager and contain the “start command” ExecStart=/usr/sbin/NetworkManager --no-daemon.

If I would add –config /path/to/my/configfile I think that I should do it in this file.

Anyway… That leads to other questions that make me feel like its a bad idea:

  • what happend if /path/to/my/configfile is not available?
  • can I specify After= directive to wait for the ovlume containing /path/to/my/configfile to be mounted ?

I have found that I can configure the connectiity check part of config file through config.json as in Network Setup on balenaOS - Balena Documentation
I still miss some configuration but I have to check if it is mandatory or not.

Hi, for the connectivity check you may indeed configure it through the config.json as you noted.

For changing the log level of NetworkManager you may use its D-Bus API or access it through a wrapper library: NetworkManager/examples at main · NetworkManager/NetworkManager · GitHub

I would definitely recommend interacting through the NetworkManager API for more advanced use-cases as it is quite feature rich. I would especially recommend using NetworkManager native library libnm which supports many programming languages through gobject-introspection: NetworkManager/examples/python/gi at main · NetworkManager/NetworkManager · GitHub

1 Like

Hi,

What exactly do you expect your /path/to/my/configfile to point to that it won’t be available?
Some kind of mount that might take a little while, or rather something that might never exist?
In the first case, you might be able to make a script/service that watches for it to become available, and only starts NetworkManager after that; ex by specifying Before=NetworkManager.
If you are not opposed to modifying the NetworkManager service file, you could try adding RequiresMountsFor=/path/to/my/configfile

Hi,
I was indeed affraid of a volume that may take a while to mount !
Your solution might work.
I will keep you updated !
Thanks a lot