Renaming Network Interface in Debian by MAC Address
In Debian Linux, you can rename a network interface by using the udev rules to match it by its MAC address and assign a custom name. Here’s how you can do it:
- 
    Identify the MAC Address: First, you’ll need to know the MAC address of the interface you want to rename. You can find it using the following command: ip link showLook for the line that starts with your current interface name (e.g., eth0,ens33, etc.) and note its MAC address (it looks something like00:1A:2B:3C:4D:5E).
- 
    Create a Udev Rule: You’ll need to create a new udevrule file. Open a terminal and create a new file in the/etc/udev/rules.d/directory. You can use any text editor, for example:sudo nano /etc/udev/rules.d/10-network.rulesIn this file, you will add a rule to rename the interface based on its MAC address. Use the following format: SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="00:1A:2B:3C:4D:5E", NAME="customname"Replace 00:1A:2B:3C:4D:5Ewith your actual MAC address, andcustomnamewith your desired interface name.
- 
    Reload Udev Rules: After saving the file, reload the udevrules with the following command:sudo udevadm control --reload-rules
- 
    Reboot or Trigger Udev: You can either reboot your system or trigger the udevrules for the interfaces. You can trigger alludevrules with:sudo udevadm trigger
- 
    Verify the Change: After rebooting or triggering the rules, you can check whether the interface has been renamed using: ip link show
This should display your network interfaces with the new name you assigned.
Example Udev Rule
Here’s an example of what the rule might look like:
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="00:1A:2B:3C:4D:5E", NAME="my_custom_interface"
Note
- Ensure that no other rules are conflicting with your new rule, especially those that might rename interfaces.
- If you switch between different hardware, consider naming conventions that remain unique following your rules.