This post is an extension of my original post on TFTP: How to Setup TFTP. Although the post was written for Ubuntu, the same idea can be applied to all systems.
So, here is our problem. You set up a TFTP server. It starts fine. You upload a file, it gives no error. Now, you try to download a file, it throws you an error:
tftp> get myfile.jpg Error code 2: Access violation
If you google the error message, Error code 2: Access violation on the web, you’ve probably noticed many solutions, some of them are very creative, such as running a touch command to create the file before downloading it etc. Before you try those solutions, ask yourself this question first: Do you want to touch 100 files before you download 100 files?
Anyway. I am not sure what cause the TFTP gives the error message: Error code 2: Access violation. However I never experienced this error in my system before with my configurations and settings. Therefore, I am going to share you my configurations for your reference.
My TFTP Configuration:
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 }
There are couple things you need to pay attention. First, my TFTP root directory is /var/lib/tftpboot, and in my configuration file, I skip the first /. Second, I put a flag, -s in the server_args. That helps to keep TFTP from complain.
Next, the permission of the TFTP root directory plays an important role. Make sure that the permission and ownership are set correctly.
sudo chown -R nobody:nobody /var/lib/tftpboot sudo chmo7 -R 777 /var/lib/tftpboot
Now, you can simply restart the system:
sudo service xinetd stop sudo service xinetd start
and try to put a file and download it back:
tftp localhost tftp> put myfile.jpg Sent 56733279 bytes in 5.7 seconds tftp> get myfile.jpg Received 56733279 bytes in 5.7 seconds
That’s it.
Happy TFTP.
–Derrick
Our sponsors: