What is Dynamips/GNS3? – An Introduction
Sep 03

Fully featured TFTP Server on Linux

As you all know, at least I suppose so if you’re reading this, a TFTP is is a very simple file transfer protocol, with the functionality of a very basic form of FTP and is mainly used when dealing with Cisco devices to backup/upload configuration to routers and when upgrading the IOS version.

A few nights ago, after all who needs to sleep?, I was putting some order on my Cisco Lab and noticed a few of my routers where running and outrageous old version of IOS so I started the upgrade process. I needed a TFTP server to upload the IOS to the routers so I simply downloaded the one available in the standard Fedora repositories and configured it and… crap it was not working! No matter what I did or tried it simply refused to work, I googled a little and found a few people had the same problem without a resolution but still I needed a TFTP on my machine and after a research on sourceforge I found a really powerful TFTP server which was working too!

Here we go, first of all you’ll need to downoad the TFTP software from here and untar it with tar zxvf  in dir of your choice, once done that you simply need to edit the tftpserver.ini file and then copy it in /etc/ with a cp tftpserver.ini /etc/, the README file contained in the archive is really complete and you should have no problems following it anyhow below you’ll find my .ini file with the configuration I’m using right now (you can simply copy and paste it) .

#IMPORTANT WARNING Never Edit this file usig Windows Editor

[LISTEN-ON]
#if you have more than one NIC card on your server
#can specify which cards/ports will listen TFTP requests
#default listening port is 69, but can be overridden here
#listening on ports less than 1024 needs root account
#upto 8 interfaces can be specified
#Default is All Interfaces
‘You can specify alternative ports as well
‘ 10.0.0.1 231

[HOME]
#You should specify home directory(s) here
#The home directory can be specified
#in two different ways, with alias or
#bare names without aliases. Using alias you
#can specify upto 8 directories like
#routers=c:/RouterImages/Images
#without alisas, only one directory can
#be specified, which will become root
#directory for tftp.
#the format is alias=directory
#mixup of bare names and aliases not allowed
/home/yourhomdir/tftp_home
‘routers=/home/knoppix
‘boot=/mnt/pc1/PXEBoot/Images
‘installs=/hda5/installs
‘j=/home/knoppix/tftpserver

[LOGGING]
#Logging is done in SYSLOG, if not overridden
#Logging will be done only if run as Service.
#default is None
#Logging "All" is resources intensive, should not be normally used.
‘None
‘Errors
‘All

[ALLOWED-CLIENTS]
#These are permitted clients for TFTP Access.
#Hosts having IP address within these ip ranges
#only will be responded to DNS requests.
#32 ranges can be specified.
#If none is specified, then all are allowed
‘192.168.0.1-192.168.0.254
‘10.0.0.1-10.255.255.254

[TFTP-OPTIONS]
#First is default timeout per interval
#if not overridden by client
#min is 1, max can be 255, default is 3
‘timeout=3

#Next is max block size, allowed
#on client request. Max is 65464
#if not overridden by client
#it is always 512
‘blksize=65464

#Next are the file operation permissions
#Clients can only read files if read is
#set to Y, default is Y
Read=Y
#Clients can only create new files if write is
#set to Y, default is N
Write=Y
#Clients can only overwrite existing files if
#overwrite is set to Y, default is N
‘Overwrite=N

Once you’ve configured all the parameters you can test youre configuration simply typying as root in your favourite shell :

tuxbox#./tftpserver -v

You should now see this :

Ready…

Now let’s test if our TFTP Server is working transferring some files, so open another shell and type :

$tftp (if tftp client is not installed you can install with yum -y install tftp)
tftp>connect localhost
tftp>get [some file name in home dir]
Received 13112 bytes in 0.0 seconds

on the "server" console you should see :

client 127.0.0.1:xxxxx file …… # blocks served

Congratulations you should now be able to run your TFTP Server!  On  a side note keep in mind you can start the server even as a daemon but personally I prefer to start it only when needed. If you want to configure the TFTP server as a system daemon all you need to do is to edit boot scripts in /etc/rc.d/rc.local or /etc/inittab files just pay attention not to put the -v switch in those files.

One Response to “Fully featured TFTP Server on Linux”

  1. %Error opening tftp://255.255.255.255/network config - How to solve it Says:

    [...] configuration files from a network TFTP server, I covered how to configure a TFTP under linux here [...]

Leave a Reply