2

This question already has an answer here:

I have CentOS-6.5 running in qemu-based virtual machine, with a single ethernet interface, which surprisingly is being renamed by udev from eth0 to eth1 for whoever knows reason (!)

So I want to to completely disable this behavior, i.e. passed "net.ifnames=0" to the kernel command line. It doesn't seem to work, the behaviour has not changed. Neither "biosdevname=0" as a kernel parameter didn't help.

% qemu-system-x86_64 -cpu host -boot c -hda my_image.qcow2 -snapshot
-m 1024 --enable-kvm -name vm0 -nographic -display curses -pidfile
/var/run/vm0.pid -mem-path /dev/hugepages -mem-prealloc -monitor
unix:/var/run/vm0monitor,server,nowait -net none -netdev
type=tap,id=net0,script=no,downscript=no,ifname=vhost1,vhost=on
-device virtio-net-pci,netdev=net0,mac=00:00:00:00:00:01,csum=off,gso=off,guest_tso4=off,guest_tso6=off,guest_ecn=off

No warnings or errors, and I can login the VM afterwards. However it seems that udev has renamed single network interface form eth0 to eth1, here is a rule file automatically created at boot:

% cat /etc/udev/rules.d/70-persistent-net.rules
# PCI device 0x1af4:0x1000 (virtio-pci)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:00:00:00:00:0
1", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

Why would virtio-pci driver choose eth1 for the single interface in the system?

However this does not happen if I run qemu without mac=.. option, ie. the MAC address is qemu predefined 52:54:xxx but I want to provide the macs via command line.

marked as duplicate by Braiam, cuonglm, Anthon, jasonwryan, slm Nov 1 '14 at 0:58

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • You sure it was to "eth1"? – Braiam Oct 31 '14 at 16:28
  • Are you all certain that this is a duplicate of the linked question? That refers to Predictable Interface Naming while this one asks why the kernel names the first/only interface as eth1 instead of the expected eth0. – garethTheRed Nov 3 '14 at 16:31
5

Delete:

/etc/udev/rules.d/70-persistent-net.rules

and reboot. udev will find your network adapter and name it eth0. It will then recreate the file above with a rule that consistently names that adapter eth0.

If you read the file before you delete it, you'll find a rule that names the adapter eth1. You may have another rule in the file that names a certain adapter eth0. This often happens if you replaced an adapter at some point in the past.

To completely disable this behaviour, make the file above a symbolic link to /dev/null:

# ln -s /dev/null /etc/udev/rules.d/70-persistent-net.rules
  • thanks for comment. Please see my updated original post. I tried your advice, it didn't help though. I think it could be because it happens in qemu-based VM. – Mark Nov 3 '14 at 16:16
  • Is it because you have: netdev=net1,mac=00:00 but earlier in the command line you have type=tap,id=net0, (you have net1 in the former and net0 in the latter). I believe they should be the same. – garethTheRed Nov 3 '14 at 16:48
  • that was a type, thanks for pointing, I corrected the original post. I think I've found the root cause: the file /etc/sysconfig/network-scipts/ifcfg-eth0 i the VM contained HWADDR different with what I specified on the command line to qemu, and it was probably rejected. Once I edited it, qemu boots and stays with eth0 interface. – Mark Nov 3 '14 at 18:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.