tftpd on FreeBSD 6.2

Prerequisites:

FreeBSD (Base + Autoconf, Automake, Bash and GCC)

Overview: Setting up a tftpd (Trivial File Transfer Protocol Daemon) server on FreeBSD means creating a directory for user files, editing the inetd.conf and starting inetd

tftpd – FreeBSD tftpd server for your network devices

# Download (Notes: Users behind a Proxy Server should read this and users without Internet but have a CDRom read this.)
# Edit inetd.conf
vi /etc/inetd.conf

# Uncomment the tftp line and set or edit the directory of your choice (-w means writable)
tftp dgram udp wait root /usr/libexec/tftpd tftpd -l -w -s /opt/tftp

# Create the directory as stated above
mkdir /opt/tftp

# Set the directory permissions
chmod a+r /opt/tftp
chmod a+w /opt/tftp

# Edit rc.conf
vi /etc/rc.conf

# Add a line to rc.conf
inetd_enable="YES"

# Start inetd
/usr/sbin/inetd

# Optional Testing
# Verify that inetd is running:
ps wwaux | grep inetd

# Local test
tftp 127.0.0.1
quit

 

tftpd patch for FreeBSD 6.2 to fix the "-w" write issue
(Without this patch, files need to be created in advance. This patch makes TFTPD work more like the Windows versions)

# Run sysinstall and get the source code for tftp, type:
sysinstall
# Navigate the menu system:
# sysinstall  --> Configure --> Distributions --> src
# From the src list select both:
# libexec
# ubin

# Install the source code (tab down and hit OK a few times)
# Exit sysinstall after the source files are downloaded

# Change to the tftp source directory
cd /usr/src/libexec/tftpd

# Download the patch file
fetch http://www.n3ncy.com/NMSWorld/UNIX/tftpdpatch.txt

# Convert the patch to UNIX (Remove the DOS ^M line breaks)
dos2unix tftpdpatch.txt

# Patch the tftpd.c file using the tftpdpatch.txt
patch tftpd.c tftpdpatch.txt

# Build and install the new binary
make install clean

# You may need to restart tftpd (or inetd) to take effect (next reboot will fix this too!)