Hướng dẫn cài đặt TFTP Server trên CentOS 7


How to install TFTP Server on CentOS 7

How to install TFTP Server on CentOS 7Cuongquach.com | In this post i will show you how to install TFTP Server on CentOS 7. Trivial File Transfer Protocol (TFTP) is a small Internet service ultility that can help use to transfer file easier than FTP Service. TFTP does not require authentication from client and client cannot list file on directory of TFTP Server. TFTP use UDP Protocol at port number 69, you can read more from RFC 1350. TFTP Server is used a lots in PXE Server Environment or like a storage place to upload flash to Router/Switch.

Steps to install TFTP Server on CentOS 7

1. Install TFTP Server package

First of all, you need to install TFTP Server package on CentOS 7.

# yum install tftp tftp-server xinetd

Turn off SELinux feature if you dont know how to control and use it. You need to reboot os to apply new config of SELinux, however you can temporarily turn off it with command ‘setenforce‘.

# vi /etc/selinux/config

# setenforce 0

2. Config TFTP Service

I will create a user to be owner of data directory used by TFTP Service.

# useradd --no-create-home -s /sbin/nologin tftp

Now, a specific directory for TFTP Server ?! It’s up to you, follow me i will create one for service.

# mkdir -p /tftpdata
# chmod 777 /tftpdata
# touch /tftpdata/demo.txt
# chown tftp:tftp -R /tftpdata

Configure file TFTP Service with below noticed config lines.

# vi /etc/xinetd.d/tftp

# default: off
# description: The tftp server serves files using the trivial file transfer
#       protocol.  The tftp protocol is often used to boot diskless
#       workstations, download configuration files to network-aware printers,
#       and to start the installation process for some operating systems.
service tftp
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -c -v -u tftp -p -U 117 -s /tftpdata
        disable                 = disable
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4

Note :
– disable = disable :
– server_args
+ ‘-c‘ : allow client connect and create file on directory of TFTP Server.
+ ‘-s‘ : auto change directory when client connect to TFTP Server, to specific directory in the config file like /tftpdata. It’s secure feature.
+ ‘-u‘ : specific user owner of directory /tftpdata.
+ ‘-p‘ : Perform no additional permissions checks above the normal system-provided access controls for the user specified via the ‘-u’ option.
+ ‘-U‘ : setup Umask setting when client create or push new file.
+ ‘-v‘ : this option help print some logging verbose when client connect to TFTP Server.

References link : https://linux.die.net/man/8/tftpd

3. Start TFTP Service, add to list startup service

Edit file system start service of TFTP, change the configuration line ‘ExecStart‘ in [Service] section to be as same as the config of previous step (step 2).

# vi /usr/lib/systemd/system/tftp.service
Description=Tftp Server

ExecStart=/usr/sbin/in.tftpd -c -v -u tftp -p -U 117 -s /tftpdata


Reload new configuration of systemd service file.

# systemctl daemon-reload

Start TFTP Service.

# systemctl start xinetd
# systemctl start tftp

Add TFTP Service to startup service on CentOS 7.

# systemctl enable xinetd
# systemctl enable tftp

Checking that TFTP is listenning on port UDP 69 or not.

# netstat -antpu | grep 69
udp6 0 0 :::69 :::* 1/systemd

4. Configure Firewall to allow TFTP Service

If you have local firewall on your server you need to set up allowing incomming port 69/UDP. For example with ‘iptables‘.

# iptables -I INPUT -p udp --dport 69 -j ACCEPT

5. Checking connecting to TFTP Server

If you are using Windows, you can use application like WinSCP to test connecting to TFTP Server. If you are using Linux OS, try using command ‘tftp’ to connect and use bot of tftp’s command like ‘get‘ – get file from TFTP Server ; ‘put‘ – push file from local to TFTP Server.

# tftp
get demo.txt

So now you finish tutorial how to install TFTP Server on CentOS 7.

Previous articleKhởi tạo mật khẩu ngẫu nhiên với code Python
Next articleTìm hiểu cấu hình Workspace trong Terraform
Bạn đang theo dõi website "https://cuongquach.com/" nơi lưu trữ những kiến thức tổng hợp và chia sẻ cá nhân về Quản Trị Hệ Thống Dịch Vụ & Mạng, được xây dựng lại dưới nền tảng kinh nghiệm của bản thân mình, Quách Chí Cường. Hy vọng bạn sẽ thích nơi này !


Please enter your comment!
Please enter your name here