Sunday, September 24, 2023
 Popular · Latest · Hot · Upcoming
rated 0 times [  22] [ 0]  / answers: 1 / hits: 43056  / 1 Year ago, thu, july 7, 2022, 3:25:26

My main ethernet interface is called enp2s0, but some software requires me to name it to eth0.

How can I rename it?

I tried creating /etc/udev/rules.d/10-rename-network.rules (as per this post), creating /etc/udev/rules.d/70-persistent-net.rule and editing /etc/network/interfaces.

The contents of /etc/udev/rules.d/10-rename-network.rules were:

SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ff:ff:ff:ff:ff", NAME="eth0"

with ff:ff...:ff replaced with the mac address of enp2s0.

More From » networking


Using netplan which is the default these days.
File /etc/netplan/50-cloud-init.yaml file.

Find the target devices mac/hw address using the lshw command:

lshw -C network

You'll see some output which looks like:

root@ys:/etc# lshw -C network
description: Ethernet interface
physical id: 2
logical name: eth0
serial: dc:a6:32:e8:23:19
size: 1Gbit/s
capacity: 1Gbit/s
capabilities: ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=bcmgenet driverversion=5.8.0-1015-raspi duplex=full ip= link=yes multicast=yes port=MII speed=1Gbit/s

So then you take the serial


Note the set-name option.

This works for the wifi section as well.

version: 2
dhcp4: true
macaddress: <YOUR MAC ID HERE>
set-name: eth0

Then then to test this config run.

netplan try

When your happy with it

netplan apply

[#1922] Friday, July 8, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 303
Total Questions: 121
Total Answers: 103

Location: Colombia
Member since Mon, May 2, 2022
1 Year ago