How do I prevent Network Manager from controlling an interface?
Note: this article no longer applies to the NTA1000 platform or fully licensed CDRouter systems. It should only be used when configuring a CDRouter DEMO evaluation platform.
Network Manager is a service for Linux which manages various networking interfaces, including physical such as Ethernet and wireless, and virtual such as VPN and other tunnels. Network Manager can be configured to control some or all of a system’s interfaces.
While Network Manager is an excellent service for managing the daily requirements of a user’s computer, its effects are typically non-optimal for a testing environment. Because of the extra variables it introduces into the state of a test machine’s networking configuration, it can be especially difficult to integrate with CDRouter, which also controls network interfaces. Due to this conflict, the start procedure will generate an error if Network Manager is controlling any interfaces used for testing. In this case you have three options:
- Configure Network Manager to ignore test interfaces
- Manually stop Network Manager
- Remove Network Manager from the system
Manual interface configuration
Before you begin, please be aware that you may still want to use Network Manager to control the non-testing interfaces you have on your system, like the one you use to connect to your system to the lab or corporate network. In this case, the first option below, may be the best.
Configure Network Manager to ignore test interfaces
Network Manager has a command line tool that can be used to see which interfaces it is controlling. Pull up a terminal window and type the following command:
nmcli dev status
This displays a table that lists all network interfaces along with their
STATE
. If Network Manager is not controlling an interface, its STATE
will be
listed as unmanaged
. Any other value indicates the interface is under Network
Manager control.
#Network Manager settings are controlled by a configuration file:
#/etc/NetworkManager/NetworkManager.conf
. We will use this
#file to tell Network Manager to stop controlling a particular interface.
ifcfg method
With CentOS or Rocky, one way to tell Network Manager to
stop controlling an interface is by editing the individual ifcfg-*
files.
First, make sure the /etc/NetworkManager/NetworkManager.conf file has the following lines.
[main]
plugins=ifcfg-rh
This plugin tells Network Manager to look at the CentOS or Rocky ifcfg-*
files. Now
for each interface you’d like Network Manager to ignore, edit the individual
/etc/sysconfig/network-scripts/ifcfg-*
interface files, adding the following
lines:
NM_CONTROLLED=no
HWADDR=00:11:22:33:44:55
If present, set the HWADDR
value to be the actual MAC address of this
interface.
keyfile method
Another way to tell Network Manager to stop controlling an interface is by adding the following lines to the /etc/NetworkManager/NetworkManager.conf file:
[main]
plugins=keyfile
[keyfile]
unmanaged-devices=mac:00:11:22:33:44:55;mac:66:77:88:99:00:aa
List the MAC address of each interface you want Network Manager to ignore, separated with a semicolon. Make sure that MAC addresses listed here are LOWER CASE.
Newer versions of NetworkManager can also use a more generic alternate KEYFILE method that does not involve actual MAC addresses and instead uses interface names. This syntax replaces the [keyfile] section above with the following:
[keyfile]
unmanaged-devices=interface-name:eth*,except:interface-name:eth0;interface-name:wlan*
udev rules method
A third way to tell Network Manager to stop controlling an interface is to add a udev rule. Create the file /etc/udev/rules.d/00-nta1000-net.rules and add the following content:
#
# Interfaces that shouldn't be managed by NetworkManager
#
ACTION=="add", SUBSYSTEM=="net", KERNEL=="eth1", ENV{NM_UNMANAGED}="1"
ACTION=="add", SUBSYSTEM=="net", KERNEL=="eth2", ENV{NM_UNMANAGED}="1"
ACTION=="add", SUBSYSTEM=="net", KERNEL=="eth3", ENV{NM_UNMANAGED}="1"
You can list the interfaces (by name) that you want Network Manager to avoid.
You should reboot for these changes to take effect.
Manually stop Network Manager
If Network Manager is not needed during testing, it can be shut off completely.
systemctl stop NetworkManager
systemctl start NetworkManager
The above commands will stop/start NetworkManager, but will not affect whether it
is automatically started when the machine boots. To disable/enable NetworkManager automatically
when the system boots, again use the systemctl
command (as root):
systemctl disable NetworkManager
systemctl enable NetworkManager
Remove Network Manager from the system
If Network Manager will not be needed at all, it can be removed from the system completely.
yum remove NetworkManager
Restart Networking
You may need to restart networking to make changes take effect.
systemctl restart network