Talk:NetworkManager

From ArchWiki
Latest comment: 11 June by Accellarando in topic Fixes for automatic VPN dispatcher script

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)!Reply

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

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)Reply
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)!Reply

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)Reply

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)Reply

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)Reply

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)Reply

We should also use "nmcli dev | grep "ethernet" | grep -w "connected"" instead of "LAN_Interface" because the name of the interface might change when using different docking stations or tongles. But I am too bad at scripting to make this change.
Utini2000

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)Reply

Share internet connection via Bluetooth

Currently there is method to share internet connection via WiFi and Ethernet but there is no mentioning on internet sharing via Bluetooth. I guess it would be nice to have one?

Pickfire (talk) 01:33, 2 March 2022 (UTC)Reply

iwd backend doesn't support mac spoofing

https://bbs.archlinux.org/viewtopic.php?pid=2063573#p2063573 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1111

This is not mentioned in https://iwd.wiki.kernel.org/networkmanager (or it iwd wiki) and will rather silently fail, so https://wiki.archlinux.org/title/NetworkManager#Configuring_MAC_address_randomization could mention it to prevent unpleasant surprises.

Seth (talk) 13:44, 23 October 2022 (UTC)Reply

Should configuration examples be added?

ConnMan has configuration examples, as well as wpa_supplicant. Would it be good to add examples of slightly more complex setups to this page as well, like this one? There are some external tools that generate configs mentioned at Network_configuration/Wireless, but sometimes a quick reference is useful. —This unsigned comment is by Dryya (talk) 05:02, 18 January 2023 (UTC). Please sign your posts with ~~~~!Reply

Fixes for automatic VPN dispatcher script

First contribution to the wiki after many years of reference! I used the script in 5.2.5 but upon network connection my VPN got stuck in an activation<->deactivation loop. After some troubleshooting I found that the script was running multiple times for some reason - I'm not sure if this is specific to my system or a more general bug. I fixed this dispatcher script to check if the VPN connection is not active before connecting to it (line 9):

#!/bin/sh
VPN_NAME="your vpn name"
ESSID="your essid"

interface=$1 status=$2
case $status in
  up|vpn-down)
    if iwgetid | grep -qs ":\"$ESSID\""; then
		if !(nmcli connection show --active | grep "$VPN_NAME"); then
		  nmcli connection up id "$VPN_NAME";
		fi
    fi
    ;;
esac

This fixed the issue for me, if anyone else can confirm this behavior on their setup I can incorporate this into the main article. Accellarando (talk) 02:37, 11 June 2024 (UTC)Reply