In Linux, you can change the name of a network interface card using the udev
subsystem.
Here’s how you can change the name of the eth0
interface to new_name
:
- Create a new udev rule file:
sudo nano /etc/udev/rules.d/10-network.rules
- Add the following lines to the file:
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:xx", NAME="new_name"
where xx:xx:xx:xx:xx:xx
is the MAC address of the eth0
interface, and new_name
is the desired name of the interface.
- Save the file and exit the editor.
- Reload the udev rules:
sudo udevadm control --reload-rules
- Verify the changes by using the
ip
command:ip addr show
Note: The new name will take effect only after a reboot or by bringing the interface down and up again: sudo ip link set dev eth0 down && sudo ip link set dev eth0 up
This method of renaming network interfaces using udev
rules is persistent across reboots, and is preferred over using the traditional ifconfig
or ip
commands.