This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Renaming Network Interfaces with Custom Names
In Linux, you can assign a specific name to a network interface to prevent it from changing due to kernel or driver updates. Here’s how to do it.
Steps
1. Find the MAC Address of the Network Interface
To identify the network interface you want to rename, first find its MAC address.
```bash ip link ```
Look for the MAC address (a unique identifier like aa:bb:cc:dd:ee:ff) of the interface you want to rename.
2. Create a .link File
Create a .link file in /etc/systemd/network/. Name it <priority>-<identifier>.link where <priority> is a number less than 99, and <identifier> is a unique name you choose (for example, 10-enwan0.link).
```bash sudo nano /etc/systemd/network/10-enwan0.link ```
3. Configure the .link File
Add the following content to define the network interface by its MAC address and assign a custom name:
```ini [Match] MACAddress=aa:bb:cc:dd:ee:ff Type=ether
[Link] Name=enwan0 ```
- Replace
aa:bb:cc:dd:ee:ffwith the MAC address of your interface. - Change
enwan0to the name you want for this interface.
If you have more interfaces to rename, create additional .link files, each targeting a different MAC address.
4. Update Initramfs
Run the following command to apply changes to the initial RAM file system:
```bash sudo update-initramfs -u -k all ```
5. Adjust Network Configurations
If you use configuration files like /etc/network/interfaces, make sure to update them with the new interface name (e.g., enwan0).
6. Reboot the System
Reboot the system to apply the changes.
```bash sudo reboot ```
After the reboot, your network interface should appear with the new name.
Example Summary of Commands
```bash ip link # Find MAC address sudo nano /etc/systemd/network/10-enwan0.link # Create .link file sudo update-initramfs -u -k all # Update initramfs sudo reboot # Reboot to apply changes ```
Now, your network interface is using the new custom name.