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.

About these ads
Posted in Software. Tags: , . 36 Comments »

36 Responses to “Installing and Testing TFTP Server in Ubuntu/Debian”

  1. ponmudi Says:

    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…..

    • mohammadthalif Says:

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

  2. nabila Says:

    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.

  3. E Headhunter Says:

    Thank you very much this is the guide I needed, simpel and working

  4. gulfamwani Says:

    Thank you Thalib,
    Alhumdulillah,,,,,,It works fine,,,really helpfull.

  5. gulfamwani Says:

    Thank you Thalib,
    It was really helpfull..

  6. Dhruv Says:

    anyways done.. was doing silly mistake .

  7. Dhruv Says:

    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. sdivya Says:

    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. Ramesh Says:

    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: 0×80800000
    Loading: T T T T T T T T T T T

    • mohammadthalif Says:

      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. UnhappyGhost Says:

    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. Sanju Says:

    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!

    • UnhappyGhost Says:

      Thanks for the reply, i figured it out and its already working ;) I missed a step in the above config :D

    • lkuty Says:

      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. gruberator Says:

    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

    • mohammadthalif Says:

      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. shushma Says:

    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?

    • mohammadthalif Says:

      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. Marco Says:

    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

    • mohammadthalif Says:

      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.

      • Marco Says:

        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

  15. Joni Zhao Says:

    I like this web site very much so much great information.

  16. abbasd Says:

    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.

  17. Blake Peccia Says:

    Appreciate it for all your efforts that you have put in this. very interesting info . “Never trust the advice of a man in difficulties.” by Aesop.

  18. Ramesh Says:

    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?

    • mohammadthalif Says:

      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.

    • UnhappyGhost Says:

      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

  19. Alex Says:

    Great. Simple and very clear. Congratulations.

  20. 2010 in review of my blog « Mohamed Thalib's Blog Says:

    [...] Installing and Testing TFTP Server in Ubuntu/Debian March 2010 4 comments 4 [...]

  21. Budi Wahyudi Says:

    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?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 30 other followers

%d bloggers like this: