Installing and setting TFTPD in Ubuntu

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

179 thoughts on “Installing and setting TFTPD in Ubuntu

  1. helpdeskdan

    If you want to put, and the file doesn’t exist, you need the -c option, which doesn’t appear to be around in this version. Try tftpd-hpa and put a -c in your /etc/inetd.conf, like so:

    tftp dgram udp wait root /usr/sbin/in.tftpd /usr/sbin/in.tftpd -c -s /var/lib/tftpboot

  2. sobi

    the last post from Jeff works, but any suggestion to PUT file,
    which doesnt exist on server?

    helpdeskdans post doesnt work form me,

    1) i have installed and set up all by tutorial
    2) then installed tftpd-hpa tftpd-hpa
    3) added ‘- c’ to /etc/inetd.conf by helpdeskdan post
    4) sudo /etc/init.d/xinetd restart

    sobi@sobi-laptop:~$ ls -las | grep test
    4 -rw-r–r– 1 sobi sobi 14 2010-03-01 02:15 test.txt
    sobi@sobi-laptop:~$ tftp 192.168.1.153
    tftp> put test.txt

    and nothing happend…

    thanks

  3. vaibhav

    Hi,

    I followed the above steps, and I believe I have the tftp server running. However, when I execute the copy to tftp command from the cisco switch, it says that it is unable to open the destination file (permission denied). Any idea on what I am missing?

    Thanks!

    vkatkade@chikanwings:~$ cat /etc/xinetd.d/tftpd
    service tftp
    {
    protocol = udp
    port = 69
    socket_type = dgram
    wait = yes
    user = nobody
    server = /usr/sbin/in.tftpd
    server_args = /tftpboot
    disable = no
    }

    vkatkade@chikanwings:~$ ls -l | grep tftpboot
    drwxrwxrwx 2 nobody vkatkade 4096 2010-03-10 14:46 tftpboot

    vkatkade@chikanwings:~$ sudo /etc/init.d/xinetd restart
    * Stopping internet superserver xinetd [ OK ]
    * Starting internet superserver xinetd [ OK ]

    FROM SWITCH
    —————-

    4506-CSCte74800#ping vrf mgmtVrf 172.25.59.1

    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 172.25.59.1, timeout is 2 seconds:
    !!!!!
    Success rate is 100 percent (5/5), round-trip min/avg/max = 1/3/8 ms

    4506-CSCte74800#copy bootflash:CSCte74800.cfg tftp
    Address or name of remote host []? 172.25.59.1
    Destination filename [CSCte74800.cfg]?
    %Error opening tftp://172.25.59.1/CSCte74800.cfg (Permission denied)

  4. Michael

    Thank you for the post !!
    However ……
    It works as long at the image file is less than 32mb in size. Is there a fix for files greater than 32mb ?

    Mike

  5. Amr

    for the people getting time out
    disable the firewall, it should work.
    i spent a whole day on this.
    i’m new but i think configuring the firewall is better but this is as far as i know till now.
    by the way it’s a great post.
    thx

  6. NewtownGal

    I am confused and nothing works !

    I’m running Ubuntu 8.04.1 Server. I want to use tftd as a daemon on one machine to receive files, and tftd on lots of other machines to send it files. This is not for booting, just for moving little files around.

    I used apt-get install tftpd, but not a single configuration file was created. I manually made a file as per the instructions at the top of this page, but I get a failure when I try to start tftp.

    There are changes to changes to changes described above. Can someone tell me what to do to make it work on Hardy ?

    Also, why does it use UDP not TCP if I want the files sent correctly over a wide area network ?

    Thank you.

  7. Mike Shafer

    Thanks for the excellent / detail instructions. It was a snap to setup tftp and get it running.

    I have to reset a password on a Pix firewall tomorrow morning and like to keep my laptop running Linux when connected to client networks. Getting tftp up and running was the missing piece. Just tested the reset procedure on my Pix 515e using this and GtkTerm. Nothing to it. The whole reset didn’t take two minutes.

    Cheers!

  8. Ladre Walgas

    Hi,

    # cat tftp

    user = nobody

    I get the mistake:

    # tftp -p -l hallo.html 141.99.22.15
    tftp: server error: (0) Permission denied

    any ideas? Thanks

  9. Nikos

    hello,
    I use ubuntu 10.04 LTS and I am trying to set the TFTP.
    I follow the instuctions, but when I issue “put hda.txt” i get the following :

    nikos@nikos-laptop:~$ tftp 192.168.1.100
    tftp> put hda.txt
    tftp: hda.txt: No such file or directory

    Can anyone suggest me any solution?

    Thanks in advance,
    Nikos

  10. Herman

    Hi,
    after downloading the latest version Ubunto, did the sw upgrade. I installed the xinetd as above, to set up a tftp server. Installations is fine. In the process list xinetd is working. Following the instructions above, added the tftpboot folder, changed the access settings of the folder and files, changed the tftp (config) file, as above. Looking in the system log the xinetd runs with one service( only tftp) defined in the tftp. Added in the hosts.allow “All” entry to make sure. No ufw on. Additionally I installed dhcp3(preparing a pxe server). Dhcp is working fine. Unfortunately tftp client(either locally or remote) always brings “open timeout” or timeout on a put or get function or on a pxe tftp load. Has anybody still an idea? I spend 3 weeks now finding a solution, without any result, installed 4 times and still no result. Inetd can be started and stopped without problems, but timeout exists.Ftp is working fine, but this does not use the xinetd.
    In response to Nikos, this looks like you are trying to send a file from the home directory and the file does not exist in that directory.

  11. Pingback: TFTP server question

  12. Pingback: Karl Nordstrom» Blog Archive » Setting up a TFTP server in Ubuntu

  13. Hans

    Thanks a lot, it helped me to setup my tftp server.
    I still have a question about the privillege of upload files. In my case, the file is always like:
    -rw——- 1 user1 user1 203353 2010-06-22 12:10 /usr/tftpboot/abc2.conf
    Then, if I try to upload another file but with same name(i just want to overwrite the old file), It get rejected.
    My question is : Can I make the default privillege for tftp upload files to be like:

    -rwxrwxrwx 1 nobody user1 ?

    Thanks a lot.

  14. Paul Margetts

    4 years after your original post, and this still seems the best place to get tftp installation instructions! I have successfully got tftp going on my Ubuntu 10.04 (running under VMware). I am new to Linux, but only problems I ran into which weren’t covered in your original post were:

    1) I initially missed the white space in the /etc/xinetd.d/tftp file (it doesn’t show up in my browser, so I didn’t know until I read the other posts).

    2) I had to use “sudo /etc/init.d/xinetd restart” rather than “sudo /etc/init.d/xinetd start” because it seems that my Ubuntu installation automatically starts xinetd.

    3) I had to use “Edit -> Virtual Network Editor…” to map port 69 across from my PC to Ubuntu because I am using NAT for my virtual machine.

    Great work, and thanks!

  15. Pingback: Net booting a Sun sparc with RARP and TFTP

  16. Lindelani

    im currently running Suse Linux enterprise 11 and im looking for the commands to run when my clients machine are not booting,error message tftp no such file or directory.Can you please help.

  17. Chechu

    Thank you very much!

    Just want to say that I needed to open 69 port on iptables with:

    iptables -A INPUT -p udp eth0 –dport 69 -j ACCEPT
    iptables -A INPUT -p tcp eth0 –dport 69 -j ACCEPT

    (if you are using eth0 device, you can check with: ifconfig -a)
    Then it worked!

  18. khalid

    I’m having issue with tftp server, i tried different set up but no luck
    ubuntu server 10.04 (Tftpd) 192.168.1.3
    centos client 5.4 192.168.1.4

    here my is configuration

    protocol =udp
    port =69
    socket_type =dgram
    wait =yes
    user =nobody
    server =/usr/sbin/in.tftpd
    server_args = -s/tftp
    disable =no
    #per_source = 11
    #cps = 100 2

    #Defaults for tftpd-hpa
    RUN_DAEMON=”yes”
    OPTIONS=”-c -l -s /tftp”

    [abdi@dhcppc2 ~]$ tftp -v 192.168.1.3 -c put hello
    Connected to 192.168.1.3 (192.168.1.3), port 69
    putting hello to 192.168.1.3:hello [netascii]
    Transfer timed out.
    [abdi@dhcppc2 ~]$

    * xinetd is running
    tftpd-hpa start/running

    ping is succesful

    ping 192.168.1.3
    PING 192.168.1.3 (192.168.1.3) 56(84) bytes of data.
    64 bytes from 192.168.1.3: icmp_seq=1 ttl=64 time=1.07 ms
    64 bytes from 192.168.1.3: icmp_seq=2 ttl=64 time=1.20 ms
    64 bytes from 192.168.1.3: icmp_seq=3 ttl=64 time=1.39 ms

    other services are running without issue

    looking forward to ur reply

  19. Pingback: Troubleshooting QNAP Debian NAS box by setting up DHCP and TFTP servers in Ubuntu at Black God

  20. khalid

    # khalid Your comment is awaiting moderation.
    October 6th, 2010 at 5:45 am

    I’m having issue with tftp server, i tried different set up but no luck
    ubuntu server 10.04 (Tftpd) 192.168.1.3
    centos client 5.4 192.168.1.4

    here my is configuration

    protocol =udp
    port =69
    socket_type =dgram
    wait =yes
    user =nobody
    server =/usr/sbin/in.tftpd
    server_args = -s/tftp
    disable =no
    #per_source = 11
    #cps = 100 2

    #Defaults for tftpd-hpa
    RUN_DAEMON=”yes”
    OPTIONS=”-c -l -s /tftp”

    [abdi@dhcppc2 ~]$ tftp -v 192.168.1.3 -c put hello
    Connected to 192.168.1.3 (192.168.1.3), port 69
    putting hello to 192.168.1.3:hello [netascii]
    Transfer timed out.
    [abdi@dhcppc2 ~]$

    * xinetd is running
    tftpd-hpa start/running

    ping is succesful

    ping 192.168.1.3
    PING 192.168.1.3 (192.168.1.3) 56(84) bytes of data.
    64 bytes from 192.168.1.3: icmp_seq=1 ttl=64 time=1.07 ms
    64 bytes from 192.168.1.3: icmp_seq=2 ttl=64 time=1.20 ms
    64 bytes from 192.168.1.3: icmp_seq=3 ttl=64 time=1.39 ms

    other services are running without issue

    looking forward to ur reply

  21. Anna Patil

    thanks.. but not able to copy config files..

    used below method… but gettng

    Destination filename [pu-shi-par-r1-as01-bs02-confg]?
    TFTP: error code 2 received – Access violation

    %Error opening tftp://172.31.6.221/pu-shi-par-r1-as01-bs02-confg (Permission denied)

    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

  22. Pingback: Drija » Archive » tftp server in ubuntu 9.04 not working ( transer timeout on GET and PUT)

  23. tu

    I also got a permission denied problem when trying to copy cisco image to /tftpboot. After hours pulling my hair, I finally got it working:

    1. Go to Synaptic Package Manager (Ubuntu)
    2. Search for atftp
    3. uncheck (uninstall) tftpd and check atftpd and atftp
    4. then click on Apply button to install

    Now I am able to copy cisco ios image to /tftpboot

  24. hema prathyusha

    Hi,

    I followed the above procedure to setup tftp in ubuntu 9.04.
    But when i tried transferring hda.txt file its giving below error.
    root@administrator-desktop:/# tftp 10.203.244.102
    tftp> put hda.txt
    tftp: hda.txt: No such file or directory
    tftp>
    My ip address is 10.203.244.102.

    If any one has suggestions to resolve above issue please let me know.

    Thanks.
    Hema

  25. Pingback: Extra Geek Points Today: Ubuntu running on Soekris | Paper Jammed

  26. sakthivel

    I tried the above steps. everything looks fine. But netstat -a | grep tftp gives nothing. port 69 not listenting. please how to solve this issue

  27. Pravinkumar Chavan

    Hi All,
    I m ubuntu 10.10 user
    As suggested above I have did the things and everything is working till
    $ tftp [..ip addr…] step
    but when I want to put the file giving me error
    root@pravin-P5GZ-MX:/# tftp 192.168.2.146
    tftp> put man.srec
    tftp: man.srec: No such file or directory

    i want ti boot my device with image man.srec about 18MB in size. and device ip ia 192.168.10.2

    As per the discussion i change
    user = nobody to root
    and
    server_args = /tftpboot to -s /var/lib/tftpboot

    tabs are properly placed in the /etc/xinetd.d/tftp file, I will see mesages in /var/log/syslog like the following:
    xinetd[6665]: xinetd Version 2.3.14 started with libwrap loadavg options compiled in.
    xinetd[6665]: Started working: 1 available service

    I have also installed tftp-hpa
    and have change file under /etc/default/tftp-hpa
    ##Default for tftpd-hpa
    {
    RUN_DAEMON=”yes”
    OPTIONS=”-c -s -l /tftpboot”
    }

    to test if tftpd is running try:
    tftp> netstart -a | grep tftp
    ?Invalid command

    Please help me…….

  28. Angel_Assassin

    root@swdesign4:/home/renatski_gutchi/Desktop/tftpboot# tftp 192.168.1.100
    tftp> status
    Connected to 192.168.1.100.
    Mode: netascii Verbose: off Tracing: off
    Rexmt-interval: 5 seconds, Max-timeout: 25 seconds
    tftp> trace
    Packet tracing on.
    tftp> put hda.txt
    sent WRQ
    sent WRQ
    sent WRQ
    sent WRQ
    sent WRQ
    Transfer timed out.

    tftp>quit <<<<——- why mine is something like this??.. Please help… Best Regards!.

  29. Pingback: 在Ubuntu上建立tftp服务器 ( Set up tftp server on Ubuntu ) | Lesca is thinking…

  30. Shira

    I defined everything- and started the tftp server- and it said [ok]- but it is not working- when i look at my opened ports i don’t have port 69 tftp- what can i do/??????????????

  31. meltunali

    on ubuntu 10.04, install tftpd-hpa, on get file i have error tranfer timed out, i solved it by installing and running openbsd-inetd

  32. meltunali

    on ubuntu 10.04, install tftpd-hpa, on get file i have error “transfer timed out”, i solved it by installing and running openbsd-inetd

  33. anonymous

    @sakthivel @shira xinet.d doesn’t bind anything to ports unless they are active. The whole point of the system is to dynamically allocate resources as needed. It will watch the ports but not bind to them. When it detects a connection on the resource it will spin up the appropriate daemon thread to answer the request. This was done to limit the consumption of resources on a server. In the old days you used to have to run an FTP daemon individually for each connecting process even if no one was connected. XInet.d resolved this but it can be a bit daunting to trouble shoot with traditional port methods.

    That being said, most of the daemons that it runs can be manually instantiated in the foreground as a debug mode…depends on the process.

Leave a Reply