Installing and setting TFTPD in Ubuntu

by David Sudjiman ~ March 27th, 2006. Filed under: Linux.

1. Install tftpd and related packages.

$ sudo apt-get install xinetd tftpd tftp

2. Create /etc/xinetd.d/tftp and put this entry:

service tftp
{
protocol        = udp
port            = 69
socket_type     = dgram
wait            = yes
user            = nobody
server          = /usr/sbin/in.tftpd
server_args     = /tftpboot
disable         = no
}

3. Make /tftpboot directory

$ sudo mkdir /tftpboot
$ sudo chmod -R 777 /tftpboot
$ sudo chown -R nobody /tftpboot

4. Start tftpd through xinetd

$ sudo /etc/init.d/xinetd start

5. Testing. Tranfering file hda.txt from 192.168.1.100 (Client using tftp) to 192.168.1.100 (Server 192.168.1.100). Get an example file to transfer (eg. hda.txt)

$ touch /tftpboot/hda.txt
$ chmod 777 /tftpboot/hda.txt
$ ls -l /tftpboot/
total 0
-rwxrwxrwx  1 davids davids 0 2006-03-27 23:04 hda.txt
$ tftp 192.168.1.100
tftp> put hda.txt
Sent 722 bytes in 0.0 seconds
tftp> quit
$ ls -l /tftpboot/
total 4
-rwxrwxrwx  1 davids davids 707 2006-03-27 23:07 hda.txt

