The scenario

You have a local network with a server and a client. You want install debian on the client by booting over the network using a kernel image stored on the server.

help.ubuntu.com/community/Installation/...
help.ubuntu.com/community/Installation/...
archive.ubuntu.com/ubuntu/dists/jaunty/.../

Installing DHCP server

The target computer needs to get its network information from DHCP. If you have another DHCP server running on the network, disable it for now.

On the server:

# apt-get install dnsmasq

Configuration

Fill out these configuration options in /etc/dnsmasq.conf:

codetitle. /etc/dnsmasq.conf

dhcp-range=<BEGIN_IP_RANGE>,<END_IP_RANGE>,12h
dhcp-boot=pxelinux.0,<SERVER_IP>
dhcp-option=3,<DEFAULT_GW>
dhcp-option=6,<DNS_SERVER>

For example:

codetitle. /etc/dnsmasq.conf

dhcp-range=192.168.0.20,192.168.0.30,12h
dhcp-boot=pxelinux.0,192.168.0.10
dhcp-option=3,192.168.0.1
dhcp-option=6,192.168.0.1

Run the dhcp server

sudo invoke-rc.d dnsmasq restart

Verify

Check if dnsmasq is listening on the bootps port 67:

sudo lsof -i :bootps

Also, remember to disable your firewall or allow port bootps.

dnsmasq also runs a dns server, which means you cannot be running another one for dnsmasq to start. To see that it is listening as a dns server:

sudo lsof -i :domain

Installing TFTP server

apt-get install atftp atftpd

The atftpd configuration (/etc/default/atftpd) by default uses the directory /var/lib/tftpboot. So, we create that directory:

sudo mkdir /var/lib/tftpboot
cd /var/lib/tftpboot

Put the netboot data in place.

sudo wget <<url for netboot.tar.gz>>
sudo tar zxf netboot.tar.gz
sudo chown -R nobody: .

Url for ubuntu and debian

disable inetd

Run tftpd as a daemon instead of from inetd:

sudo sed -e '/USE_INETD=/s/true/false/' -i /etc/default/atftpd
sudo invoke-rc.d inetd stop
sudo invoke-rc.d xinetd stop
sudo invoke-rc.d atftpd restart

verify

Check the it is running and bound to port 69 (tftp)

sudo lsof -i :tftp

Attempt to connect and get boot image:

cd /tmp
echo 'get pxelinux.0' | atftp localhost
ls -l pxelinux.0

This should display a ~14k pxelinux.0 file. Replace ‘localhost’ with whatever host your tftpd is running on.

Old way

Figure out the MAC address of the computer you want to boot (host). Usually, this can be discovered in the bios. It goes on the line “hardware ethernet MAC_ADDRESS”.

This assume that you have set up 192.168.0.1 as the network for DHCP and that 192.168.0.1 is configured as a nameserver and is set up with ipmasq. This is not required: any valid default route will work.

codetitle. /etc/dhcpd.conf:

option domain-name "riseup.net";
default-lease-time 600;
max-lease-time 7200;
allow booting;
allow bootp;

subnet 192.168.0.0 netmask 255.255.255.0 {
  range 192.168.0.50 192.168.0.100;
  filename "pxelinux.0";
  option subnet-mask 255.255.255.0;
  option broadcast-address 192.168.0.100;
  option routers 192.168.0.1;
  option domain-name-servers 192.168.0.1;

  host servername_to_boot {
    hardware ethernet 00:30:48:59:0B:C6;
    fixed-address 192.168.0.5;
    filename "pxelinux.0";
  }
}

Download netboot kernel

For links to download netboot.tar.gz:

  1. mkdir /tftpboot
  2. cd /tftpboot
  3. wget <>
  4. tar xvzf netboot.tar.gz

Install TFTPd

# apt-get install atftpd

You could run the TFTP daemon from inetd or as a background daemon, but since we probably just want to do this once, it is best to run it on the command line and make it spit the logging messages out to the console:

atftpd --daemon --no-fork --tftpd-timeout 300 --retry-timeout 5 --mcast-port 1758 --mcast-addr 239.239.239.0-255 --mcast-ttl 1 --maxthread 100 --verbose=7 --logfile /dev/stdout /tftpboot

Testing TFTP

# apt-get install atftp
> atftp localhost
tftp> get pxelinux.0