The below steps will allow you to set up a TFTP server on Linux but specifically on a CentOS server. All you need to do is install a couple files with yum, enable the server, and restart xinetd.

  1. Install TFTP Server: Use the below syntax to install the TFTP server on CentOS.
  2. [root@centos-server ~]#yum install tftp-server
    

  3. Install Xinetd: The TFTP server will run via xinetd so you need to make sure xinetd is installed using the bellow command.
  4. [root@centos-server ~]#yum install xinetd
    
  5. Enable TFTP and Xinetd: Use chkconfig to ensure that xinetd and tftp starts on reboot.
  6. [root@centos-server ~]#chkconfig tftp on
    [root@centos-server ~]#chkconfig xinetd on
    
  7. Modify TFTPBOOT Permissions: Use the below syntax to modify the permissions of the /tftpboot directory to allow tftp transfers to and from this directory. The /tftpboot directory is the default directory where files are transfered to and from using TFTP.
  8. [root@centos-server ~]#chmod 777 /tftpboot
    
  9. Example TFTP Command: The below is an example of use of the TFTP command.
  10. [root@centos-server ~]#tftp -v 192.168.1.100 -c put file-example.txt
    

    The normal computer user is probably not going to find TFTP very useful but techies will be able to find many uses. Typically technical people will run across TFTP when upgrading the firmware on some sort of network device. Please post comments if you have any TFTP questions.
     


List Price: $39.99 USD
New From: $20.94 USD In Stock
Used from: $0.46 USD In Stock

