Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Host’s /etc/network/interfaces installed into VM image #181

Open
paulmenzel opened this issue Jun 7, 2021 · 5 comments
Open

Host’s /etc/network/interfaces installed into VM image #181

paulmenzel opened this issue Jun 7, 2021 · 5 comments
Labels

Comments

@paulmenzel
Copy link
Contributor

Using --vm or --vmfile implies --nointerfaces, but in my test, the host /etc/network/interfaces was installed into the virtual machine image. I am going to debug this, but wanted to document the issue.

@mika
Copy link
Member

mika commented Jun 7, 2021

When installing a VM, then the "$DEFAULT_INTERFACES" is supposed to be set up, defined as:

  DEFAULT_INTERFACES="# /etc/network/interfaces - generated by grml-debootstrap

# Include files from /etc/network/interfaces.d when using
# ifupdown v0.7.44 or newer:
#source-directory /etc/network/interfaces.d

auto lo                                                                                                                                                                                                                                     
iface lo inet loopback

allow-hotplug eth0
iface eth0 inet dhcp
"

@mika mika added the verify label Jun 7, 2021
@paulmenzel
Copy link
Contributor Author

$ sudo kpartx -av test.iso
$ sudo mount /dev/mapper/loop0p1 /mnt
$ more /mnt/etc/network/interfaces
# /etc/network/interfaces - generated by grml-debootstrap

# Include files from /etc/network/interfaces.d when using
# ifupdown v0.7.44 or newer:
#source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

allow-hotplug eth0
iface eth0 inet dhcp

allow-hotplug enp3s0
iface enp3s0 inet dhcp

With set -x:

+ cp /home/joey/src/grml-debootstrap-config-vm/locale.gen /mnt/debootstrap.13526/etc/locale.gen
cp: cannot stat '/home/joey/src/grml-debootstrap-config-vm/locale.gen': No such file or directory
+ '[' -d /home/joey/src/grml-debootstrap-config-vm/bin ']'
+ '[' -d /home/joey/src/grml-debootstrap-config-vm/boot ']'
+ '[' -d /home/joey/src/grml-debootstrap-config-vm/etc ']'
+ '[' -d /home/joey/src/grml-debootstrap-config-vm/sbin ']'
+ '[' -d /home/joey/src/grml-debootstrap-config-vm/share ']'
+ '[' -d /home/joey/src/grml-debootstrap-config-vm/usr ']'
+ '[' -d /home/joey/src/grml-debootstrap-config-vm/var ']'
+ DEFAULT_INTERFACES='# /etc/network/interfaces - generated by grml-debootstrap

# Include files from /etc/network/interfaces.d when using
# ifupdown v0.7.44 or newer:
#source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

