-1

I have a small application which takes in kernel code, and spins up VMs. I've been using this for kernel development. It is helpful and very fast when I want to spin up VMs with different kernel codes. The application uses qemu, and generates the qemu command on the fly based on the given options. The problem I am facing is ever changing network interface names.

The initial setup was such, that the interface names were ens*, and I had the following configuration in the /etc/network/interfaces to configure them to dhcp

allow-hotplug ens3
iface ens3 inet dhcp

I had a number of them, to make sure if the names gets pushed from ens3 to ens7 (maybe due to added qcow as scsi devices), the network interface ens7 still gets configured. It was working fine.

Now with the new Linux kernel 6.4-rc, I observe that the names of the interfaces are coming up as enp0s*. Now my /etc/network/interfaces configuration is not working. I can't keep changing the /etc/network/interfaces file according to kernel, cause that defeats the purpose of simply changing kernel code path and spinning up VMs. Btw, this was working fine for 2 years, and for kernel ranging from 4.19 to 6.1 (havent tested 6.2 and 6.3)

My question is, is there a default way to configure the network, such that any and all network interfaces come up with dhcp. Basically, something like

allow-hotplug all
iface all inet dhcp
Haris
  • 49
  • 1
  • 7

1 Answers1

2

There's several ways of doing this.

You could

  • generate /etc/network/interfaces during the boot process, using the names assigned
  • disable the renaming of devices (initially assigned eth0, eth1 ... will still be available by speciftying net.ifnames=0 on the kernel command line
  • Use udev rules to assign a name based on the MAC address
symcbean
  • 21,009
  • 1
  • 31
  • 52
  • The second one changes it to older `eth` format. I like the first one. Can you point out how to do this? Maybe yourself, or a link which describes this clearly. – Haris Jun 22 '23 at 14:26
  • You'll find a list of the devices in /sys/class/net - just exclude 'lo' and mailemerge your config. – symcbean Jun 22 '23 at 14:33