Rich Freeman via plug on 28 Jun 2020 08:46:50 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Virtual machine NIC device name


On Sun, Jun 28, 2020 at 11:30 AM K.S. Bhaskar via plug
<plug@lists.phillylinux.org> wrote:
>
> I created a Debian 10 virtual machine for users and customers to learn
> database administration and operations (including crash recovery;
> virtual machines being well suited to that). It has a single virtual
> NIC. When I boot it on my Arch Linux laptop with qemu, the virtual NIC
> has the name ens3, whereas when booted with Virtual Box on various
> operating systems, the virtual NIC has the name enp0s3. Since I would
> like the virtual machine to just come up with an IP address obtained
> by DHCP from the virtualization software. This means that they have to
> login from the console and manually edit /etc/network/interfaces. Is
> there any way to configure the virtual machine to just either give the
> NIC a consistent name,
>

You're using different software so getting them to behave identically
without any config tweaks is going to be difficult.  I suspect the
difference comes down to how the VM presents the connectivity of the
interface (what PCI slot it is in, etc).  If you can control that then
you might get the name to be consistent, assuming the distros you're
running inside use the same udev rules.

> or to tell it “whatever the NIC is called,
> just use DHCP to get an IP address”?

This is the approach I usually take.  I typically stick this in my
systemd-networkd config:
cat /etc/systemd/network/static.network
[Match]
Name=e*

[Network]
DHCP=yes

Really though I've found that most distros set up dhcp by default, so
I'm not sure why you even need to fiddle with it.

This is assuming you're using networkd as your network manager.
Obviously the details will vary if you're using something else.  A lot
of the legacy distros use their own solutions so there will be
variance if you're using one.

-- 
Rich

-- 
Rich
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug