Identifying Network Interfaces
To inspect active interfaces and assigned addresses, execute:
ip addr show
Check connection status with:
nmcli device status
Common interface naming patterns include ens33, eth0, or enp0s3.
Persistent Configuration via NetworkManager Files
AlmaLinux manages network connections using NetworkManager. Interface definitions reside in /etc/sysconfig/network-scripts/, following the ifcfg-<name> convention.
Editing the Interface File
Open the appropriate configuration file:
sudo vim /etc/sysconfig/network-scripts/ifcfg-ens192
Static Addressing Example
Adjust the parameters below to assign a fixed address:
TYPE=Ethernet
BOOTPROTO=static
NAME=ens192
DEVICE=ens192
ONBOOT=yes
IPADDR=10.10.10.50
PREFIX=24
GATEWAY=10.10.10.1
DNS1=223.5.5.5
DNS2=8.8.4.4
Key fields explained:
- BOOTPROTO: Set to
staticfor manual IP assignment ordhcpfor automatic leasing. - ONBOOT:
yesactivates the interface during system startup. - PREFIX: Represents the subnet mask in CIDR notation; an alternative to
NETMASK.
Applying the Changes
Reload NetworkManager or reapply the specific connection profile:
sudo systemctl restart NetworkManager
sudo nmcli device reapply ens192
Using nmcli for Ad-Hoc and Permanent Modifications
NetworkManager's command-line tool nmcli offers a scriptable approach.
Settting Addresses Temporarily
These assignments are lost after a reboot unless made permanent:
sudo nmcli connection modify ens192 ipv4.addresses 10.10.10.50/24
sudo nmcli connection modify ens192 ipv4.gateway 10.10.10.1
sudo nmcli connection modify ens192 ipv4.dns "223.5.5.5 8.8.4.4"
sudo nmcli connection modify ens192 ipv4.method manual
sudo nmcli connection up ens192
Setting ipv4.method to auto restores DHCP behavior.
Committing Changes Permanently
Append --permanent to persist acrosss restarts, then reactivate:
sudo nmcli connection modify ens192 ipv4.addresses 10.10.10.50/24 --permanent
sudo nmcli connection modify ens192 ipv4.gateway 10.10.10.1 --permanent
sudo nmcli connection modify ens192 ipv4.dns "223.5.5.5 8.8.4.4" --permanent
sudo nmcli connection modify ens192 ipv4.method manual --permanent
sudo nmcli connection up ens192
Renaming Network Interfaces
To change interface naming from predictable schemes (like ens33) to traditional eth0:
-
Edit the bootloader configuraton:
sudo vim /etc/default/grubModify the
GRUB_CMDLINE_LINUXline to includenet.ifnames=0 biosdevname=0:GRUB_CMDLINE_LINUX="rd.lvm.lv=almalinux/root … net.ifnames=0 biosdevname=0" -
Regenerate the GRUB configuration:
BIOS systems:
sudo grub2-mkconfig -o /boot/grub2/grub.cfgUEFI systems:
sudo grub2-mkconfig -o /boot/efi/EFI/almalinux/grub.cfg -
Rename the existing connection profile:
sudo mv /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-eth0 -
Update the
NAMEandDEVICEfields insideifcfg-eth0toeth0. -
Reboot the machine:
sudo reboot
Troubleshooting
-
Examine NetworkManager logs for configuration errors:
journalctl -u NetworkManager -f -
Verify the syntax of modified configuration files.
-
Cloud instances (AWS, Alibaba Cloud, etc.) may enforce custom networking configurations; consult provider-specific guidance before altering settings.