From 05af0fc8635153dc69c1754592db665d3f064a14 Mon Sep 17 00:00:00 2001 From: Andreas Florath Date: Wed, 12 Jun 2019 13:53:38 +0000 Subject: [PATCH] debootstrap: make default network interface names configurable Nowadays, in the time of Predictable Network Interface Names, the network interface names 'ethX' are not used that often any more. Depending on the virtualization layer and the guest OS names like 'ens3', 'enp1s0' or 'enp0s31f6' are used. This patch enables the user to set DIB_NETWORK_INTERFACE_NAMES to a list of network interfaces which are brought up using DHCP during (first) boot. Change-Id: I04cc2ee710f0389a8085b1c91d9329784cb28048 Signed-off-by: Andreas Florath --- diskimage_builder/elements/debootstrap/README.rst | 9 ++++++++- .../debootstrap/environment.d/20-network-interface-names | 1 + .../elements/debootstrap/install.d/10-debian-networking | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 diskimage_builder/elements/debootstrap/environment.d/20-network-interface-names diff --git a/diskimage_builder/elements/debootstrap/README.rst b/diskimage_builder/elements/debootstrap/README.rst index a84006a6..e45e5bdd 100644 --- a/diskimage_builder/elements/debootstrap/README.rst +++ b/diskimage_builder/elements/debootstrap/README.rst @@ -69,7 +69,14 @@ Networking By default ``/etc/network/interfaces.d/eth[0|1]`` files will be created and enabled with DHCP networking. If you do not wish this to -be done, set ``DIB_APT_MINIMAL_CREATE_INTERFACES`` to ``0``. +be done, set ``DIB_APT_MINIMAL_CREATE_INTERFACES`` to ``0``. If you +need different interface names than ``eth[0|1]`` set +``DIB_NETWORK_INTERFACE_NAMES`` to a space separated list of network +interface names like: + +.. code-block:: bash + + export DIB_NETWORK_INTERFACE_NAMES="ens3 ens4" ------------------- Note on ARM systems diff --git a/diskimage_builder/elements/debootstrap/environment.d/20-network-interface-names b/diskimage_builder/elements/debootstrap/environment.d/20-network-interface-names new file mode 100644 index 00000000..3605a1c9 --- /dev/null +++ b/diskimage_builder/elements/debootstrap/environment.d/20-network-interface-names @@ -0,0 +1 @@ +export DIB_NETWORK_INTERFACE_NAMES=${DIB_NETWORK_INTERFACE_NAMES:-eth0 eth1} diff --git a/diskimage_builder/elements/debootstrap/install.d/10-debian-networking b/diskimage_builder/elements/debootstrap/install.d/10-debian-networking index 420e7413..09941ede 100755 --- a/diskimage_builder/elements/debootstrap/install.d/10-debian-networking +++ b/diskimage_builder/elements/debootstrap/install.d/10-debian-networking @@ -35,7 +35,7 @@ if [[ "${DIB_APT_MINIMAL_CREATE_INTERFACES:-1}" -eq "1" ]]; then echo "source /etc/network/interfaces.d/*" >> /etc/network/interfaces echo 'Network configuration set to source /etc/network/interfaces.d/*' fi - for interface in eth0 eth1; do + for interface in ${DIB_NETWORK_INTERFACE_NAMES}; do cat << EOF | tee /etc/network/interfaces.d/$interface auto $interface iface $interface inet dhcp