Installing and Testing TFTP Server in Ubuntu/Debian


Installing and Testing TFTPD Server in Ubuntu

1. Install following 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. Create a folder /tftpboot  this should match whatever you gave in server_args. mostly it will be tftpboot
$ sudo mkdir /tftpboot
$ sudo chmod -R 777 /tftpboot
$ sudo chown -R nobody /tftpboot
4. Restart the xinetd service.
$ sudo /etc/init.d/xinetd stop
$ sudo /etc/init.d/xinetd start
Now our tftp server is up and running.

Testing our tftp server

5. Create a file named test with some content in /tftpboot path of the tftp server
$ ls / > /tftpboot/test
$ sudo chmod -R 777 /tftpboot
$ ls /tftpboot/test -lh
-rw-r--r-- 1 thalib thalib 159 2010-03-05 20:48 test
Obtain the ip address of the tftp server using ifconfig command, in this example we will consider the ip address as 192.168.1.2
6. Now in some other system follow the following steps.
$ tftp 192.168.1.2
tftp> get test
Sent 159 bytes in 0.0 seconds
tftp> quit
$ ls test -lh
-rw-r--r-- 1 thalib thalib 159 2010-03-05 20:48 test

Thats it. Our tftp server is working fine.

62 thoughts on “Installing and Testing TFTP Server in Ubuntu/Debian

  1. Hi,
    please help me in this
    in verify TFTP i am getting this issue
    bgl-ads-633:291> tftp 192.168.122.1
    tftp> get test
    Transfer timed out.

    tftp>

    If you need any logs pls ask

  2. To me (on Ubuntu 14.04 as server), it looks like the server connects to its directory /src/tftp. This is specified in /etc/inetd.conf. The information about /tftpboot in /etc/xinetd.d/tftp does not seem to be looked at.

  3. Loader:elf Filesys:tftp Dev:eth0 File:192.168.0.113: Options:(null)
    Could not load : File not found

    please help me to figure out my mistake

  4. Assalamualaikum..i am new with the tftp and i need to finish up this project by the end of this month..i really need someone to help me with this project.. i am using debian 6 for my project and the objective of this project is to send the filename string using the tftp..my problem is i dont know how to display the filename string at the client..someone please help me..thank you

  5. i configured tftp server in my ubuntu system but i cant transfer file to remote system eg: windows xp ; timeout error shows whenever i transfer file to remote system and at the same time i can get the file in remote system-winxp can anyone help me for this problem and post ur answer please…..

    1. tftp is not a secure protocol to transfer file, so most of the host will not allow receiving files over tftp. use ftp instead.

  6. Assalamualaikum.. I am new with tftp..I have set up tftp to transfer file between two linux (using debian) VMware, my laptop as a client and desktop as a server.my laptop is using Wifi,but my desktop is connected with cable
    I have installed tftp on both..
    but how to transfer files between them? i have done this on client side:

    ./atftp (server ip address)
    tftp > get (filename)

    timeout: retrying…
    timeout: retrying…
    timeout: retrying…
    timeout: retrying…
    timeout: retrying…

    for now, it works fine when i transfer file on local host..
    i hope someone can help me..
    Thank you.

  7. I set ->
    sudo mkdir /tftpboot
    sudo chown nobody.nogroup /tftpboot
    sudo chmod 777 /tftpboot

    sudo vi /etc/default/tftpd-hpa

    RUN_DAEMON=”yes”
    OPTIONS=”-l -s /tftpboot”

    sudo ifconfig eth0 192.168.1.1
    sudo tftp 192.168.1.1

    tftp> get test.txt
    Transfer time out.

    Please what am i missing?

  8. I have completed with Tftp server installation and configuration in my host ubuntu system. Its working fine. But when trying to test it from qemu . i cannot test it. help me to test wthether tftp server working from qemu

  9. why i try to update image over tftp, getting following error. what is the issue ?

    TFTP from server 192.168.1.3; our IP address is 192.168.1.1
    Filename ‘xxxxx.img’.
    Load address: 0x80800000
    Loading: T T T T T T T T T T T

    1. Looks like network issue. Some below if below things..
      1. You are setting the IP address of the target as 192.168.1.1, mostly it will be you routers IP (incase you have a router ) choose a IP that is not used by any device on you network
      2. Do a quick check if the server is reachable. Just od a ping to see if the host is reachable.

  10. I tried the steps mentioned, got it installed, but the problem arises in the testing part

    i execute the tftp connect command on the tftp server itself, just to be sure that am not being blocked by any firewall if i try to connect from other system.
    $ tftp 192.168.1.2
    tftp> get net.img
    After the above command, it doesn’t download anyting from the server and is just struck there

  11. Router#copy disk2:fromtftp.txt tftp:
    Address or name of remote host []? 10.10.10.10
    Destination filename [fromtftp.txt]?
    TFTP: error code 2 received – 16739

    %Error opening tftp://10.10.10.10/fromtftp.txt (Permission denied)

    How to resolve this!

    1. You should create the file prior to the transfer (with the command touch) and set its permissions to 666 (world writable). This is explained in the manpage of tftpd.

  12. When i’m trying to create file in that directory:
    :/etc/xinetd.d$ sudo cat > tftpd
    bash: tftpd: Permission denied

    i’m using Ubuntu 12.04, i tried this in windows style, both with failure, i am so frustrated ARGHH

    1. try this
      sudo cat >> /etc/xinetd.d/tftp << EOF
      service tftp
      {
      protocol = udp
      port = 69
      socket_type = dgram
      wait = yes
      user = nobody
      server = /usr/sbin/in.tftpd
      server_args = /tftpboot
      disable = no
      }
      EOF

      else manually edit the file using vim

  13. Hi can anyone help me setting up tftp file transfer between two linux PCs?

    Pls provide exact steps for the same.
    1.should the both systems be connected thro cables?
    2.how to install tftp client?
    3.how to transfer the files between them?

    1. You can use the above steps in the blog.
      1. In both PC’s execute all the above steps
      2. Then run to test tftp transfer between the PC’s only execute step 6, but use opposite PC’s IP here.

      Answer for your question.
      1.should the both systems be connected thro cables?
      As long as both the PC’s are in the same net work, or they are able to ping them each other then you can use tftp between them.
      You can also use WIFI.

      2.how to install tftp client?
      If you have folloed the instruction in this blog then you have installed the tftp client,
      where tftpd is server and tftp is client. Step 6 shows how to use tftp client

      3.how to transfer the files between them?
      Normally under all Linux OS due to security reason, You can get files from tftp server, but you can’t put.
      So consider using ftp for file transfer between PC’s

      All the best.

  14. hi all

    i tried the instruction…..also the chmod but it gives me this..

    sysadmin@sysadmin:/$ tftp 10.10.10.2
    tftp> get test
    tftp: test: Permission denied
    tftp> exit
    ?Invalid command
    tftp> quit
    sysadmin@sysadmin:/$ sudo chmod -R 777 /tftpboot
    sysadmin@sysadmin:/$ ls /tftpboot/test -lh
    -rwxrwxrwx 1 sysadmin sysadmin 132 2011-12-15 08:46 /tftpboot/test

    what’s wrong?

    thank you very much

    Marco

    1. The current directory where you are is not having write permission for your user. so change to some a directory where you have write permission eg. home path

      $ cd ~/

      Now test the tftp, it should work..

      All the best.

      1. you right………after the post i found the solution…..’cause it worked with ” sudo tftp ”
        thank you man….and sorry for time wasted

        😉

        c ya

      2. I have the same problem, when i switch to other folder i says
        Error code:1 File not found

        i followed the instructions here

    2. sudo chown -R nobody /tftpboot

      OUPUT: ls -la /
      drwxrwxrwx 2 nobody root 4096 Jul 24 10:36 tftpboot

  15. Thank you for a wonderful info. it worked first time. Wish you can do the same for dhcp-server program. I have tried to follow the instructions but got failure installing it. Also dhcp3-server file was missing.

  16. i am using “sudo apt-get install xinetd tftpd tftp” command nut i got
    E: Unable to locate package xinetd
    E: Unable to locate package tftpd
    E: Unable to locate package tftp

    I am using Ubuntu 11.04 Ver.
    Y? can any one help me?

    1. I am also using Ubuntu 11.04. where I can find the package’s using this command.

      $ apt-cache search xinetd
      update-inetd – inetd configuration file updater
      xinetd – replacement for inetd with many enhancements
      globus-gfork-progs – Globus Toolkit – GFork Programs
      rlinetd – gruesomely over-featured inetd replacement

      Try
      $ sudo apt-get update
      then install it again.

    2. Please make sure you set the nameservers in /etc/resolv.conf
      then ping google.com to see if you have connectivity to internet
      Then try the sudo apt-get install xinetd tftpd tftp
      Because, when you are trying to install apps using apt-get, it searches for the
      repositories online and has to resolve the domain names to reach upto them

  17. Thanks
    I have success follow instruction Installation

    but I try put file from other computer to tftp server got “Access Violation”

    how to set it for allowing upload file from outside tftpd server?

    1. I have missed some thing in the instruction use below step to solve the problem

      $sudo chmod 777 -R /tftpboot/

      Now it should work fine

Leave a reply to mohammadthalif Cancel reply