How To Disable NetworkManager on Rocky Linux 9
In this tutorial, we will show you how to Disable NetworkManager on Rocky Linux 9. Rocky Linux 9, a robust and reliable operating system, offers a variety of tools for managing network connections. Among these tools, NetworkManager is a popular choice for its ease of use and comprehensive features. However, there are scenarios where disabling NetworkManager is necessary, such as when using legacy network configurations or specific software that requires direct control over network settings. In this article, we will delve into the process of disabling NetworkManager on Rocky Linux 9, providing step-by-step instructions and troubleshooting tips to ensure a smooth transition.
Introduction to NetworkManager
NetworkManager is a network connection manager that simplifies the process of managing network interfaces. It supports both wireless and wired connections, making it a versatile tool for users. NetworkManager’s user-friendly interface allows users to easily configure and manage network settings, including setting up static IP addresses, connecting to Wi-Fi networks, and managing VPN connections.
However, in certain environments, such as server setups or specific network configurations, NetworkManager might not be the best choice. For instance, if you need precise control over network interfaces or if your setup requires legacy network configurations, disabling NetworkManager could be beneficial.
Understanding NetworkManager in Rocky Linux 9
NetworkManager in Rocky Linux 9 operates similarly to other Linux distributions, providing a centralized way to manage network connections. It supports a wide range of network devices and protocols, making it suitable for most users. However, if you are upgrading from Rocky Linux 8, you might notice some improvements in NetworkManager’s performance and compatibility with newer hardware.
Common Use Cases
NetworkManager is commonly used in desktop environments for its ease of use and graphical interface. However, in server environments or when precise control over network settings is required, disabling NetworkManager might be necessary. This could include scenarios where specific network configurations are needed for software compatibility or when using legacy network equipment.
Preparing Your System
Before disabling NetworkManager, it’s essential to prepare your system by accessing the terminal and verifying NetworkManager’s status.
Accessing the Terminal
- Open the Terminal: You can access the terminal by searching for it in the applications menu or by using the keyboard shortcut
Ctrl + Alt + T
. - Switch to Root User: Use the command
sudo su
to switch to the root user. This will prompt you to enter your password.
Checking NetworkManager Status
To verify if NetworkManager is running, use the following command:
systemctl status NetworkManager
This command will show you whether NetworkManager is active or inactive.
Backup Important Files
Before making any changes, it’s crucial to backup your network configuration files. This ensures that you can revert any changes if needed. You can backup the files by copying them to a safe location:
cp /etc/NetworkManager/NetworkManager.conf /etc/NetworkManager/NetworkManager.conf.backup
cp /etc/sysconfig/network-scripts/* /etc/sysconfig/network-scripts/backup/
Disabling NetworkManager
Disabling NetworkManager involves stopping the service, disabling it from starting on boot, and configuring your network interfaces manually.
Stopping NetworkManager Service
To stop NetworkManager, use the following command:
systemctl stop NetworkManager
Disabling NetworkManager Service
To prevent NetworkManager from starting on boot, use:
systemctl disable NetworkManager
Modifying Interface Configuration Files
To ensure that NetworkManager does not manage your network interfaces, you need to modify the interface configuration files. Typically, these files are located in /etc/sysconfig/network-scripts/
.
- Edit the Interface File: Open the file corresponding to your network interface (e.g.,
ifcfg-eth0
) in a text editor:
nano /etc/sysconfig/network-scripts/ifcfg-eth0
- Set NM_CONTROLLED=”no”: Add or modify the line
NM_CONTROLLED="no"
to prevent NetworkManager from managing this interface:
NM_CONTROLLED="no"
- Save and Close: Save the changes and close the editor.
Enabling Legacy Network Service
To manage network connections without NetworkManager, you need to enable the legacy network service. This service is typically managed by the network
service.
- Enable the Network Service: Use the following command to enable the network service:
systemctl enable network
- Start the Network Service: Start the network service to apply the changes:
systemctl start network
Configuring Network Interfaces Manually
Configuring network interfaces manually involves editing configuration files for each interface.
Understanding Interface Configuration Files
Interface configuration files are typically located in /etc/sysconfig/network-scripts/
. Each file corresponds to a specific network interface (e.g., ifcfg-eth0
for Ethernet interface eth0
).
Setting Static IP Addresses
To set a static IP address for an interface, you need to edit its configuration file.
- Open the Configuration File: Use a text editor to open the interface’s configuration file:
nano /etc/sysconfig/network-scripts/ifcfg-eth0
- Configure Static IP: Add or modify the following lines to set a static IP address:
BOOTPROTO="static"
IPADDR="192.168.1.100"
NETMASK="255.255.255.0"
GATEWAY="192.168.1.1"
DNS1="8.8.8.8"
DNS2="8.8.4.4"
- Save and Close: Save the changes and close the editor.
Enabling Interfaces on Boot
To ensure that your network interfaces are enabled at startup, you need to configure them to start automatically.
- Enable the Interface: Use the following command to enable the interface to start on boot:
chkconfig network on
Alternatively, for systems using systemd
, you can use:
systemctl enable network
- Restart the System: Restart your system to apply the changes:
reboot
Alternative Network Management Tools
Even after disabling NetworkManager, you can still manage network connections using alternative tools.
Using nmcli
nmcli
is a command-line tool that allows you to manage network connections even if NetworkManager is disabled. You can use it to add, modify, or delete network connections.
- List Connections: Use the following command to list all network connections:
nmcli connection show
- Add a Connection: You can add a new connection using:
nmcli connection add type ethernet ifname eth0 con-name my-eth0
- Modify a Connection: Modify an existing connection by specifying its name:
nmcli connection modify my-eth0 ipv4.addresses 192.168.1.100/24
Using nmtui
nmtui
is a text-based user interface for NetworkManager that allows you to manage network connections graphically.
- Launch nmtui: Use the following command to launch
nmtui
:
nmtui
- Edit a Connection: Navigate to the “Edit a connection” option to modify existing connections.
Other Tools
Other tools like ip
and ifconfig
can be used to manage network interfaces directly.
- Using ip: The
ip
command allows you to manage network interfaces, routes, and tunnels:
ip addr show
- Using ifconfig: Although deprecated,
ifconfig
can still be used to manage network interfaces:
ifconfig eth0 192.168.1.100 netmask 255.255.255.0
Troubleshooting Common Issues
After disabling NetworkManager, you might encounter some issues. Here are some troubleshooting tips:
Network Connectivity Issues
- Check Interface Configuration: Ensure that your network interface configuration files are correct and that the interface is enabled.
- Restart Network Service: Try restarting the network service to apply changes:
systemctl restart network
Service Not Starting
- Check Service Status: Use
systemctl status network
to check if the network service is running. - Enable and Start Service: Ensure the service is enabled and started:
systemctl enable network
systemctl start network
Reverting Changes
If you encounter issues or decide to revert to using NetworkManager, you can re-enable it by following these steps:
- Enable NetworkManager Service:
systemctl enable NetworkManager
- Start NetworkManager Service:
systemctl start NetworkManager
- Restore Backup Files: If you backed up your configuration files, restore them to their original locations.
Congratulations! You have successfully disabled NetworkManager. Thanks for using this tutorial to turn off the NetworkManager on your Rocky Linux 9 system. For additional help or useful information, we recommend you check the official AlmaLinux website.