MAC Address changes between interfaces during each reboot in centos 7.6

Issues related to configuring your network
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/08 12:37:48

I did it after the installation (don't remember, but it probably required a reboot).

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 13:05:15

tunk wrote:
2019/05/08 12:37:48
I did it after the installation (don't remember, but it probably required a reboot).
Now the problem is taking correct interface order for renaming from en* to eth*

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/08 13:59:56

I seem to remember that I only edited these two files:

Code: Select all

# more /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"

# more /etc/sysconfig/network-scripts/ifcfg-eth0 
TYPE=Ethernet
BOOTPROTO=static
NAME=eth0
NM_CONTROLLED=no
DEVICE=eth0
ONBOOT=yes
HWADDR=01:12:23:34:45:56
DNS1="something"
DNS2="something"
IPADDR="something"
GATEWAY="something"
NETMASK="something"
NETWORK="something"
IPV6INIT=no

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 14:36:34

tunk wrote:
2019/05/08 13:59:56
I seem to remember that I only edited these two files:

Code: Select all

# more /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"

# more /etc/sysconfig/network-scripts/ifcfg-eth0 
TYPE=Ethernet
BOOTPROTO=static
NAME=eth0
NM_CONTROLLED=no
DEVICE=eth0
ONBOOT=yes
HWADDR=01:12:23:34:45:56
DNS1="something"
DNS2="something"
IPADDR="something"
GATEWAY="something"
NETMASK="something"
NETWORK="something"
IPV6INIT=no
Before renaming, the actual interfaces will be in the following order
ip a
enp3s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether <mac> brd ff:ff:ff:ff:ff:ff
enp2s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether <mac> brd ff:ff:ff:ff:ff:ff
enp9s0f0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether <mac> brd ff:ff:ff:ff:ff:ff
enp9s0f1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether <mac> brd ff:ff:ff:ff:ff:ff

The renaming will be done in the following manner.
enp3s0 -> eth0,enp2s0 -> eth1,enp9s0f0 -> eth2,enp9s0f1->eth3

But some times the interface listing order changes.
ip a
enp2s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether <mac> brd ff:ff:ff:ff:ff:ff
enp3s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether <mac> brd ff:ff:ff:ff:ff:ff
enp9s0f1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether <mac> brd ff:ff:ff:ff:ff:ff
enp9s0f0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether <mac> brd ff:ff:ff:ff:ff:ff

In this case, I am not sure in which order interfaces have to be renamed

aks
Posts: 2807
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/08 17:34:31

changes has to be done during installation process
Okay so how are you installing?

For example, say we're doing PXE/DHCP with kickstart, then the interfaces don't really matter - for the installation all that really matters is that you can get to the installation media/repo/whatever and the PXE server. Post installation, you can rename/shuffle about as needed.
Is there any unique attribute that can be considered for correct order during the renaming process
Probably, but that's local knowledge. If you know what networks you can have, you could try each interface in turn to determine if you can get to a "well known" (like a router) . The ICMP ping command supports -I <interface>. Or you could use DHCP to determine which network you are connected to (DHCP *should* give you a unique address and subnet mask, from which you can derive the network address). Or you could listen to the broadcasts on each interface to determine which network you are connected to. If IPv6 is (truly) involved, then things change again (IPv6 "does away" with ARP).

If this is some installation that's then shipped off to (say a customer's site) - i.e.: unknown networks, then you have limited choice. You'd have to set them to DHCP and adjust accordingly - but then the knowledge of what you're trying to get to comes into play - so maybe the DHCP server also gives you a list of routers, or perhaps routers are advertised by the router.

But that's all requires local knowledge.

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/15 07:10:14

Sorry in getting back late.

Thanks aks for your suggestion. It really helped.

Yes, exactly it is with the local knowledge. We came up with an approach, that the user has to choose the MAC address from the available MAC addresses for each interfaces (after fresh installation). Once the user selects the MAC and the interfaces, this mapping is written to udev rules. So in this way, after subsequent reboots it worked fine.

Appreciate all your help.

Post Reply