Tuxcoder Blog

A place for random code postings, tips, and how-tos for Linux.


Configure TFTPD Server in Ubuntu

written on Thursday, June 5, 2008

I recently needed a TFTP server in Ubuntu for PXE booting my MythTV system. Up until now I was using the built-in DnsMasq server, which was great. When I moved my DHCP service to my Linksys router I needed stand-alone TFTP service. Hopefully this step-by-step HowTo will help someone get up an running quickly.

  1. The first step is to install the TFTP client and server packages on your system. The client, tftp-hpa is not necessary, but helps to debug your system if anything goes wrong.

    sudo apt-get install tftp-hpa tftpd-hpa
    
  2. The default directory location to store your TFTP files is /var/lib/tftpboot. You can chose your own location if you don't want to use the default. For now, setup the directory permissions of the TFTP server root directory:

    sudo mkdir /var/lib/tftpboot
    sudo chown nobody.nogroup /var/lib/tftpboot
    sudo chmod 777 /var/lib/tftpboot
    
  3. Edit the TFTP server configuration file, /etc/default/tftpd-hpa, to put the service in daemon mode. Also, if you are using a custom TFTP directory, change /var/lib/tftpboot to the correct directory location.

    /etc/default/tftpd-hpa

    #Defaults for tftpd-hpa
    RUN_DAEMON="yes"
    OPTIONS="-l -s /var/lib/tftpboot"
    
  4. Start the TFTP init script.

    sudo /etc/init.d/tftpd-hpa start
    
  5. There should be an indication that the service started. Also, use netstat to check the port has been opened:

    netstat -a | grep tftp
    
  6. After adding a file the TFTP server directory, you should be able to access a file using the TFTP client. Assuming the file /var/lib/tftpboot/pxelinux.0 exists, try:

    tftp localhost -c get pxelinux.0
    

You will know that everyhing worked if the file pxelinux.0 now exists in your current directory.

This entry was tagged tftp, tftpd, tftpd-hpa and ubuntu



© Copyright Patrick C. McGinty 2011. All Rights Reserved.

powered by rstblog