Setting up a TFTP server on Linux

Setting up a TFTP server on Linux

When I am talking to people about updating Cisco devices using TFTP I often get asked about setting up a TFTP Server on a linux machine. While this can change depending on the Linux distro you are running, the steps below should be close for all of them. I am basing this on RedHat Enterprise and Centos distros. Also follow these steps at your own risk. If you are not comfortable performing any of these steps get someone that is or ask.

First thinks first, you will need to see if you have the tftp-server installed. Open up a shell and type:
rpm -qa tftp-server

If the TFTP server is installed then you will see something like
#rpm -qa tftp-server
tftp-server-0.42-3.1.el5.centos

If you do not see the tftp-server installed you can use apt, yum, or smart to easily do this for you. Example:
yum install tftp-server

Once you have the server installed there are a few things that must be done before everything is running correctly. The tftp service is part of xinetd and must be enabled.

Edit the /etc/xinetd.d/tftp file and change the following:
disable = no
server_args = -c -s /tftpboot

First we change the disable from yes to no. This will allow the tftp server to start with the xinetd service is started.
Second we change the server_args and add the -c option. This option allows you to upload files to the tftp server without them first existing. If you do not do this you will get an error something like:

%Error opening tftp://1.1.1.1/c7200-ipbasek9-mz.124-24.T.bin (No such file or directory)

Once you have the changes in the /etc/xinetd.d/tftp, save the file and restart xinetd:

/etc/init.d/xinetd restart

Now you should be good to go. Files will be saved into the directory that you specify at the end of the server_args line in the tftp configuration file. If you have trouble uploading files and get a permissions error, make sure the directory is writable.

Like it? Share it!:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Twitter
  • Yahoo! Buzz
  • LinkedIn

About the Author

MattsShack MattsShack: Follow Us on Twitter at: MattsShack