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:


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



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

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

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

  5. if you “error 2”

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

    tftp localhost
    tftp> put file_name

  6. 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’

Leave a Reply to blakdawg Cancel reply

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