3. Setting up DHCP and TFTP servers
A DHCP server is required to provide IP addresses for the clients when booting Grub (BOOTP) and later when booting Linux. A TFTP server is required to make the boot images available on the network for Linux to boot. The TFTP server is also necessary to make it possible to save and restore the disk images.
3.1. Setting up DHCP
Details on DHCP are beyond the scope of this article. The "Linux Networking HOWTO" has a chapter on DHCP.
Setting up DHCP is very easy, but if you are in a network environment administered by someone else, it's advisable to use a preexisting DHCP server. If you "own" the network then you can follow this procedure.
Install DHCP, if not installed, from the rpm package, normally found in Linux distributions:
# rpm -ihv dhcp-*.rpm |
Edit the /etc/dhcpd.conf file to configure DHCP service. In our setup, the server has IP address 10.0.0.1 and provides IP addresses up to 253 clients. Configure /etc/dhcpd.conf according to your environment:
#/etc/dhcpd.conf server-identifier dhcp.clonedomain.com; default-lease-time 172800; max-lease-time 604800; option domain-name "clonedomain.com"; subnet 10.0.0.0 netmask 255.255.255.0 { range dynamic-bootp 10.0.0.2 10.0.0.254; } |
Start the dhcpd server:
/etc/rc.d/init.d/dhcpd start.
3.2. Setting up TFTP
Setting up TFTP is almost as easy as DHCP.
First install from the rpm package:
# rpm -ihv tftp-server-*.rpm |
Create a directory for the files:
# mkdir /tftpboot # chown nobody:nobody /tftpboot |
The directory /tftpboot is owned by user nobody, because this is the default user id set up by tftpd to access the files.
Edit the file /etc/xinetd.d/tftp to look like the following:
service tftp { socket_type = dgram protocol = udp wait = yes user = root server = /usr/sbin/in.tftpd server_args = -c -s /tftpboot disable = no per_source = 11 cps = 100 2 } |
The changes from the default file are the parameter disable = no (to enable the service) and the server argument -c. This argument allows for the creation of files, which is necessary if you want to save boot or disk images. You may want to make TFTP read only in normal operation.
Then reload xinetd:
/etc/rc.d/init.d/xinetd reload
You can use the tftp command, available from the tftp (client) rpm package, to test the server. At the tftp prompt, you can issue the commands put and get.
3.3. Using different servers
It is possible to use different servers for DHCP and TFTP. This may be necessary if using a preexisting DHCP server. You can configure the next-server parameter in DHCP to point to the TFTP server or you can use the command tftpserver in Grub.