allow-hotplug eth0
iface eth0 inet dhcp
'
+ '[' -x /bin/udevadm ']'
++ mktemp
+ tmpfile=/tmp/tmp.7KWfEvO84q
+ for interface in /sys/class/net/*
+ udevadm info --query=all --path=/sys/class/net/dummy0
+ grep -q 'P: /devices/virtual/net/' /tmp/tmp.7KWfEvO84q
+ continue
+ for interface in /sys/class/net/*
+ udevadm info --query=all --path=/sys/class/net/lo
+ grep -q 'P: /devices/virtual/net/' /tmp/tmp.7KWfEvO84q
+ continue
+ for interface in /sys/class/net/*
+ udevadm info --query=all --path=/sys/class/net/net00
+ grep -q 'P: /devices/virtual/net/' /tmp/tmp.7KWfEvO84q
+ for property in ID_NET_NAME_FROM_DATABASE ID_NET_NAME_ONBOARD ID_NET_NAME_SLOT ID_NET_NAME_PATH ID_NET_NAME_MAC
+ grep -q ID_NET_NAME_FROM_DATABASE /tmp/tmp.7KWfEvO84q
+ for property in ID_NET_NAME_FROM_DATABASE ID_NET_NAME_ONBOARD ID_NET_NAME_SLOT ID_NET_NAME_PATH ID_NET_NAME_MAC
+ grep -q ID_NET_NAME_ONBOARD /tmp/tmp.7KWfEvO84q
+ for property in ID_NET_NAME_FROM_DATABASE ID_NET_NAME_ONBOARD ID_NET_NAME_SLOT ID_NET_NAME_PATH ID_NET_NAME_MAC
+ grep -q ID_NET_NAME_SLOT /tmp/tmp.7KWfEvO84q
+ for property in ID_NET_NAME_FROM_DATABASE ID_NET_NAME_ONBOARD ID_NET_NAME_SLOT ID_NET_NAME_PATH ID_NET_NAME_MAC
+ grep -q ID_NET_NAME_PATH /tmp/tmp.7KWfEvO84q
++ grep ID_NET_NAME_PATH /tmp/tmp.7KWfEvO84q
++ sed -n -e 's/E: ID_NET_NAME_PATH=\([^$*]\)/\1/p'
+ interface=enp3s0
+ DEFAULT_INTERFACES='# /etc/network/interfaces - generated by grml-debootstrap

# Include files from /etc/network/interfaces.d when using
# ifupdown v0.7.44 or newer:
#source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

allow-hotplug eth0
iface eth0 inet dhcp

allow-hotplug enp3s0
iface enp3s0 inet dhcp
'
+ break
+ rm -f /tmp/tmp.7KWfEvO84q
+ '[' -n '' ']'
+ '[' -n '' ']'
+ '[' -n 1 ']'
+ einfo 'Setting up Virtual Machine, installing default /etc/network/interfaces'
+ einfon 'Setting up Virtual Machine, installing default /etc/network/interfaces\n'
+ '[' '' '!=' yes ']'
+ '[' einfon = ebegin ']'
+ printf ' %s*%s Setting up Virtual Machine, installing default /etc/network/interfaces\n' '' ''
 * Setting up Virtual Machine, installing default /etc/network/interfaces
+ LAST_E_CMD=einfon
+ return 0
+ return 0
+ mkdir -p /mnt/debootstrap.13526/etc/network
+ echo '# /etc/network/interfaces - generated by grml-debootstrap

# Include files from /etc/network/interfaces.d when using
# ifupdown v0.7.44 or newer:
#source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

allow-hotplug eth0
iface eth0 inet dhcp

allow-hotplug enp3s0
iface enp3s0 inet dhcp
'
+ eend 0
+ local retval=0
+ shift
+ '[' 0 -gt 0 ']'
+ return 0
+ '[' -r /etc/network/interfaces.examples ']'
+ '[' -n '' ']'
+ '[' -n '' ']'
+ '[' -d /run/udev ']'
+ einfo 'Setting up bind-mount /run/udev'

@paulmenzel
Copy link
Contributor Author

Looking at

# network setup
DEFAULT_INTERFACES="# /etc/network/interfaces - generated by grml-debootstrap
# Include files from /etc/network/interfaces.d when using
# ifupdown v0.7.44 or newer:
#source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet dhcp
"
# add dhcp setting for Predictable Network Interface Names
if [ -x /bin/udevadm ]; then
tmpfile=$(mktemp)
for interface in /sys/class/net/*; do
udevadm info --query=all --path="${interface}" > "${tmpfile}"
# skip virtual devices, like bridges, vboxnet,...
if grep -q 'P: /devices/virtual/net/' "${tmpfile}" ; then
continue
fi
# iterate over possible naming policies by precedence (see udev/net/link-config.c),
# use and stop on first match to have same behavior as udev's link_config_apply()
for property in ID_NET_NAME_FROM_DATABASE ID_NET_NAME_ONBOARD ID_NET_NAME_SLOT ID_NET_NAME_PATH ID_NET_NAME_MAC ; do
if grep -q "${property}" "${tmpfile}" ; then
interface=$(grep "${property}" "${tmpfile}" | sed -n -e "s/E: ${property}=\([^\$*]\)/\1/p")
DEFAULT_INTERFACES="${DEFAULT_INTERFACES}
allow-hotplug ${interface}
iface ${interface} inet dhcp
"

the code adding DHCP settings for predictable network interface names, extends the variable with all these interfaces unconditionally.

@mika
Copy link
Member

mika commented Jun 7, 2021

Thanks for debugging, so it's not about host's /etc/network/interfaces, but about the extended default configuration, I see.
I'm afraid there's no easy solution to this, and we're considering switching to systemd-networkd anyway (see e.g. #136 + #110) , which should also solve this problem.

@paulmenzel
Copy link
Contributor Author

Thanks for debugging, so it's not about host's /etc/network/interfaces, but about the extended default configuration, I see.

Yes, sorry for not being clear about that. Is there any use case by having “build host” network device information in the VM?

I'm afraid there's no easy solution to this,

I am going to work around it using --nointerfaces.

and we're considering switching to systemd-networkd anyway (see e.g. #136 + #110) , which should also solve this problem.

I am looking forward to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants