3

I had setup an infrastructure for automatic installation of Debian based machines. It uses PXE booting with DHCP and TFTP servers, and preseed to automate the OS installation.

What I want is:

  • use DHCP for PXE boot
  • use DHCP for Debian installer: it needs an IP address to access the preseed file and I don't want to enter it manually
  • use a static IP address on the final installed OS. This IP address will be specified in the preseed file.

But I can't find how to do that, even know if it's possible.

My current preseed file looks like this (network parameters only):

# netcfg will choose an interface that has link if possible. This makes it
# skip displaying a list if there is more than one interface.
d-i netcfg/choose_interface select auto

# If you prefer to configure the network manually, uncomment this line and
# the static network configuration below.
d-i netcfg/disable_autoconfig boolean true

# If you want the preconfiguration file to work on systems both with and
# without a dhcp server, uncomment these lines and the static network
# configuration below.
d-i netcfg/dhcp_failed note
d-i netcfg/dhcp_options select Configure network manually

# Static network configuration.
#
# IPv4 example
d-i netcfg/get_ipaddress string 192.168.1.10
d-i netcfg/get_netmask string 255.255.255.0
d-i netcfg/get_gateway string 192.168.1.254
d-i netcfg/get_nameservers string 192.168.1.1
d-i netcfg/confirm_static boolean true

(I also tested commenting the line d-i netcfg/disable_autoconfig boolean true with the same result).

Do anyone knows how to do that?

Thanks.

ps: It's Debian Wheezy

daks
  • 673
  • 6
  • 23

1 Answers1

3

Use in preseed options of your's own command execution after installation:

d-i preseed/late_command string wget http://your-web_or_ftp/unattend/dopostinstall.sh -O /tmp/dopostinstall.sh;  chmod +x /tmp/dopostinstall.sh; /tmp/dopostinstall.sh

The dopostinstall.sh something like that:

#!/bin/ash

echo -e "auto lo eth0 \niface lo inet loopback\n\niface eth0 inet static\n\t address 192.168.1.10\n\t netmask 255.255.255.0\n\t gateway 192.168.1.254\n\t dns-nameservers 192.168.1.1" > /target/etc/network/interfaces
serj
  • 31
  • 2
  • Thanks for this tip, even if it's not the way I wanted to do it, directly from debian-installer. Maybe there is a bug or my use case is special. I'll try it. – daks Sep 17 '13 at 11:57
  • I believe this answer is not tested carefully. It would be a problem to use `wget` that requires an active internet to download the script file just for fixing the internet. Instead, we should have a ready script inside installation. – MaXi32 Apr 08 '21 at 15:52