How to prevent interface name changes?

Issues related to configuring your network
InRi
Posts: 3
Joined: 2017/10/09 10:16:48

How to prevent interface name changes?

Postby InRi » 2017/10/09 10:41:55

Hello dear CentOS community,

we are running a server with CentOS 6.9 final installed on it. Last update via yum 6th Oct. 2017. On this machine several VMs are running under KVM (qemu-kvm.x86_64 2:0.12.1.2-2.503.el6_9.3). The virtual network interfaces of the VMs use the passthrough mode. On the host machine I provide every network interface under /etc/sysconfig/network-scripts/ with the corresponding MAC address of the VM's virtual NIC. Same goes for the /etc/udev/rules.d/70-persistent-net.rules.

Problem:
When I shutdown every VM and restart the host system, the network interfaces will be renamed, because the MAC addresses of the physical NICs do not match the virtual ones in the ifcfg-ethX files. So, for example, I now have the old eth1, eth2, eth3 entries of the VMs, alongside the new entries eth4, eth5, eth6 given to the physical NICs. Same goes for the net.rules file. Thus, when I try to boot up the VMs it will fail, because the expected interface for the VM is not really there anymore. I always have to change the entries manually to get the guests running again.

Question:
Is there a way to prevent this renaming, so that I do not have to correct everything again and again?


Thank you in advance and best regards,
InRi

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

Re: How to prevent interface name changes?

Postby TrevorH » 2017/10/09 13:05:25

Are you changing the MAC addresses of the interface cards?
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

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

Re: How to prevent interface name changes?

Postby jlehtone » 2017/10/11 07:28:11

InRi wrote:The virtual network interfaces of the VMs use the passthrough mode. On the host machine I provide every network interface under /etc/sysconfig/network-scripts/ with the corresponding MAC address of the VM's virtual NIC.

I don't quite understand.

The VM never dictates any MACs. It is the KVM config in the host that sets a MAC for VM interface.

I'm a bit hazy on the passthrough modes, but I would assume that when a VM uses host's interface "passthrough", the VM really uses the physical NIC and the MAC of the physical NIC is then the MAC of the interface of the VM. (Might be the PCI passthrough mode, where physical NIC is invisible to the host while it is used by the VM.)

I have had a VM that had in its config (in CentOS 6):

Code: Select all

    <interface type='direct'>
      <mac address='52:54:00:09:5a:9e'/>
      <source dev='em2' mode='passthrough'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </interface>

The interface of the VM was matched to physical NIC with the source dev attribute
and host had a ifcfg-em2:

Code: Select all

DEVICE=em2
HWADDR=*:*:52:69:4c:1a
ONBOOT=yes

Different MACs. No renaming.

InRi
Posts: 3
Joined: 2017/10/09 10:16:48

Re: How to prevent interface name changes?

Postby InRi » 2017/10/11 09:29:30

The physical NICs come with their own MAC addresses. When the host boots up, config files are created. Each interface gets such a config file and each config file holds the MAC address of the physical NIC.

For the guest systems to work properly in DMZ, I have to choose the passthrough mode for each virtual NIC in KVM. Then I take the MAC addresses from these virtual NICs and paste them in the above mentioned config files on the host system. So, I replace the physical MAC addresses with the virtual MAC addresses in the host's config files. Only then networking for the guests works properly.

Now, if I shutdown VMs and host, then boot the host up again, the old configs on the host are left untouched. However, the physical network interfaces got new names. Instead of eth1, eth2, eth3 it's then eth4, eth5, eth6. All of them expect new config files. I think, since the 70-persistent-net.rules holds eth1, eth2, and eth3 with specific MAC addresses (virtual), which don't match the physical addresses, the system just thinks these (physical) interfaces are new and thus gives them new names.

Question is, how do I prevent this? I want, that the host boots up and leaves the names untouched, so that I only have to bring the VMs back up, without any network error messages caused by this naming issue.

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

Re: How to prevent interface name changes?

Postby jlehtone » 2017/10/11 11:18:05

Why?

I just wrote that I've seen a functional setup, where the host NIC kept it's MAC and a VM used that NIC with different MAC (in some passthrough mode).

You say that something requires passthrough. Fine, passthrough (although you have not told which; there are many).

What does that have to do with MACs?
Why should host and VM use the same MAC?


I don't believe that you are asking the right question. You have not told enough (about your network) for me to be sure, but it sure looks like you are desperately trying to shoehorn a workaround for a problem that should not exist in the first place. Like a patient that demands painkillers from a doctor for pain in leg, but neglects to mention that there is still a lion gnawing the leg.

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

Re: How to prevent interface name changes?

Postby TrevorH » 2017/10/11 11:41:13

I'd guess the VM is changing the actual MAC on the real hardware since it's passed through. Then when the host sees it, it has a new MAC address than the one it was expecting and thus it treats it as a new interface. Solution, get the guest to use the same MAC as the real hardware.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

Whoever
Posts: 964
Joined: 2013/09/06 03:12:10

Re: How to prevent interface name changes?

Postby Whoever » 2017/10/11 14:53:38

Why do you need passthrough mode?

Why not use bridge mode, then the VM will have its own, persistent MAC address.

InRi
Posts: 3
Joined: 2017/10/09 10:16:48

Re: How to prevent interface name changes?

Postby InRi » 2017/10/12 11:57:42

jlehtone: I can only see one network passthrough mode. The VMs are within a DMZ and each VM has its own public IP. So, each VM should have its own/dedicated physical interface on the host system. In other words, when I pull a specific network cable, a specific VM has to lose its connection.

Whoever: The VMs already have their own MAC addresses. I take them and put them in the ifcfg files on the host machine. If I don't do that, the VMs simply will fail to boot up. Bridge mode seems to be designed for LAN use. I need direct WAN facing.

TrevorH: That sounds good, but won't there be a conflict, like when you give two machines one and the same IP address?

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

Re: How to prevent interface name changes?

Postby TrevorH » 2017/10/12 13:09:58

I don't think there will be a confict since the cards are passed through to the guest so the host won't be able to use them. I think your problem comes from trying to use them on the guest with a MAC other than their real one. If you use the real MAC address then I think everything will be happy.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

Whoever
Posts: 964
Joined: 2013/09/06 03:12:10

Re: How to prevent interface name changes?

Postby Whoever » 2017/10/12 14:13:35

InRi wrote:Whoever: The VMs already have their own MAC addresses. I take them and put them in the ifcfg files on the host machine. If I don't do that, the VMs simply will fail to boot up. Bridge mode seems to be designed for LAN use. I need direct WAN facing.


You can use Bridge mode on WAN facing interfaces. Then you don't need to configure the MAC addresses in the ifcfg files on the host.