Talk:NetworkManager

From ArchWiki
Jump to navigation Jump to search

Explain that encrypting passwords requires nm-applet (or equivalent?) to be running

When using Gnome Keyring to encrypt passwords, several interfaces to NetworkManager (at least nmcli and nm-connection-editor) will only have access to the passwords if nm-applet is running (as apparently it is the entity communicating with the keyring, through libsecret). This can be surprising when trying to use NetworkManager outside of Gnome (e.g. in Sway, or without a graphical user interface), see https://bbs.archlinux.org/viewtopic.php?id=246698 for more details.

Unless mistaken, I think this would be worth mentioning in the NetworkManager#nm-applet and/or the NetworkManager#Encrypted Wi-Fi passwords sections. What do you think?

Wehlutyk (talk) 13:00, 27 May 2019 (UTC)

Correct/Updated dnsmasq with NetworkManager

So I just set this up to enable ad blocking on my laptop regardless of which network I connect to. So far it seems to be working. This config presented on the site dns=none and so forth does not work as desired. create me:

/etc/NetworkManager/dnsmasq.d/dnsmasq.conf
resolv-file=/run/NetworkManager/no-stub-resolv.conf
strict-order
interface=lo
cache-size=1000
conf-file=/etc/NetworkManager/dnsmasq-shared.d/bad_domains.txt #https://github.com/notracking/hosts-blocklists (https://raw.githubusercontent.com/notracking/hosts-blocklists/master/domains.txt)
addn-hosts=/etc/NetworkManager/dnsmasq-shared.d/bad_hostnames.txt #https://github.com/notracking/hosts-blocklists (https://raw.githubusercontent.com/notracking/hosts-blocklists/master/hostnames.txt)
domain-needed
bogus-priv

edit me:

/etc/NetworkManager/NetworkManager.conf
# Configuration file for NetworkManager.
# See "man 5 NetworkManager.conf" for details.
[main]
dns=dnsmasq

I'm created by NetworkManager, just FYI of what I contain:

/run/NetworkManager/no-stub-resolv.conf 
# Generated by NetworkManager
nameserver DHCP_PROVIDED_DNS_1
nameserver DHCP_PROVIDED_DNS_2
nameserver DHCP_PROVIDED_DNS_3

Glenntanner3 (talk) 13:54, 1 November 2019 (UTC)!

—This unsigned comment is by Glenntanner3 (talk) 16:06, 31 October 2019 (UTC). Please sign your posts with ~~~~!

That looks overcomplicated. This should work:
/etc/NetworkManager/conf.d/dns.conf
[main]
dns=dnsmasq
/etc/NetworkManager/dnsmasq.d/dnsmasq.conf
cache-size=1000
conf-file=/etc/NetworkManager/dnsmasq-shared.d/bad_domains.txt
You don't need to include /run/NetworkManager/no-stub-resolv.conf, NetworkManager will send the DNS server addresses to dnsmasq over dbus.
-- nl6720 (talk) 11:08, 1 November 2019 (UTC)
Explanation for parameters:

I'll try to make this update correct. Didn't know, or expect, that username wouldn't be added and i'm kind of surprised this isn't designed to be indepent messages. Updated what I had before to match your better formatting.

From what I just tested resolv-file=/run/NetworkManager/no-stub-resolv.conf is required, commented it out->restarted NM->ping google->fail; dbus didn't seem to do it.

I also included interface lo to prevent external usage of my laptop being used for DNS.

I used NetworkManager.conf as it already existed, no need to create more that the minimum number of new configuration files.

domain-needed and bogus-priv are recommended for safety.

conf-file and addn-hosts are for ad domain blocking, should have mentioned; those can be excluded but perhaps should be mentioned.

Set this up to work around need for pihole at work or any network i'm connected to. But the documentation I found to be lacking.

Glenntanner3 (talk) 13:54, 1 November 2019 (UTC)!

If the DNS servers are not send over dbus, then something is broken on your end, check journalctl -u NetworkManager.service. It should contain dnsmasq[#]: setting upstream servers from DBus and dnsmasq[#]: using nameserver address#port(via interface).
I tested with:
/etc/NetworkManager/conf.d/dns.conf
[main]
dns=dnsmasq
/etc/NetworkManager/dnsmasq.d/dnsmasq.conf
cache-size=1500
conf-file=/etc/NetworkManager/dnsmasq-shared.d/bad_domains.txt
addn-hosts=/etc/NetworkManager/dnsmasq-shared.d/bad_hostnames.txt
domain-needed
bogus-priv
And everything works correctly for me.
-- nl6720 (talk) 07:25, 2 November 2019 (UTC)

Network configuration in related articles

Currently, Network configuration and Wireless network configuration are listed in the related articles. Some time ago, information wired-connection specifics moved to Network configuration/Ethernet and wireless-connection specifics moved to Network configuration/Wireless.

Should it list only Network configuration, or all three Network configuration, Network configuration/Ethernet and Network configuration/Wireless ? -- Josephgbr (talk) 00:04, 12 November 2019 (UTC)

Warn about that nm-applet installs libappindicator-gtk3 which breaks several applications?

Nm-applet installs libappindicator-gtk3 as a dependency. Some applications like blueman-tray as well as all electron-based applications use libappindicator if pressent in system. This breaks functionality in the tray area for all this applications (left mouse click stop to work and other clik/menu related issues).

This is clearly not an issue with nm-applet (maybe even not with libappindicator since nm-applet's tra icon seems to work properly) but nm-applet is one of the few applications that installs libappindicator as their dependency.

Edit: just figured out that if the nm-applet is started with "--indicator", if also has the same tray issues as described above.

Micw (talk) 09:31, 7 January 2021 (UTC)

Use dispatcher to automatically toggle wireless depending on LAN cable being plugged in

The script, as it currently stands, will cause networking to be disabled if the network cable is disconnected while the computer is off.

If I plug in a LAN cable, the command nmcli radio wifi off is run. Thats good, but later I turn off the computer to take it with me, and then I unplug the LAN cable. When I turn it back on, still without LAN cable (intending to use Wi-Fi), my LAN_interface is "unavailable", and will not receive any network events, i.e. "$1" in the script will never be the LAN interface name, and so the command nmcli radio wifi on will never be run, and my wifi radio remains off.

The command to turn it back on can be run manually, of course, and the LAN cable can be disconnected before power off, which will also turn it on - but the best solution would be to foolproof the script.

I'm not sure what would be the best way to go about it, though, but a bit of testing tells me that after the radio is off and the LAN cable is out, I will receive two network events on boot:

  • none (action: hostname)
  • <empty> (action: connectivity-change)

I believe the hostname action happens only when the hostname changes, and will normally happen only on boot, so maybe that can be a place to start? Maybe add to the front of the script something like:

if [ "$1" = "none" ]; then
    if [ "$(nmcli -g GENERAL.STATE device show LAN_interface)" = "20 (unavailable)" ]; then
        nmcli radio wifi on
    fi
fi

Or, maybe better, disconnect it form the hostname action and just run the unavailability test first, no matter what $1 and $2 is? It's not going take much CPU anyway - the network events seems to happen only on actual changes, so not very often.

Edit: I added a failsafe in an else clause to the event check. It will be run on all events that are not related to the LAN Interface, so it's not elegant, but I don't know how else to pick up the non-event that you have no network.

Ferdinand (talk) 18:21, 17 August 2021 (UTC)

NetworkManager-wait-online

Updated the section, to be coherent with Systemd-networkd#systemd-networkd-wait-online. Most of the section however might be better off in NetworkManager#Troubleshooting. --Cvlc (talk) 23:01, 22 September 2021 (UTC)