# How to rename NIC?

**URL:** https://forums.rockylinux.org/t/how-to-rename-nic/7260
**Category:** Rocky Linux Help & Support
**Created:** [September 15, 2022, 9:43pm UTC](https://forums.rockylinux.org/t/how-to-rename-nic/7260 "2022-09-15T21:43:09Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ebalsley](https://avatars.discourse-cdn.com/v4/letter/e/a87d85/32.png) [@ebalsley](https://forums.rockylinux.org/u/ebalsley)
#### Post date: [September 15, 2022, 9:43pm UTC](https://forums.rockylinux.org/t/how-to-rename-nic/7260/1 "2022-09-15T21:43:09Z")

</div>

After installing Mellanox OFED driver, my network interfaces were renamed, e.g. enp197s0f0 is now enp197s0f0np0. `nmcli con` shows the old names but `nmcli dev` shows the new names. I’d like to rename these to something easier to remember like `eth1`. I tried doing this with the following udev rule but it has no effect. Is there a log file somewhere that would show why this isn’t working? I didn’t find anything about ‘eth2’ in dmesg or journalctl.

```auto
# cat /etc/udev/rules.d/85-net-persistent-names.rules 
#PCI device 15b3:1019 (mlx5_core)
#NAME:="some name" , := is used to make sure that device name will be persistent.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="B8:CE:F6:82:D1:64", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME:="eth1"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="B8:CE:F6:82:D1:65", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME:="eth2"

```

---

<div class="post-metadata">

### Author: ![label](https://avatars.discourse-cdn.com/v4/letter/l/c5a1d2/32.png) [@label](https://forums.rockylinux.org/u/label)
#### Post date: [September 16, 2022, 3:32am UTC](https://forums.rockylinux.org/t/how-to-rename-nic/7260/2 "2022-09-16T03:32:09Z")

</div>

There’s a few ways to do it without udev, depending on if you’re on Rocky 8 or 9.

```auto
# Identify the mac address of the interface
[root@cm01 ~]# ip a s enp1s0
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 52:54:00:85:14:ac brd ff:ff:ff:ff:ff:ff
    inet 10.100.0.12/24 brd 10.100.0.255 scope global noprefixroute enp1s0
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:fe85:14ac/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

# Rocky Linux 8 only as it still uses /etc/sysconfig/network-scripts/ifcfg-* files
[root@cm01 ~]# echo 'HWADDR="52:54:00:85:14:ac"' >> /etc/sysconfig/network-scripts/ifcfg-enp1s0
[root@cm01 ~]# mv /etc/sysconfig/network-scripts/ifcfg-enp1s0 /etc/sysconfig/network-scripts/ifcfg-cm0
[root@cm01 ~]# sed -i 's/enp1s0/cm0/g' /etc/sysconfig/network-scripts/ifcfg-cm0
[root@cm01 ~]# init 6

[label@router ~]$ ssh cm01
[label@cm01 ~]$ ip a s cm0
2: cm0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 52:54:00:85:14:ac brd ff:ff:ff:ff:ff:ff
    inet 10.100.0.12/24 brd 10.100.0.255 scope global noprefixroute cm0
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:fe85:14ac/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

```

Using systemd links:

```auto
# Rocky Linux 8 or 9 can use this
[root@idp ~]# mkdir /etc/systemd/network
[root@idp ~]# vi /etc/systemd/network/70-custom.link
[Match]
MACAddress=52:54:00:ea:a2:6b

[Link]
Name=idp0

# Rocky Linux 9 only operations
[root@idp ~]# mv /etc/NetworkManager/system-connections/enp1s0.nmconnection mv /etc/NetworkManager/system-connections/idp0.nmconnection
[root@idp ~]# sed -i 's/enp1s0/idp0/g' /etc/NetworkManager/system-connections/idp0.nmconnection
[root@idp ~]# init 6

. . .

[root@idp ~]# ip a s idp0
2: idp0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 52:54:00:ea:a2:6b brd ff:ff:ff:ff:ff:ff
    inet 10.100.0.13/24 brd 10.100.0.255 scope global noprefixroute idp0
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:feea:a26b/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

```

Note that with Rocky Linux 9, using systemd links is the most effective way to change an interface name without using udev.

---

<div class="post-metadata">

### Author: ![ebalsley](https://avatars.discourse-cdn.com/v4/letter/e/a87d85/32.png) [@ebalsley](https://forums.rockylinux.org/u/ebalsley)
#### Post date: [September 16, 2022, 4:09am UTC](https://forums.rockylinux.org/t/how-to-rename-nic/7260/3 "2022-09-16T04:09:26Z")

</div>

Thanks! I’ll give this a shot. I’m on Rocky 8.6. So is udev deprecated now?

---

<div class="post-metadata">

### Author: ![label](https://avatars.discourse-cdn.com/v4/letter/l/c5a1d2/32.png) [@label](https://forums.rockylinux.org/u/label)
#### Post date: [September 16, 2022, 4:24am UTC](https://forums.rockylinux.org/t/how-to-rename-nic/7260/4 "2022-09-16T04:24:15Z")

</div>

Awesome, one of those methods should work for you then.

It’s not deprecated. udev is a linux kernel device manager and is a fundamental part of majority of distributions, especially Enterprise Linux and Fedora. Unfortunately in my experience, it has been inconsistent and difficult to maintain/manage since RHEL 8’s release in changing device names.

I have found that it’s just simpler to use systemd network or ifcfg-\* directives to get around udev not operating like it should for network device names.

---

<div class="post-metadata">

### Author: ![brian](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/brian/32/5777_2.png) [@brian](https://forums.rockylinux.org/u/brian)
#### Post date: [August 25, 2023, 3:40am UTC](https://forums.rockylinux.org/t/how-to-rename-nic/7260/5 "2023-08-25T03:40:12Z")

</div>


