Skip to content

Latest commit

ย 

History

History
239 lines (176 loc) ยท 5.58 KB

File metadata and controls

239 lines (176 loc) ยท 5.58 KB

๐Ÿ“ฑ Trivial File Transfer Protocol (TFTP) Server Setup on RHEL/CentOS

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.


๐Ÿ“… Package Verification and Installation

In this section, we will check whether TFTP packages are installed and then install them if necessary.

๐Ÿ” Check if TFTP client or server is installed

rpm -qa | grep tftp

This command lists installed packages and filters the list for any package related to TFTP.

๐Ÿ“‚ Install the TFTP client and server

yum install tftp tftp-server

Installs the necessary client and server components for TFTP.


๐Ÿ“„ TFTP Package Information

This section helps gather information about the installed TFTP packages and their contents.

๐Ÿ“… View TFTP server package information

rpm -qi tftp-server

Displays details about the installed tftp-server package.

๐Ÿ” List files installed by the TFTP server package

rpm -ql tftp-server

Shows all files included in the tftp-server package.

๐Ÿ”ง Display configuration files

rpm -qc tftp-server

Displays the configuration files associated with the TFTP server package.

๐Ÿ“š Show documentation files

rpm -qd tftp-server

Lists the documentation provided by the TFTP server package.


๐Ÿ“‚ Directory Setup for TFTP Boot

This section prepares the root directory used by the TFTP server.

๐Ÿ”„ Navigate to the default TFTP root directory

cd /var/lib/tftpboot/

Changes to the TFTP root directory.

๐Ÿ” Check if the directory exists

ls -lha /var/lib/ | grep "tftpboot"

Verifies that the TFTP root directory exists and is properly listed.

โš ๏ธ Set full permissions (testing only)

chmod -R 777 /var/lib/tftpboot/

Grants full permissions on the TFTP directory. Not recommended for production use.

๐Ÿ“„ Copy test files into TFTP directory

cp -v /var/log/* /var/lib/tftpboot/

Copies system log files into the TFTP root for testing file transfers.


๐Ÿ”ง Systemd Configuration for TFTP

We will configure custom service and socket unit files to manage the TFTP service using systemd.

๐Ÿ“‚ Copy the systemd service and socket unit files

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

Copies the default unit files to custom locations for editing.

๐Ÿ“– Review the TFTP daemon documentation

man in.tftpd

Displays the manual page for the TFTP daemon.


๐Ÿ“ƒ TFTP Server Service File Configuration

This is the custom service file for TFTP, configured to point to the correct directory.

๐Ÿ“„ File: /etc/systemd/system/tftp-server.service

[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.socket

๐Ÿ“ƒ TFTP Server Socket File Configuration

The socket file is responsible for listening on UDP port 69 for TFTP requests.

๐Ÿ“„ File: /etc/systemd/system/tftp-server.socket

[Unit]
Description=TFTP Server Activation Socket

[Socket]
ListenDatagram=69
BindIPv6Only=both

[Install]
WantedBy=sockets.target

๐Ÿ”ฅ Firewall Configuration Using firewalld

We need to allow TFTP traffic through the system firewall.

๐Ÿ” Check if firewalld is active

systemctl status firewalld

Displays the current status of firewalld.

โ–ถ๏ธ Start and enable firewalld

systemctl start firewalld
systemctl enable firewalld

Starts and enables firewalld to run on boot.

โž• Add TFTP service to the public zone

firewall-cmd --zone=public --add-service=tftp --permanent

Allows TFTP service in the public zone permanently.

๐Ÿ”“ Open UDP port 69 manually

firewall-cmd --zone=public --add-port=69/udp --permanent

Manually opens port 69 for TFTP if the above service method is not used.

๐Ÿ”„ Reload the firewall

firewall-cmd --reload

Reloads the firewalld configuration to apply new changes.

๐Ÿ“… Verify applied rules

firewall-cmd --zone=public --list-all

Lists all the active rules in the public zone.


๐Ÿš€ Starting and Enabling the TFTP Server

Enable and start the TFTP service via systemd socket.

๐Ÿ”„ Restart the TFTP socket

systemctl restart tftp-server.socket

Restarts the socket to activate the TFTP service.

๐Ÿ”— Enable TFTP service at boot

systemctl enable tftp-server

Ensures the TFTP service starts on system boot.


๐Ÿ”Ž Verifying TFTP Server Status

Confirm that the TFTP server is listening on the correct port.

๐Ÿ“ถ Check using netstat

netstat -nltup | grep 69

Looks for TFTP listening on UDP port 69.

๐Ÿ“ถ Check using ss

ss -uln | grep 69

An alternative tool to check UDP port bindings for TFTP.


๐Ÿ“ˆ Summary

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.


โšก