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