41 Responses to Installing and setting TFTPD in Ubuntu

  1. stefan schwert

    Hallo David,
    thank you for the description. I found a lot of sites about netbooting, but setting up the tftp-server wasn’t clear to me until I found your page. Stefan

  2. kitten

    Very helpful; this was driving me insane because I needed to get it running for a work-related project. Thanks for the information.

  3. jlabrie

    It helped me too, thanks!!

  4. William Hile

    I have been attempting to get tftpd to run for a few days now and have still had zero luck…… for some reason it does not srart/listen on port 69…. or any port for that matter…. any ideas?

    Thanks

    William

  5. Sean Xie

    Thanks, my tftp server is working now.

  6. Celso Providelo

    Dude, thank you so much ! xinetd hint worked perfectly !

  7. Grant T

    Another success here. As mentioned, there are a lot of sites that describe setting up a TFTP to boot a PXE from, but nothing about setting up tftpd in Ubuntu. The only difference is after running through the steps I still could not connect to the TFTP server until I did /etc/init.d/xinetd restart.

  8. Dheep Vijay B

    Thanks David,

    I was cracking my head for two days to make the tftp server running in my system. your page helped me to start the tftp in 5mins. Thanks.

  9. Yatta

    Hey thanks for posting this… I was starting to pull out my non-existant hair on how to do this.
    All i keep seeing is how do a netwwork boot

  10. DoudZ

    Hello,

    you need -s before the tftp root directory making the server_args like:
    server_args = -s /tftpboot

    apart from that it works OK.

  11. Arthur

    Thanks David and DoudZ !!

  12. j mollo

    Thanks a lot, but when I finished this tutorial I had a very stupid “problem”: the whitespaces in the /etc/xinet.d/tftp file. I didn’t use them and they are mandatory….

    I hope this to be usefull for someone.

  13. Trilik

    I am new to linux and I found a thousand sites explaining to me how to setup a tftp server but none of them explained that I needed to install xinetd.d. Thank you very much this has to be the simplest and most informative how to site thank you.

  14. DL

    Indeed, I concur with everyone that this was:
    1. the most helpful
    2. the simplest

    information on installing tftp. I also tried using atftp(d), but this was the only success I had.

    Thanks, DS!

  15. Stefan Ludwig

    Thanks for this, it worked mostly.

    However, on Ubuntu 6.10, I had to change the user to root, as “nobody” is not associated with an existing group and that caused problems during the startup of xinetd.

    If you run into issues, it helps to check /var/log/syslog (or the equivalent for your Linux) to see those error messages. Yes, I’m pretty new to this, suffering from too many years of Windoze abuse, so bear with me.

    The easiest solution I came up with (maybe not the right one), was to change the user used by tftp to “root”. That worked.

    Here’s my /etc/xinet.d/tftp. “-c” allows it to create files in that directory

    service tftp
    {
    disable = no
    protocol = udp
    socket_type = dgram
    wait = yes
    user = root
    server = /usr/sbin/in.tftpd
    server_args = -u root -c -s /tftpboot
    }

  16. Nathan

    I’ve tried this on Fiesty Fawn, but “apt-get install xinetd” results in an error message which indicates that package xinetd is not available. Is there some new method?

  17. Dan Schmidt

    Here’s how I got it working in feisty.

    #1. Install tftpd with dependencies - no xinetd, I never could get it to work right.

    #2. Reboot. Tried everything to make it work without rebooting, I can’t seem to get it.

    #3. sudo mkdir /srv/tftp
    sudo chown -R nobody tftp

    /srv/tftp is your tftp directory. Works quite well now.

  18. sark

    nice , i tryd more sites but i can’t get this solution , thanx…

  19. Tim

    Thanks! I had real trouble with this until I found your page.

  20. Kaushik

    Very useful i run my tftp server in 1 minute. very clear instruction. Thanks :)

  21. Oscar

    Excelent. I’m new to linux, but moving really fast. Fortunately this was the first site I visited. I first did a
    “sudo apt-get install ftpd” but it told me the superserver was not found. Then I visited this site and got it working. Thanks. :)

  22. d2

    Thank you, hours with minicom and 10 mins with your instructions. thanks

  23. hakim tonkin

    hello, I have followed your tutorial, but when i do ” >put essai.txt” ihave this message “transfer timed out”.
    thinks

  24. David

    Note that this only worked for me when I made the lines between the { } braces tab-indented.

    service tftp
    {
    [tab]port = 69

    }

  25. RJ

    On Ubuntu 6.10 this isn’t working. Tried all the above suggestions but the transfers are timing out..

    Anyone found a solution to this?

  26. egophobiae

    work well indeed sofar.thanks
    ps:
    but one might need to change above ip-adress to your own i.e. 192.168.0.1 in my case.

  27. jonny

    Running ubuntu server 7.04–
    I have the tftp server working as specified, but file transfers ONLY work internally either on itself or within a local network.
    As soon as I attempt to transfer over the internet, i get
    “Transfer timed out.”
    or another error if i do not have -s in serverags.
    whats up?

  28. CodeWiZzard

    To run the deamon you have to enable this often default-disabled option in:

    /etc/default/tftpd-hpa

    RUN_DAEMON=”yes”

    to test if tftpd is running try:

    netstat -a | grep tftp

    the result shoud be:

    udp 0 0 *:tftp *:*

  29. CodeWiZzard

    TO THE MOD:

    sorry stupid me.. forgott half of it.

    Wanted to say using tftp-hda is a good alternative on debian/ubuntu

    install with

    aptitude install tftpd-hpa

    then configure it like above and start with

    /etc/init.d/tftpd-hda start

    sorry for scrambling it up, but i didnt have much time.. maybe you could sort it out or add it to your own howto

    thanks

  30. Jonny

    Hi CodeWiZzard-
    Thanks for your reply… I tried your method on 7.04 and then re-formatted and tried on 7.10 and still no luck. Still timing out.
    I am running out of ideas, and I definatly dont want to run CentOS or Windows just to serve tftp files…

    Any other thoughts?

    Thanks,

  31. kevink

    Thanks, this worked after I realized that I made the same mistake as j mollo (see above). I added tabs to the front of the lines in the /etc/xinetd.d/tftp file and then it worked. We also had problems with a tftp/UDP blocking rule on our corporate firewall/gateway.

  32. Seb

    Many thanks !!!

  33. Nato

    Nice work, thanks David and DoudZ !!

  34. Andrea

    Thanks David…I so simple after read your post…Bye From Italy

  35. Bill Zimmerly

    Great work David! Thank you for clear, easy to follow instructions.

  36. Amir

    Need help guys! I am using Ubuntu 7.10 and managed to set up the ftp as instructed. But when I try to to the step: tftp> put hda.txt

    I got a message that: tftp: No such file or directory

    Any idea where am I making mistake.

    Thanks

  37. Asif

    Amir you should have TFTP service files on you root partition after this you have to copy this file on /var/lib/tftpboot

  38. Daniel

    Great work David! Thank you for clear, easy to follow instructions.

  39. russi

    hey!!
    easiest tutorial I found on the net
    however tftp works only internally –I cannot boot a client –it simply says tftp open timeout!
    I have a multihomed network with subnets 192.168.40.0 and 10.10.1.0 and I can use tftp internelly on both

  40. Duna

    You helped me. Thanks a lot.

  41. Erdal Saglam

    Hi,

    Thanks David for the description.

    from Germany

Leave a Reply