Setting up a Linux DHCP and TFTP Server for Intrinsyc Cerfboards

Information compiled by Douglas Low, updated by Matt Cosand 12/01.

Introduction

The following guide assumes you have a Redhat distro, version 6.2 or later, and that you have root privilege. For Windows installations, talk to Adam MacBeth.

DHCP is Dynamic Host Configuration Protocol and for our purposes is used to supply an IP address to the CerfBoard.

TFTP is Trivial File Transfer Protocol, a non-error-checked file transfer protocol, with no login and password required. It is intended for booting clients from a network.

Your host Linux system will run these DHCP and TFTP daemons, which the CerfBoard will use.

Obtaining DHCP and TFTP daemons

These daemons are not usually installed by default on Linux systems, as they are really only useful for servers, not clients. If they are installed already, the binary files /usr/sbin/dhcpd and /usr/sbin/in.tftpd should exist.

You can find DHCP and TFTP as RPM (Redhat Package Manager) files on a Redhat mirror, a local (UW) one is ftp://redhat.cac.washington.edu. Some quick links are

for Redhat 7.0.

Installing DHCP and TFTP daemons

Once you have the appropriate RPM files, use the following command to install the daemons:
rpm -i <rpm file>

Obtaining MACs

A MAC is a hardware network address associated with an ethernet card. This is used by the DHCP daemon to allocate IP addresses to clients.

Connect your CerfBoard (Serial 3) to the serial port of a desktop computer running a terminal program. The Cerfboards should be running at 9600 or 38400 baud (both 8-n-1), and may switch between the two when it starts the Linux kernel. If your CerfBoard has a working Linux kernel, you should let it boot up, then log in and type
dmesg
There will be the MAC address amongst the rest of the information.

Otherwise you should press a key when you get the "Waiting for RTC..." message to get to the bootloader. Type
tftp foo
This will cause the CerfBoard to broadcast a DHCP request on the network. The server will not respond yet (because we have not configured it yet) but the status message printed will include the MAC address.

Setting up DHCP

Edit the file /etc/dhcpd.conf to contain the following:
deny unknown-clients;   # for security...

allow bootp;            # enable bootp

subnet 192.168.1.0 netmask 255.255.255.0 {
  option routers       192.168.1.100;   # also tftp/"bootp" server IP
  option subnet-mask   255.255.255.0;
}

group {
  next-server          192.168.1.100;   # tftp/"bootp" server IP

  host cerf1 { # hostname
    hardware           ethernet 00:D0:CA:F1:1F:22;  # client MAC address
    fixed-address      192.168.1.1;                # client IP
  }
  host cerf2 {
    hardware           ethernet 00:D0:CA:F1:47:23;
    fixed-address      192.168.1.2;
  }
}

The IP addresses 192.168.0.* are private and cannot be seen outside of your network (or switch, I believe, if you have one). Avoid using the addresses ending in .0 or .255, as they have special meanings - there may be others I do not know about.

You can use whatever host names you like for your clients, as long as the names are unique.

Before running the DHCP daemon for the first time, you will need to use the following command to create the leases file:
touch /var/state/dhcp/dhcpd.leases

It only has data written into it if you assign dynamic IPs to your CerfBoards but the file is needed regardless.

The DHCP daemon can be started with the following command:
/etc/rc.d/init.d/dhcpd start
stopped with:
/etc/rc.d/init.d/dhcpd stop
and stopped and started with:
/etc/rc.d/init.d/dhcpd restart

It is possible to place the start command in the appropriate runlevel script file but this generally isn't needed unless other people without root privilege will be booting CerfBoards from your host when you aren't around. The relevant files are in the directory /etc/rc.d.

Setting up TFTP

Find the line beginning with:
tftp dgram udp wait root
in the file /etc/inetd.conf and modify to look like:
tftp dgram udp wait root /usr/sbin/tcpd in.tftpd <tftp-root-dir>
<tftp-root-dir> is the directory where TFTP clients will obtain files from.

Send a SIGHUP to the inetd to get the TFTP daemon running.