ArticlesRocky Linux

Renaming Network Interfaces Without Rebooting

interfaceiplinklinuxnetworkrebootrenameRocky Linuxruleudev

Howard Van Der Wal
Sr. Customer Support Engineer

Dec 27, 2024

Introduction

In high-availability server environments, minimizing downtime is critical. Renaming a network interface often requires a reboot, which can disrupt services. This guide provides methods to rename network interfaces dynamically, ensuring changes take effect without requiring a system restart.

Problem

Renaming network interfaces without rebooting can be a challenge in Linux systems. Traditional methods typically require a restart to apply changes, which isn't ideal for systems that demand continuous uptime. This limitation can hinder administrators managing critical services or performing live configurations.

Resolution

Prerequisites

Access to the root user account or a user with escalated privileges.

Method 1 - ip link set

To temporarily change the name of an interface, use the ip link set command.

Bring down the network interface that you wish to rename:

sudo ip link set <INTERFACE_NAME> down

Rename the interface:

sudo ip link set <INTERFACE_NAME> name <NEW_INTERFACE_NAME>

Enable the newly renamed interface:

sudo ip link set <NEW_INTERFACE_NAME> up

Please note that rebooting your server removes the changes.

Method 2 - udev rules by MAC address

Check under /etc/udev/rules.d/ that you have a 70-persistent-net.rules file. If the file isn't there, create it with touch /etc/udev/rules.d/70-persistent-net.rules

Confirm the interface you wish to edit by using ip -brief address show. You can see a similar output as in the below example:

$ ip -brief address show
lo               UNKNOWN        127.0.0.1/8 ::1/128 
enp8s0           UP             <PUBLIC_IP>/24

Open /etc/udev/rules.d/70-persistent-net.rules with your text editor of choice and modify the NAME field of the interface you wish to change. A before and after example follows:

Before:

$ cat /etc/udev/rules.d/70-persistent-net.rules
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="<MAC_ADDRESS_HERE>", NAME="enp8s0"

After:

$ cat /etc/udev/rules.d/70-persistent-net.rules
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="<MAC_ADDRESS_HERE>", NAME="new-name-1"

Bring the network interfaces down with ip link set <INTERFACE_NAME> down. In this case enp8s0:

ip link set enp8s0 down 

Use the udevadm control command to reload the udev rules and request device events from the kernel with udevadm trigger:

udevadm control --reload-rules; udevadm trigger --subsystem-match=net --action=add

Use ip -brief address show to confirm that the system has renamed the network interface:

$ ip -brief address show
lo               UNKNOWN        127.0.0.1/8 ::1/128 
new-name-1       DOWN           <PUBLIC_IP>/24

Bring the link back up using ip link set <NEW_INTERFACE_NAME> up. Please see the following example:

ip link set new-name-1 up 

Observe that the system renamed the interface and brought it up without requiring a reboot:

$ ip -brief address show
lo               UNKNOWN        127.0.0.1/8 ::1/128 
new-name-1       UP             <PUBLIC_IP>/24

Even if you reboot the machine, the changes remain persistent.

References & related articles

udevadm man page
udev rules introduction