MAC Address changes between interfaces during each reboot in centos 7.6

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

MAC Address changes between interfaces during each reboot in centos 7.6

Post by tsrini » 2019/05/07 10:44:17

We have tried to rename the interfaces from default naming to traditional ethX style using the following approaches.

Approach 1
1) Added net.ifnames=0 biosdevname=0 in /etc/default/grub and ran grub2-mkconfig
2) renamed /etc/sysconfig/network-scripts/ifcfg-en* files to /etc/sysconfig/network-scripts/ifcfg-eth*
3) changed the NAME and DEVICE to eth0 /etc/sysconfig/network-scripts/ifcfg-eth0, NAME and DEVICE to eth1 /etc/sysconfig/network-scripts/ifcfg-eth1 - etc

Approach 2
1) Added net.ifnames=0 in /etc/default/grub and ran grub2-mkconfig
2) Added HWADDR in /etc/sysconfig/network-scripts/ifcfg-eth* files
3) Instead of HWADDR, tried by setting MACADDR in ifcfg-eth* files

Approach 3
1) Added net.ifnames=0 in /etc/default/grub and ran grub2-mkconfig
2) Added the following udev rules in /etc/udev/rules.d/60-net.rules
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="mac1", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="mac2", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="mac3", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="mac4", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3"

In this approach we could see the following erros in systemd-udev.service status.
Apr 20 05:32:38 HOSTNAME systemd-udevd: error changing net interface name eth0 to eth1: File exists
Apr 20 05:32:38 HOSTNAME systemd-udevd: error changing net interface name eth1 to eth0: File exists

The MAC addresses are getting swapped between interfaces during each reboot. Couldn't get any solution from Internet.

Is there any approach available to have permanent MAC Addr & interface name mapping across reboots.
Last edited by tsrini on 2019/05/07 11:10:50, edited 1 time in total.

tunk
Posts: 564
Joined: 2017/02/22 15:08:17

Re: MAC Address changes between interfaces during each reboot in centos 7.6

Post by tunk » 2019/05/07 10:53:45

I had to change the name of one interface, and I did it in /etc/udev/rules.d/70-persistent-ipoib.rules:
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="01:12:23:34:45:56", ATTR {type}=="1", KERNEL=="eth*", NAME="public"

Link: https://www.schrodinger.com/kb/1649

tsrini
Posts: 18
Joined: 2018/04/06 13:25:09

Re: MAC Address changes between interfaces during each reboot in centos 7.6

Post by tsrini » 2019/05/07 11:52:21

tunk wrote:
2019/05/07 10:53:45
I had to change the name of one interface, and I did it in /etc/udev/rules.d/70-persistent-ipoib.rules:
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="01:12:23:34:45:56", ATTR {type}=="1", KERNEL=="eth*", NAME="public"

Link: https://www.schrodinger.com/kb/1649
This apporach only works in Centos 6 .

tunk
Posts: 564
Joined: 2017/02/22 15:08:17

Re: MAC Address changes between interfaces during each reboot in centos 7.6

Post by tunk » 2019/05/07 12:08:51

Forgot to say it's on a 7.6 system.

tsrini
Posts: 18
Joined: 2018/04/06 13:25:09

Re: MAC Address changes between interfaces during each reboot in centos 7.6

Post by tsrini » 2019/05/07 12:16:49

This approach may work for system with single interface.But in our case system contains 4 interfaces.Have you tested with multiple interfaces?

tunk
Posts: 564
Joined: 2017/02/22 15:08:17

Re: MAC Address changes between interfaces during each reboot in centos 7.6

Post by tunk » 2019/05/07 13:21:14

I've only changed one NIC (eth0), and HWADDR was added to the config file.
The other NIC (em4) was left unchanged (again with HWADDR).
networkmanager is disabled.

tsrini
Posts: 18
Joined: 2018/04/06 13:25:09

Re: MAC Address changes between interfaces during each reboot in centos 7.6

Post by tsrini » 2019/05/07 13:30:26

tunk wrote:
2019/05/07 13:21:14
I've only changed one NIC (eth0), and HWADDR was added to the config file.
The other NIC (em4) was left unchanged (again with HWADDR).
networkmanager is disabled.
In my case I want to change all the 4 interfaces.

tunk
Posts: 564
Joined: 2017/02/22 15:08:17

Re: MAC Address changes between interfaces during each reboot in centos 7.6

Post by tunk » 2019/05/07 13:34:24

I don't know if it will work, but here's what I would try:
- disable networkmanager (if not already done)
- update /etc/udev/rules.d/70-persistent-ipoib.rules with the four NICs
- add HWADDR to the four config files

aks
Posts: 2806
Joined: 2014/09/20 11:22:14

Re: MAC Address changes between interfaces during each reboot in centos 7.6

Post by aks » 2019/05/07 17:49:05

First remove all interfaces, then add.

tsrini
Posts: 18
Joined: 2018/04/06 13:25:09

Re: MAC Address changes between interfaces during each reboot in centos 7.6

Post by tsrini » 2019/05/08 11:12:55

Now it is working fine.

But there is a problem.These changes has to be done during installation process .We thought to rename the interfaces from ifcfg-en* to ifcfg-eth* based ip addr command or ifindex attribute.But it seems we can't rely on these methods.Is there any unique attribute that can be considered for correct order during the renaming process?

Post Reply