Wednesday, May 7, 2014

TFTP Server on Fedora Linux

For some odd reason, Fedora 20 still ships with a prehistoric and dysfunctional TFTP server, which requires the deprecated xinetd service.  Installing that is only good if you want a broken system that won't boot...

You can get a proper TFTP server here:
http://freecode.com/projects/tftp-hpa

Download tftp-hpa

Make a directory to work in  called sw:
$ cd
$ mkdir sw
$ cd sw

Get the file:
$ wget https://www.kernel.org/pub/software/network/tftp/tftp-hpa/tftp-hpa-5.2.tar.xz

Untar it:
# xzcat tftp-hpa-5.2.tar.xz > tftp-hpa-5.2.tar
# tar -xvf tftp-hpa-5.2.tar

(or simply tar -xJvf  tftp-hpa-5.2.tar.xz, if your copy of tar supports it)

Install the software development tools

First do an update:
# yum update -y
Install the software development tools: 
# yum install kernel-headers -y
# yum groupinstall "Development Tools" "Development Libraries" -y

You may also want to install the RPM tools, while you are at it:
# yum install rpm-build gvim -y

Apper Update Service Locking Yum

BTW, if you are running F20 KDE, then you will run into an annoyance with the software update processes incessantly checking for updates, thus keeping yum locked.  The overall best solution is to  uninstall apper completely and install yumextender instead:
# yum remove apper -y
# yum install yumext -y

Compile

The usual drill:
$ cd tftp[tab]
$ ./configure
$ make
$ make check

$ su
password
# make install

Configure

Make a directory for the load files:
# mkdir /tftpboot

Upload your software image files and note that all files must be marked READ ONLY, otherwise TFTP will not work!

# chmod 444 /tftpboot/*
# chown nobody: /tftpboot/*

You may want to put that in the TFTP server start up script, just to make sure it will actually work.

Start the TFTP Server to test it:
# /usr/sbin/in.tftpd -ls /tftpboot

You can put the above in a script in /usr/local/bin.

Test it with a TFTP client and try to get a file:
# touch /tftpboot/testfile 
# chmod 444  /tftpboot/testfile
# exit
$ tftp localhost -c get testfile

My TFTP launch script:
#! /bin/bash
/usr/sbin/iptables -F
chmod 444 /tftpboot/*
chown nobody: /tftpboot/* 
/usr/bin/killall in.tftpd
/usr/sbin/in.tftpd -ls /tftpboot

La voila!

No comments:

Post a Comment

On topic comments are welcome. Junk will be deleted.