DeliciousStumbleUponDiggTwitterFacebookRedditLinkedInEmail
Tags: , , , , , , ,
38 Responses to “Linux: Setup TFTP Server on CentOS”
  1. Gavin says:

    Thanks,

    I love doing quick Google searches for tasks I don’t do often (like setup tftp server under CentOS!!). Good work!

    [Reply]

    alex Reply:

    Thanks! Glad to be able to help.

    [Reply]

  2. Vladimir says:

    Alex,

    Thank you very much for sharing.

    Everything worked perfectly.

    [Reply]

    alex Reply:

    Hello Vladimir,

    No problem. Glad it helped out. Thanks for taking the time to leave feedback.

    Thanks.
    alex

    [Reply]

  3. Robert says:

    one problem for me : an error message : transfer time out

    [Reply]

    alex Reply:

    Hello Robert,

    Thats like saying one problem for me… I try to start my car and it won’t… tell me how to fix it.

    There are so many variables that it could be many different items. If you want the possibility of getting resolution to your TFTP problem then list as many specifics as you can. How have you set things up? What specifically are you doing (step by step with commands included) to receive that error?

    If you provide more details I will do my best to help you out.

    Thanks.
    alex

    [Reply]

  4. AW says:

    I also have gotten the same error as Robert.

    Basically, I followed the setup above on a CentOS box. Then when I run my tftp client (even using the command you give above in the final step) to connect to the CentOS box that I installed the server on (via your directions), I get the transfer timeout message.

    I have ensured that the firewall is allowing port 69 connections, and even disabled the firewall all together. No love.

    Any ideas?

    [Reply]

    alex Reply:

    Hello AW,

    Jim has some great tips in the below comments. Hope it helps.

    Thanks.
    alex

    [Reply]

  5. Jim says:

    Most likely you have to edit your iptables or use the customize function in system-config-securitylevel to allow tftp through the firewall.

    [Reply]

    Jim Reply:

    Err – that might have been of use to Robert (or a future note for myself when I search for this). For AW, you should try tail -f /var/log/messages when you try tftping to your server to see what happens. If nothing, try putting tftp client like atftp on your box and try to connect to localhost and upload/download something. If that doesn’t work, your tftp server is screwed; if it does work, it’s either firewall (which you said you disabled) or the client.

    [Reply]

    alex Reply:

    Hello Jim,

    Thanks for adding the extra info Jim! We always appreciate anyone helping others out or providing different ways to troubleshoot.

    Thanks.
    alex

    [Reply]

  6. afed says:

    You never chmod 777 anything. Idiot.

    [Reply]

    alex Reply:

    Hello afed,

    I love when people make statements like the above but don’t offer a different solution. Have you ever used TFTP? If so please let me know of a different configuration that works properly.

    Thanks.
    alex

    [Reply]

  7. Shane says:

    Alex,
    I assume afed was distressed that permissions on the tftpboot directory/files should be more like 755- with 777 one will allow global permission to write (think erase or modify) the files in tftpboot. That combined with the lack of access control in tftp daemon itself leaves your system vulnerable to exploitation, or vandalism. Not generally a good idea on a network that is not highly secure.

    Regards,

    Shane

    [Reply]

    alex Reply:

    Hello Shane,

    Fair enough. I personally don’t use TFTP outside of my private network but I do understand the concern and agree that if you have a public facing network. I assume if the files are owned by tftpboot things will work properly, allowing not only read but also write (if you need that capability), with permissions of 755?

    Thanks for the actual feedback as it is always appreciated to not only see others real opinions but also expand my knowledge of specific subjects.

    Thanks.
    alex

    [Reply]

  8. Shane says:

    HI Alex,
    The permissions go from OWNER to GROUP to EVERYONE. I recommended a 755, which means the OWNER of the file (in this case ROOT) should have Read, Write and eXecute permissions, while the GROUP ROOT will have Read and eXecute permissions, and GLOBAL is allowed Read and eXecute permissions. I suppose the main thing here is one would not want Joe Public being able to gain access to the file to modify it in some way (whether by accident or malice), or delete it- write privilege allows deletion, as well.

    That being said, I agree with you one would not want to put a tftp server at the edge of one’s network where Internet users as a whole have access to it.

    I also agree with you that one would want to make a specific user that is NOT root to control tftpboot acccess to the subdirectory (all OWNERSHIP an GROUPS should be moved to tftpboot user and group, as well). MUCH more secure than with root privileges. I’m going to have to make a new PBX server tonight, and I will pay particular attention to this aspect of the configuration. THANKS for jogging my memory!!! Your comments are very timely!!

    Thank you for going to the trouble of writing the piece, and responding to my questions/comments.

    Regards,

    Shane

    [Reply]

    alex Reply:

    Hello Shane,

    Thanks for the quick response. I definitely understand permissions, etc. but the explanation is great. The reason for 777 on /tftpboot in the initial article was for multiple reasons. One as we have discussed the setup as it relates to the article was on a completely private/secure network where 100′s of devices I managed were pulling new firmware, etc. The devices were provisioned before even being connected to the Internet in this manner. What I am curious about though is if I recall correctly the tftpboot directory has to be read/write/world to function properly because of the nature of TFTP however this is where I could be wrong since I it has been awhile and the fact that security wasn’t even on my mind at the time of configuration. It was one of those get it up and operational and worry about the details later if time permits…. Anyway I would be curious to hear if you actually have a tftp server operational that can also write configuration files back to the TFTP server that is not readable/writeable by everyone accessing it.

    PS: Good luck with the PBX. I come from telco myself but its been a couple years since I have messed with much outside of 2811′s and Asterisk.

    Thanks!
    alex

    [Reply]

  9. Kevin says:

    In current versions you need to add “-c” to the server_args in /etc/xinetd.d/tftp to allow devices to create files on the tftp server (copy configs from routers, etc) otherwise you get “Error code 1: File not found”.

    As far as the permissions go the current implementation of tftp writes the files as the user nobody (even though xinetd runs it as root – this can be changed in server_args as well – man in.tftpd), so instead of chmod 777 /tftpboot, you should keep the permissions at 755, but run “chown nobody:nobody /tftpboot”

    My $.02

    [Reply]

    alex Reply:

    Hello Kevin,

    Thanks for the follow up! Been awhile since I wrote the article and since I have even used TFTP so the updated detailed info is definitely appreciated!

    Thanks.
    alex

    [Reply]

  10. manoranjan says:

    thanks u sir

    [Reply]

    alex Reply:

    Hello manoranjan,

    No problem. Thanks for taking the time to leave feedback.

    Thanks.
    alex

    [Reply]

  11. Wilson says:

    It works perfectly.
    Thanks Alex

    [Reply]

    alex Reply:

    Hello Wilson,

    No problem. Thanks for taking the time to leave feedback.

    Thanks.
    alex

    [Reply]

  12. alex2 says:

    Thanks! very helpfull

    I got a question, i can’t find a file name tftp in /etc/xinetd.d/

    i need to add some lines on xinetd.d for tftp… i am following a manual about asterisk… ag! do you know if the file changes because of the version?

    Again thanks

    [Reply]

    alex Reply:

    Hello alex2,

    It sounds as is you just have not installed TFTP. You might try installing something like atftp via your favorite package manager.

    Thanks.
    alex

    [Reply]

  13. alex2 says:

    Thanks for the feedback! but no, there are no files. I tried installing the TFTP.

    I will have to keep trying :)

    again, thanks

    [Reply]

    alex Reply:

    Hello alex2,

    No problem. Good luck.

    Thanks.
    alex

    [Reply]

  14. kingsley says:

    hi alex, thanks for this and it was pretty straightforward… i’m trying to make my ip phones (cisco) pick up settings from the tftp server i just created. i think i need to put the settings in the tftpboot directory but i don’t know where to find this and i’m not sure of what settings to put in this directory. any suggestions would be greatly appreciated.

    thanx…

    [Reply]

    alex Reply:

    Hello kingsley,

    Your questions are outside the realm of this article. If you are interested in consulting services contact us via the contact form on this site. We have done many Cisco VoIP deployments and would be happy to assist.

    Thanks.
    alex

    [Reply]

  15. Scott J says:

    Alex,

    Good article.

    I’m doing tftp to support PXE booting to install OSes across my network. I’ve got DHCP and PXE working just fine.

    When I do yum install tftp-server I get the following output from yum:

    No package tftp-server available.
    Nothing to do

    What am I missing? Is there something wrong with my repos? I’m running CentOS 5.7.

    [Reply]

  16. Scott J says:

    Nevermind. I found the answer. It looks like the tftp server is not in the 5.7 i386 repos. You can get the rpm directly from the 5.6 repo and it works.

    See this CentOS forum post:

    centos.org/modules/newbb/viewtopic.php?viewmode=thread&order=ASC&topic_id=33383&forum=37

    [Reply]

    alex Reply:

    Hello Scott,

    Thanks for following up with the answer.

    Thanks.
    alex

    [Reply]

  17. arush says:

    Hello Alex,

    Thanks.! its very helpful for learner.

    i followed all the steps suggested by you and stuck with below error

    bash: tftp command not found

    Please help ! Thanks in advance

    Regards
    Arush

    [Reply]

    alex Reply:

    Hello arush,

    That would indicate that TFTP is not installed or is not located in the PATH of the user attempting to run the command. Are you attempting to run tftp as root? If you are not running as root try that first but if that does not work you likely need to install TFTP which can be done using the below command.

    bash# yum install tftp tftp-server

    Hope that helps.

    Thanks.
    alex

    [Reply]

  18. James Doran says:

    @arush – CentOS does not include tftp client by default you have to install it.
    yum install tftp should sort you out.

    [Reply]

    alex Reply:

    Hello James Doran,

    Just replied to arush directly as well before I saw your comment. Anyhow thanks for taking the time to answer his question as well.

    Thanks.
    alex

    [Reply]

  19. Rafael says:

    Hello Alex.

    Mi client conect to the server, but a constant timeout occurs. Have any idea?

    regards,

    [Reply]

    alex Reply:

    Hello Rafael,

    I would check file and directory permissions first.

    Thanks.
    alex

    [Reply]

  20.  
Leave a Reply

*Type the letter/number combination in the abvoe field before clicking submit.

*