Friday, December 27, 2024
Google search engine
HomeGuest BlogsSetup TFTP server on CentOS 8|RHEL 8|Rocky Linux 8

Setup TFTP server on CentOS 8|RHEL 8|Rocky Linux 8

.tdi_3.td-a-rec{text-align:center}.tdi_3 .td-element-style{z-index:-1}.tdi_3.td-a-rec-img{text-align:left}.tdi_3.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_3.td-a-rec-img{text-align:center}}

This guide will discuss how to install TFTP Server on CentOS 8|RHEL 8|Rocky Linux 8 Linux machine. The Trivial File Transfer Protocol (TFTP) is a UDP protocol designed to allow users to transfer files between systems. TFTP uses UDP port 69 for data transfer.

The most ideal use case of TFTP protocol is remote booting of diskless devices such as workstations. By setting up TFTP Server on CentOS 8 / RHEL 8 can help you do large installations OS Fedora / CentOS and RHEL server and Desktop installations in your network.

With TFTP, you can only read and write files to or from a remote system, but there is no capability to list files or make any changes on the remote server. It is recommended to run a TFTP Server in your local area network (LAN) as there is no user authentication support. TFTP only provides very little security.

.tdi_2.td-a-rec{text-align:center}.tdi_2 .td-element-style{z-index:-1}.tdi_2.td-a-rec-img{text-align:left}.tdi_2.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_2.td-a-rec-img{text-align:center}}

Configure TFTP server on CentOS 8 / RHEL 8 / Rocky Linux 8

So how then can I install TFTP Server on CentOS 8|RHEL 8|Rocky Linux 8?.

Step 1: Install TFTP Server

The TFTP server and client packages are available on the Base OS repository of RHEL / CentOS 8 Linux. Open your favorite terminal emulator and run the commands below to install TFTP Server on RHEL 8 / CentOS 8.

sudo dnf install -y tftp-server tftp

Step 2: Configure TFTP Server

The installation automatically creates a tftp service and socket file for systemd under /usr/lib/systemd/system. We’ll copy systemd configuration files to /etc/systemd/system directory.

sudo cp /usr/lib/systemd/system/tftp.service /etc/systemd/system/tftp-server.service
sudo cp /usr/lib/systemd/system/tftp.socket /etc/systemd/system/tftp-server.socket

Edit /etc/systemd/system/tftp-server.service service and set these values.

sudo tee /etc/systemd/system/tftp-server.service<<EOF
[Unit]
Description=Tftp Server
Requires=tftp-server.socket
Documentation=man:in.tftpd

[Service]
ExecStart=/usr/sbin/in.tftpd -c -p -s /var/lib/tftpboot
StandardInput=socket

[Install]
WantedBy=multi-user.target
Also=tftp-server.socket
EOF

Meaning of options added to ExecStart line.

  • -c : Allows new files to be created.
  • -p : Used to have no additional permissions checks performed above the normal system-provided access controls.
  • -s : Recommended for security and compatibility with older boot ROMs.

Note that the default location for files uploads and downloads is /var/lib/tftpboot as configured in the service file.

Step 3: Start TFTP Server

We have the configurations for TFTP server done right. Let’s reload the systemd daemon:

sudo systemctl daemon-reload

Once reloaded, start and enable the server:

$ sudo systemctl enable --now tftp-server
Created symlink /etc/systemd/system/multi-user.target.wants/tftp-server.service → /etc/systemd/system/tftp-server.service.
Created symlink /etc/systemd/system/sockets.target.wants/tftp-server.socket → /etc/systemd/system/tftp-server.socket.

Confirm the service is running.

systemctl status tftp-server

Here is my screenshot.

install tftp server centos 8 01

Set correct permissions for TFTP directory.

sudo chmod 777 /var/lib/tftpboot

For systems with running Firewalld service, allow TFTP ports:

sudo firewall-cmd --add-service=tftp --permanent
sudo firewall-cmd --reload

Add test files to TFTP directory.

sudo touch  /var/lib/tftpboot/file{1..3}.txt
echo "Hello File 1" | sudo tee /var/lib/tftpboot/file1.txt
echo "Hello File 2" | sudo tee /var/lib/tftpboot/file2.txt
echo "Hello File 3" | sudo tee /var/lib/tftpboot/file3.txt

Step 4: Using TFTP Client

Let’s test our connection to TFTP Server using TFTP client. This can be a different machine in your network. But the same machine running TFTP server can be used for this operation

Install the TFTP client:

sudo yum install tftp -y

Try use the the tftp command to connect to the TFTP server.

$ tftp 10.10.1.152
tftp> 

Here are the commands you can use on the shell.

Commands may be abbreviated.  Commands are:

connect 	connect to remote tftp
mode    	set file transfer mode
put     	send file
get     	receive file
quit    	exit tftp
verbose 	toggle verbose mode
trace   	toggle packet tracing
literal 	toggle literal mode, ignore ':' in file name
status  	show current status
binary  	set mode to octet
ascii   	set mode to netascii
rexmt   	set per-packet transmission timeout
timeout 	set total retransmission timeout
?       	print help information
help    	print help information

Example – Let’s download added files.

$ cat file1.txt file2.txt file3.txt 
Hello File 1
Hello File 2
Hello File 3

To upload a file, use put command.

tftp> put client_test.log

Use quit to quit.

tftp> quit

You’ve learned how to install TFTP Server on CentOS 8 / RHEL 8 Linux system and configure TFTP client to upload and download files from TFTP server. Until next time, stay connected for newer updates.

Recommended Linux Books  to read:

Also check:

.tdi_4.td-a-rec{text-align:center}.tdi_4 .td-element-style{z-index:-1}.tdi_4.td-a-rec-img{text-align:left}.tdi_4.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_4.td-a-rec-img{text-align:center}}

RELATED ARTICLES

Most Popular

Recent Comments