How to Setup TFTP on Ubuntu 11.10

Recently I decide to jump into the pool of using diskless Ubuntu. Basically the client computer downloads the necessary files from the Ubuntu server every time during the boot. To keep things simple and easy, Ubuntu does that by using TFTP. So the first step is to set up a TFTP server on the server. For those who haven’t heard of TFTP, it is similar to FTP, except that it has no security feature, and the function is extremely limited. Anyway, here is how to set up a TFTP server on Ubuntu 11.10:

Installing TFTP sounds easy. However, I’ve heard that many people experienced many issues during the installation, such as Error code 2: Access violation issue. That’s why I create this tutorial. If you follow exact the same steps, you will not experience any problem.

First, let’s install all the necessary packages:

sudo apt-get install xinetd tftpd tftp -y

Next, we need to create a configuration file:

sudo nano /etc/xinetd.d/tftp

Put the following content into the file.

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

In the server_args, I have var/lib/tftpboot, which represents the location of the tftp root, i.e., /var/lib/tftpboot. Notice that I skip the root /.

Now let’s change the ownership of the directory:

sudo mkdir /var/lib/tftpboot
sudo chown -R nobody:nobody /var/lib/tftpboot
sudo chmod -R 777 /var/lib/tftpboot

and start the TFTP service:

sudo service xinetd stop
sudo service xinetd start

Verify the TFTP is running correctly or not:

netstat -na | grep LIST | grep 69

You should see something like this:

tcp        0      0    *     LISTEN

Test: Upload a file to TFTP Server

Now let’s test the TFTP server by logging into the server first:

tftp localhost

and upload a file:

tftp> put myfile.jpg
Sent 56733279 bytes in 5.7 seconds



Make sure that file has been uploaded:

ls -l /var/lib/tftpboot

Test: Download a file from TFTP Server

Now, let’s go to a different directory and download the file we just upload.

cd some_other_directory

and log in to the tftp server again:

tftp localhost

and get the file:

tftp> get myfile.jpg
Received 56733279 bytes in 5.7 seconds

You are done.

Troubleshooting (e.g., Error code 2: Access violation)

If you see a message like: Error code 2: Access violation

Make sure that you:
– Follow the exact procedure in this tutorial
– Make sure that the tftp is started with -s flag.
– Check the permission of the directory, i.e., 777
– After you’ve made any changes to the TFTP configuration, make sure that you stop and start the inet service again.
– Don’t forget to quit tftp before retrying the command.

That’s it!

Enjoy TFTP.


Our sponsors:

20 Responses to “How to Setup TFTP on Ubuntu 11.10”

  1. This Howto helped me much, but I can’t get tftp working.
    Did you try “get myfile.jpg” after “put myfile.jpg”?
    I opened

    Please, can you give your opinion?

  2. Hi ego,

    If you see a message like: Error code 2: Access violation

    Make sure that you:
    – Check the permission of the directory, i.e., 777
    – Make sure that the tftp is started with -s flag.



  3. HI. Looked like this was going to be a good reference. I can’t make this work

    sudo chown -R nobody:nobody /var/lib/tftpboot
    sudo chmo7 -R 777 /var/lib/tftpboot

    Changed nobody:nobody to nobody:nogroup
    chmo7 to chown

    stopped and started.

    No joy. Access violation 2. The tftpboot looks like this
    drwxr-xr-x 2 777 nogroup

  4. I started the service but netstat -na | grep LIST | grep 22 doesnt give the expected output. How do I troubleshoot that please?

  5. Never mind, it works anyway… Thanks for this.

  6. change to:
    server_args = -s /var/lib/tftpboot

    not correct
    sudo chown -R nobody:nobody /var/lib/tftpboot
    sudo chmo7 -R 777 /var/lib/tftpboot

    sudo chown -R nobody:nogroup /var/lib/tftpboot
    sudo chown -R 777 /var/lib/tftpboot

    becouse it works on 69 port, so grep 69

    and when you put a file, it uploads with 600 permission, and when you tries to get file, you get access violation

  7. sorry
    >sudo chown -R 777 /var/lib/tftpboot

  8. Value too large for defined data type why? i try to put a 2 gb file.

  9. does anyone have a solution for “Permission denied” error while trying to get a file?

  10. blakdawg says:

    try “chmod -R 777” not “chown -R 777”; 777 are permissions, not a username.

  11. touch /var/lib/tftpboot/
    chmod 777 /var/lib/tftpboot/

    tftp localhost
    tftp> put

  12. if you “error 2”

    touch /var/lib/tftpboot/file_name
    chmod 777 /var/lib/tftpboot/file_name

    tftp localhost
    tftp> put file_name

  13. This was a fantastic post and it helped me immensely.
    I hope you don’t mind but I copied and pasted your post to my blog, but made sure to give you the credit. If you do not want me to keep your post there let me know and I will take it down and just keep the link back to your post.
    Thanks again for posting this great How-To.

  14. To check the service you should run this:
    netstat -anu | grep 69

    And the output should look like this:
    udp 0 0*

  15. Why are you looking looking to see if port 22 is listening? That’s the SSH port! Shouldn’t you be looking for port 69?

    Your config file is also missing the leading slash on ‘var/lib/tftpboot’, it should be ‘/var/lib/tftpboot’

  16. you put udp in the conf, and get tcp in netstat ?

  17. Yes, that is strange…i think it must look like this:

    # netstat -a | grep -i tftp
    udp 0 0 *:tftp *:*


  1. Setting TFTP Server in Linux Mint 12 | Ordinary Man - [...] How to Setup TFTP on Ubuntu 11.10 [...]

Leave a Reply

Your email address will not be published. Required fields are marked *