Skip to content

Excluding network adapters from NetworkManager

strasharo edited this page Sep 16, 2018 · 1 revision

There are multiple ways to exclude network adapters from being managed by NetworkManager, some are temporary and are effective only until the next reboot, others are persistent over reboots.


Permanent:

Via an udev rule (universal and recommended solution):

The benefits of this solution are that it's not distribution-specific and also you're defining a persistent and custom name for your interface based on its default mac address.

  1. Check the status of the device

root@zero:# nmcli d

DEVICE TYPE STATE CONNECTION

wlan0 wifi disconnected --

eth0 ethernet unmanaged --

lo loopback unmanaged --

root@zero:#

  1. Create the file /etc/udev/rules.d/70-persistent-net.rules (the 70 prefix indicates priority in which the file is going to be applied, you can increase/decrease the number in order to combine it with other udev rules) with the following content:

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:xx", ATTR{type}=="1", KERNEL=="wlan*", NAME="white", ENV{NM_UNMANAGED}="1"

Where you should replace xx:xx:xx:xx:xx:xx with the permanent MAC address of your card. You can find it either by using ethtool:

root@zero:# ethtool -P wlan0

Permanent address: de:ad:be:ef:ca:fe

root@zero:#

Or through macchanger:

root@zero:# macchanger -s wlan0

Current MAC: de:ad:be:ef:ca:fe (unknown)

Permanent MAC: de:ad:be:ef:ca:fe (unknown)

root@zero:#

You can also change the value of NAME to whatever you want your interface. If you just want the persistent name of the interface and still want it to be managed by NetworkManager, just omit the , ENV{NM_UNMANAGED}="1" part at the end.

  1. Reboot the device and once it boots you should have a renamed interface which is not being managed by NetworkManager:

root@zero:# nmcli d

DEVICE TYPE STATE CONNECTION

eth0 ethernet unmanaged --

lo loopback unmanaged --

whiteh wifi unmanaged --

root@zero:#

Via /etc/network/interfaces (Debian based distributions):

  1. Check the current status of the device:

root@zero:# nmcli d

DEVICE TYPE STATE CONNECTION

wlan0 wifi disconnected --

eth0 ethernet unmanaged --

lo loopback unmanaged --

root@zero:#

  1. Append an entry in /etc/network/interfaces describing that the device is manually managed one

root@zero:# cat /etc/network/interfaces

auto lo

iface lo inet loopback

allow-hotplug eth0

iface eth0 inet dhcp

iface wlan0 inet manual

root@zero:#

  1. Restart the NetworkManager service or reboot the system to apply the change

root@zero:# systemctl restart NetworkManager

root@zero:#

  1. Confirm that the change has been applied

root@zero:# nmcli d

DEVICE TYPE STATE CONNECTION

eth0 ethernet unmanaged --

lo loopback unmanaged --

wlan0 wifi unmanaged --

root@zero:#


Temporary:

Via nmcli:

  1. Check the current status of the device:

root@zero:# nmcli d

DEVICE TYPE STATE CONNECTION

wlan0 wifi disconnected --

eth0 ethernet unmanaged --

lo loopback unmanaged --

root@zero:#

  1. Set it to non-managed state:

root@zero:# nmcli dev set wlan0 managed no

root@zero:#

  1. Confirm that the change has been applied:

root@zero:# nmcli d

DEVICE TYPE STATE CONNECTION

eth0 ethernet unmanaged

lo loopback unmanaged

wlan0 wifi unmanaged

root@zero:#