09-11-2019, 05:22 PM
How to set up a TFTP server on Fedora
TFTP, or Trivial File Transfer Protocol, allows users to transfer files between systems using the UDP protocol. By default, it uses UDP port 69. The TFTP protocol is extensively used to support remote booting of diskless devices. So, setting up a TFTP server on your own local network can be an interesting way to do Fedora installations, or other diskless operations.
TFTP can only read and write files to or from a remote system. It doesn’t have the capability to list files or make any changes on the remote server. There are also no provisions for user authentication. Because of security implications and the lack of advanced features, TFTP is generally only used on a local area network (LAN).
TFTP server installation
The first thing you will need to do is install the TFTP client and server packages:
This creates a tftp service and socket file for systemd under /usr/lib/systemd/system.
Next, copy and rename these files to /etc/systemd/system:
Making local changes
You need to edit these files from the new location after you’ve copied and renamed them, to add some additional parameters. Here is what the tftp-server.service file initially looks like:
Make the following changes to the [Unit] section:
Make the following changes to the ExecStart line:
Here are what the options mean:
The default upload/download location for transferring the files is /var/lib/tftpboot.
Next, make the following changes to the [Install] section:
Don’t forget to save your changes!
Here is the completed /etc/systemd/system/tftp-server.service file:
Starting the TFTP server
Reload the systemd daemon:
Now start and enable the server:
To change the permissions of the TFTP server to allow upload and download functionality, use this command. Note TFTP is an inherently insecure protocol, so this may not be advised on a network you share with other people.
Configure your firewall to allow TFTP traffic:
Client Configuration
Install the TFTP client:
Run the tftp command to connect to the TFTP server. Here is an example that enables the verbose option:
Remember, TFTP does not have the ability to list file names. So you’ll need to know the file name before running the get command to download any files.
Photo by Laika Notebooks on Unsplash.
TFTP, or Trivial File Transfer Protocol, allows users to transfer files between systems using the UDP protocol. By default, it uses UDP port 69. The TFTP protocol is extensively used to support remote booting of diskless devices. So, setting up a TFTP server on your own local network can be an interesting way to do Fedora installations, or other diskless operations.
TFTP can only read and write files to or from a remote system. It doesn’t have the capability to list files or make any changes on the remote server. There are also no provisions for user authentication. Because of security implications and the lack of advanced features, TFTP is generally only used on a local area network (LAN).
TFTP server installation
The first thing you will need to do is install the TFTP client and server packages:
Code:
dnf install tftp-server tftp -yThis creates a tftp service and socket file for systemd under /usr/lib/systemd/system.
Code:
/usr/lib/systemd/system/tftp.service
/usr/lib/systemd/system/tftp.socketNext, copy and rename these files to /etc/systemd/system:
Code:
cp /usr/lib/systemd/system/tftp.service /etc/systemd/system/tftp-server.service cp /usr/lib/systemd/system/tftp.socket /etc/systemd/system/tftp-server.socketYou need to edit these files from the new location after you’ve copied and renamed them, to add some additional parameters. Here is what the tftp-server.service file initially looks like:
Code:
[Unit]
Description=Tftp Server
Requires=tftp.socket
Documentation=man:in.tftpd [Service]
ExecStart=/usr/sbin/in.tftpd -s /var/lib/tftpboot
StandardInput=socket [Install]
Also=tftp.socketMake the following changes to the [Unit] section:
Code:
Requires=tftp-server.socketMake the following changes to the ExecStart line:
Code:
ExecStart=/usr/sbin/in.tftpd -c -p -s /var/lib/tftpbootHere are what the options mean:
- The -c option allows new files to be created.
- The -p option is used to have no additional permissions checks performed above the normal system-provided access controls.
- The -s option is recommended for security as well as compatibility with some boot ROMs which cannot be easily made to include a directory name in its request.
The default upload/download location for transferring the files is /var/lib/tftpboot.
Next, make the following changes to the [Install] section:
Code:
[Install]
WantedBy=multi-user.target
Also=tftp-server.socketDon’t forget to save your changes!
Here is the completed /etc/systemd/system/tftp-server.service file:
Code:
[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.socketReload the systemd daemon:
Code:
systemctl daemon-reloadNow start and enable the server:
Code:
systemctl enable --now tftp-serverTo change the permissions of the TFTP server to allow upload and download functionality, use this command. Note TFTP is an inherently insecure protocol, so this may not be advised on a network you share with other people.
Code:
chmod 777 /var/lib/tftpbootConfigure your firewall to allow TFTP traffic:
Code:
firewall-cmd --add-service=tftp --perm
firewall-cmd --reloadInstall the TFTP client:
Code:
yum install tftp -yRun the tftp command to connect to the TFTP server. Here is an example that enables the verbose option:
Code:
[client@thinclient:~ ]$ tftp 192.168.1.164
tftp> verbose
Verbose mode on.
tftp> get server.logs
getting from 192.168.1.164:server.logs to server.logs [netascii]
Received 7 bytes in 0.0 seconds [inf bits/sec]
tftp> quit
[client@thinclient:~ ]$Remember, TFTP does not have the ability to list file names. So you’ll need to know the file name before running the get command to download any files.
Photo by Laika Notebooks on Unsplash.

