This guide explains how to install, configure, and verify a TFTP server on RHEL/CentOS systems. TFTP is a simple file transfer protocol, typically used for bootstrapping embedded systems, routers, and PXE booting.
In this section, we will check whether TFTP packages are installed and then install them if necessary.
rpm -qa | grep tftpThis command lists installed packages and filters the list for any package related to TFTP.
yum install tftp tftp-serverInstalls the necessary client and server components for TFTP.
This section helps gather information about the installed TFTP packages and their contents.
rpm -qi tftp-serverDisplays details about the installed tftp-server package.
rpm -ql tftp-serverShows all files included in the tftp-server package.
rpm -qc tftp-serverDisplays the configuration files associated with the TFTP server package.
rpm -qd tftp-serverLists the documentation provided by the TFTP server package.
This section prepares the root directory used by the TFTP server.
cd /var/lib/tftpboot/Changes to the TFTP root directory.
ls -lha /var/lib/ | grep "tftpboot"Verifies that the TFTP root directory exists and is properly listed.
chmod -R 777 /var/lib/tftpboot/Grants full permissions on the TFTP directory. Not recommended for production use.
cp -v /var/log/* /var/lib/tftpboot/Copies system log files into the TFTP root for testing file transfers.
We will configure custom service and socket unit files to manage the TFTP service using systemd.
cp -v /usr/lib/systemd/system/tftp.service /etc/systemd/system/tftp-server.service
cp -v /usr/lib/systemd/system/tftp.socket /etc/systemd/system/tftp-server.socketCopies the default unit files to custom locations for editing.
man in.tftpdDisplays the manual page for the TFTP daemon.
This is the custom service file for TFTP, configured to point to the correct directory.
[Unit]
Description=TFTP Server
Requires=tftp-server.socket
Documentation=man:in.tftpd
[Service]
ExecStart=/usr/sbin/in.tftpd -p -s /var/lib/tftpboot
StandardInput=socket
[Install]
WantedBy=multi-user.target
Also=tftp-server.socketThe socket file is responsible for listening on UDP port 69 for TFTP requests.
[Unit]
Description=TFTP Server Activation Socket
[Socket]
ListenDatagram=69
BindIPv6Only=both
[Install]
WantedBy=sockets.targetWe need to allow TFTP traffic through the system firewall.
systemctl status firewalldDisplays the current status of firewalld.
systemctl start firewalld
systemctl enable firewalldStarts and enables firewalld to run on boot.
firewall-cmd --zone=public --add-service=tftp --permanentAllows TFTP service in the public zone permanently.
firewall-cmd --zone=public --add-port=69/udp --permanentManually opens port 69 for TFTP if the above service method is not used.
firewall-cmd --reloadReloads the firewalld configuration to apply new changes.
firewall-cmd --zone=public --list-allLists all the active rules in the public zone.
Enable and start the TFTP service via systemd socket.
systemctl restart tftp-server.socketRestarts the socket to activate the TFTP service.
systemctl enable tftp-serverEnsures the TFTP service starts on system boot.
Confirm that the TFTP server is listening on the correct port.
netstat -nltup | grep 69Looks for TFTP listening on UDP port 69.
ss -uln | grep 69An alternative tool to check UDP port bindings for TFTP.
In this guide, we:
- Verified and installed TFTP packages
- Explored TFTP package contents and configurations
- Set up the TFTP root directory and permissions
- Configured systemd service and socket files
- Adjusted firewall settings for UDP port 69
- Started and enabled the TFTP service
- Verified server status using network tools
With these steps, your RHEL/CentOS system should now be fully equipped with a functioning TFTP server ready to handle file transfers over the network.