Help on CentOS 7.6 MAC & interface swap

Issues related to configuring your network
Post Reply
tsrini
Posts: 18
Joined: 2018/04/06 13:25:09

Help on CentOS 7.6 MAC & interface swap

Post by tsrini » 2019/05/27 16:41:41

Hi Team,

We are using ESXi 6.5 host machine with 4 physical NICs (4 VMNetworks with 4 vSwitch). On this host, we are launching a CentOS 7.6 VM with 4 NICs with 1 - 1 mapping.

Say as below,

During VM creation (created with manual MACs)
Network Adapter vNIC1 (MAC M1) -> Physical NIC1
Network Adapter vNIC2 (MAC M2) -> Physical NIC2
Network Adapter vNIC3 (MAC M3) -> Physical NIC3
Network Adapter vNIC4 (MAC M4) -> Physical NIC4

We would need to use ethX naming and hence we will convert the ensX/enpX interface naming to tradition ethX.

To do this, inside VM, we will ask (from a script) user to configure the MAC address for eth0, eth1, eth2 and eth3 (say M1, M2, M3 & M4 is configured respectively by the user). We need to persist the MAC & interface mapping consistent across reboots. The /etc/sysconfig/network-scripts/ifcfg-* files are updated appropriately with the name & MAC address.

To do this, we tried the below options,

Using udev rules

1. Configured udev rules (/etc/udev/rules.d/70-persistent-ipoib.rules) based on the user input,

SUBSYSTEM=="net", ACTION=="remove", DRIVERS=="?*", ATTR{type}=="1", KERNEL=="eth*"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="<M1>", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="<M2>", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="<M3>", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="<M4>", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3"

2. Reboot the VM

3. Interfaces failed to rename with the error,
...error changing net interface name eth0 to eth1: File exists...

Even tried with ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules

Tried even renaming the interfaces to a temporary names using udev rules, say like, ens01 -> net0 and then from net0 -> eth0. In this, ens01 -> net0 worked but net0 -> eth0 didn't work and end up with the same error (error changing net interface.. file exists).

Using systemd.links

1. Removed the above udev rules
2. Configured [1-4].link files in /etc/systemd/network with below mapping,

[Match]
MACAddress=M1

[Link]
Name=eth0


3. Rebooted the VM.
4. Interfaces failed to rename.

We tried all above options with & without kernel parameters net.ifnames=0 biosdevname=0. Nothing worked out.

Can someone help us on this to persistent the MAC -> interface name mapping and consistent across all reboots.

Regards,
Srini

bkannadassan
Posts: 10
Joined: 2018/05/17 10:26:35

Re: Help on CentOS 7.6 MAC & interface swap

Post by bkannadassan » 2019/08/22 16:25:46

We are facing the same issue, did you find a way to get this working ?. We set biosdevname and ifnames to 0 in grub and though interface cameup with eth it kept moving to different pci's on every reboot.

rgds
Balaji

User avatar
Super Jamie
Posts: 310
Joined: 2014/01/10 23:44:51

Re: Help on CentOS 7.6 MAC & interface swap

Post by Super Jamie » 2019/08/26 10:09:59

Forcing "ethX" names for interfaces isn't possible anymore.

Either use the systemd/biosdevname naming, or call your interfaces a non-kernel name like "netX" or "prod" and "backup".

User avatar
TrevorH
Forum Moderator
Posts: 26590
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Help on CentOS 7.6 MAC & interface swap

Post by TrevorH » 2019/08/26 12:40:11

Forcing "ethX" names for interfaces isn't possible anymore.
Since when? It's always been possible to do this with CentOS 7 so far.
CentOS 5 died in March 2017 - migrate NOW!
CentOS 6 goes EOL sooner rather than later, get upgrading!
Full time Geek, part time moderator. Use the FAQ Luke

User avatar
Super Jamie
Posts: 310
Joined: 2014/01/10 23:44:51

Re: Help on CentOS 7.6 MAC & interface swap

Post by Super Jamie » 2019/08/26 22:36:09

Unfortunately, since EL7 came out.

Device enumeration order from the hardware isn't guaranteed or expected to be the same every boot, and systemd's udev doesn't do the "rename" shuffle that old EL6 and earlier udev used to do.

ethX naming appears to work fine... most of the time.

However, every so often you are guaranteed to have manually-named ethX devices swap around and end up with an incorrect IP configuration, as the posters above have encountered.

Some Red Hat knowledgebase references:

Is it safe to set net.ifnames=0 in RHEL7 and RHEL8?

How to use original ethX style NIC network interface device names in RHEL7

It's also mentioned in the product documentation:

https://access.redhat.com/documentation ... ice_Naming
Red Hat Enterprise Linux does not provide a way to consistently apply the ethX naming convention except under very specific circumstances.

User avatar
jlehtone
Posts: 2312
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Help on CentOS 7.6 MAC & interface swap

Post by jlehtone » 2019/08/27 08:37:29

You seem to be talking of sightly different things.

Trevor says that you can have ethN-style names in CentOS 7. That is true.

It is true that enumeration of eth-style names has never been consistent.

Jamie says that CentOS 7 does not provide means to get consistent eth-style names. That is true.

CentOS 6 has udev-based solution to rename devices. Personally, I did use it to rename from nonsense ethN to more logical "lan", "wan", etc. CentOS 7 (and future 8) have consistent names, but they are not in eth-style, although KVM guests on libvirt seem to get ethN consistently.

Does the ESXi present devices inconsistently for a guest?


PS. The "RH solutions" are not readable for all.

Post Reply

Return to “CentOS 7 - Networking Support”