Modifying Network Interface IP Addresses on AlmaLinux

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 static for manual IP assignment or dhcp for automatic leasing.
  • ONBOOT: yes activates 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:

  1. Edit the bootloader configuraton:

    sudo vim /etc/default/grub
    

    Modify the GRUB_CMDLINE_LINUX line to include net.ifnames=0 biosdevname=0:

    GRUB_CMDLINE_LINUX="rd.lvm.lv=almalinux/root … net.ifnames=0 biosdevname=0"
    
  2. Regenerate the GRUB configuration:

    BIOS systems:

    sudo grub2-mkconfig -o /boot/grub2/grub.cfg
    

    UEFI systems:

    sudo grub2-mkconfig -o /boot/efi/EFI/almalinux/grub.cfg
    
  3. Rename the existing connection profile:

    sudo mv /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-eth0
    
  4. Update the NAME and DEVICE fields inside ifcfg-eth0 to eth0.

  5. 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.

Tags: AlmaLinux networking networkmanager IP configuration nmcli

Posted on Sat, 20 Jun 2026 17:21:34 +0000 by nwoottonn