Skip to content

Commit 58b9a23

Browse files
committed
Prepare switch from legacy network interfaces to systemd-networkd
By default grml-debootstrap used the host /etc/network/interfaces file to configure the network of the guest system. We now provide a systemd-networkd configuration enabling DHCP on all network devices next to the legacy /etc/network/interfaces which only enables DHCP on eth0 (which does not work when using the predictable devices names). If no networking option is given, this will be the new default. NOTE: systemd-networkd is currently not enabled by default.
1 parent 242470a commit 58b9a23

1 file changed

Lines changed: 22 additions & 23 deletions

File tree

grml-debootstrap

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ MNTPOINT="/mnt/debootstrap.$$"
7979
[ -n "$TIMEZONE" ] || TIMEZONE='Europe/Vienna'
8080
[ -n "$TUNE2FS" ] || TUNE2FS='tune2fs -c0 -i0'
8181
[ -n "$UPGRADE_SYSTEM" ] || UPGRADE_SYSTEM='yes'
82+
[ -n "$USE_DEFAULT_INTERFACES" ] || USE_DEFAULT_INTERFACES="true"
8283
[ -n "$VMSIZE" ] || VMSIZE="2G"
8384

8485
# inside the chroot system locales might not be available, so use minimum:
@@ -140,11 +141,9 @@ Configuration options:
140141
--nopackages Skip installation of packages defined in
141142
/etc/debootstrap/packages
142143
--nokernel Skip installation of default kernel images.
143-
--nointerfaces Do not copy /etc/network/interfaces from host system
144-
to target system.
145-
(This option is automatically enabled when using --vmfile.)
146-
--defaultinterfaces Install a default /etc/network/interfaces file (enabling
147-
DHCP for eth0) instead of taking over config from host system.
144+
--nointerfaces Skip installation of default network configuration.
145+
--defaultinterfaces Install a default /etc/systemd/network/80-dhcp.network file
146+
(enabling DHCP for all network devices). (default)
148147
--debconf <file> Pre-seed packages using specified pre-seed db file.
149148
--grmlrepos Enable Grml's Debian repository (deb.grml.org).
150149
--backportrepos Enable Debian's backports repository (backports.debian.org).
@@ -441,10 +440,10 @@ while :; do
441440
--password) # Use specified password as password for user root
442441
shift; _opt_password="$1"
443442
;;
444-
--defaultinterfaces) # Install default /etc/network/interfaces
443+
--defaultinterfaces) # Install a default /etc/systemd/network/80-dhcp.network file
445444
_opt_defaultinterfaces=T
446445
;;
447-
--nointerfaces) # Skip installation of /etc/network/interfaces
446+
--nointerfaces) # Skip installation of default network configuration.
448447
_opt_nointerfaces=T
449448
;;
450449
--nokernel) # Skip installation of default kernel images
@@ -1673,6 +1672,16 @@ preparechroot() {
16731672
[ -d "${CONFFILES}"/var ] && cp $VERBOSE -a -L "${CONFFILES}"/var/* "${MNTPOINT}"/var/
16741673

16751674
# network setup
1675+
1676+
# systemd-networkd
1677+
DEFAULT_SYSTEMD_NETWORKD="# /etc/systemd/network/80-dhcp.network - generated by grml-debootstrap
1678+
[Match]
1679+
Name=en*
1680+
1681+
[Network]
1682+
DHCP=yes
1683+
"
1684+
# legacy network interfaces
16761685
DEFAULT_INTERFACES="# /etc/network/interfaces - generated by grml-debootstrap
16771686
16781687
# Include files from /etc/network/interfaces.d when using
@@ -1687,30 +1696,20 @@ iface eth0 inet dhcp
16871696
"
16881697

16891698
if [ -n "$NOINTERFACES" ] ; then
1690-
einfo "Not installing /etc/network/interfaces as requested via --nointerfaces option" ; eend 0
1699+
einfo "Not installing /etc/systemd/network/80-dhcp.network as requested via --nointerfaces option"
1700+
eend 0
16911701
elif [ -n "$USE_DEFAULT_INTERFACES" ] ; then
1692-
einfo "Installing default /etc/network/interfaces as requested via --defaultinterfaces options."
1702+
einfo "Installing default /etc/systemd/network/80-dhcp.network as requested via --defaultinterfaces options."
1703+
echo "$DEFAULT_SYSTEMD_NETWORKD" > "${MNTPOINT}/etc/systemd/network/80-dhcp.network"
16931704
echo "$DEFAULT_INTERFACES" > "${MNTPOINT}/etc/network/interfaces"
16941705
eend $?
16951706
elif [ -n "$VIRTUAL" ] ; then
1696-
einfo "Setting up Virtual Machine, installing default /etc/network/interfaces"
1697-
echo "$DEFAULT_INTERFACES" > "${MNTPOINT}/etc/network/interfaces"
1698-
eend $?
1699-
elif [ -r /etc/network/interfaces ] ; then
1700-
einfo "Copying /etc/network/interfaces from host to target system"
1701-
cp $VERBOSE /etc/network/interfaces "${MNTPOINT}/etc/network/interfaces"
1702-
eend $?
1703-
else
1704-
ewarn "Couldn't read /etc/network/interfaces, installing default /etc/network/interfaces"
1707+
einfo "Setting up Virtual Machine, installing default /etc/systemd/network/80-dhcp.network"
1708+
echo "$DEFAULT_SYSTEMD_NETWORKD" > "${MNTPOINT}/etc/systemd/80-dhcp.network"
17051709
echo "$DEFAULT_INTERFACES" > "${MNTPOINT}/etc/network/interfaces"
17061710
eend $?
17071711
fi
17081712

1709-
# install config file providing some example entries
1710-
if [ -r /etc/network/interfaces.examples ] && [ ! -r "$MNTPOINT/etc/network/interfaces.examples" ] ; then
1711-
cp /etc/network/interfaces.examples "$MNTPOINT/etc/network/interfaces.examples"
1712-
fi
1713-
17141713
eend 0
17151714
}
17161715
# }}}

0 commit comments

Comments
 (0)