-
Notifications
You must be signed in to change notification settings - Fork 405
Excluding network adapters from NetworkManager
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.
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.
- 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:#
- 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.
- 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:#
- 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:#
- 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:#
- Restart the NetworkManager service or reboot the system to apply the change
root@zero:# systemctl restart NetworkManager
root@zero:#
- 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:#
- 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:#
- Set it to non-managed state:
root@zero:# nmcli dev set wlan0 managed no
root@zero:#
- 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:#