Fedora - How to set up a TFTP server on Fedora - Printable Version +- Sick Gaming (https://www.sickgaming.net) +-- Forum: Computers (https://www.sickgaming.net/forum-86.html) +--- Forum: Linux, FreeBSD, and Unix types (https://www.sickgaming.net/forum-88.html) +--- Thread: Fedora - How to set up a TFTP server on Fedora (/thread-91964.html) |
Fedora - How to set up a TFTP server on Fedora - xSicKxBot - 09-11-2019 How to set up a TFTP server on Fedora <div><p><strong>TFTP</strong>, or Trivial File Transfer Protocol, allows users to transfer files between systems using the <a href="https://en.wikipedia.org/wiki/User_Datagram_Protocol">UDP protocol</a>. 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 <a href="https://docs.fedoraproject.org/en-US/fedora/f30/install-guide/advanced/Network_based_Installations/">Fedora installations</a>, or other diskless operations.</p> <p> <span id="more-29278"></span> </p> <p>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).</p> <h2>TFTP server installation</h2> <p>The first thing you will need to do is install the TFTP client and server packages:</p> <pre class="wp-block-preformatted">dnf install tftp-server tftp -y</pre> <p>This creates a <em>tftp</em> service and socket file for <a href="https://fedoramagazine.org/systemd-getting-a-grip-on-units/">systemd</a> under <em>/usr/lib/systemd/system</em>.</p> <pre class="wp-block-preformatted">/usr/lib/systemd/system/tftp.service /usr/lib/systemd/system/tftp.socket</pre> <p>Next, copy and rename these files to <em>/etc/systemd/system</em>:</p> <pre class="wp-block-preformatted">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.socket</pre> <h2>Making local changes</h2> <p>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 <em>tftp-server.service</em> file initially looks like:</p> <pre class="wp-block-preformatted">[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.socket</pre> <p>Make the following changes to the <em>[Unit]</em> section:</p> <pre class="wp-block-preformatted">Requires=tftp-server.socket</pre> <p>Make the following changes to the <em>ExecStart</em> line:</p> <pre class="wp-block-preformatted">ExecStart=/usr/sbin/in.tftpd -c -p -s /var/lib/tftpboot</pre> <p>Here are what the options mean:</p> <ul> <li>The <strong><em>-c</em></strong> option allows new files to be created.</li> <li>The <strong><em>-p</em></strong> option is used to have no additional permissions checks performed above the normal system-provided access controls.</li> <li>The<strong><em> -s</em></strong> 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.</li> </ul> <p>The default upload/download location for transferring the files is <em>/var/lib/tftpboot</em>.</p> <p>Next, make the following changes to the <em>[Install]</em> section:</p> <pre class="wp-block-preformatted">[Install] WantedBy=multi-user.target Also=tftp-server.socket</pre> <p>Don’t forget to save your changes!</p> <p>Here is the completed <em>/etc/systemd/system/tftp-server.service</em> file:</p> <pre class="wp-block-preformatted">[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</pre> <h2>Starting the TFTP server</h2> <p>Reload the systemd daemon:</p> <pre class="wp-block-preformatted">systemctl daemon-reload</pre> <p>Now start and enable the server:</p> <pre class="wp-block-preformatted">systemctl enable --now tftp-server</pre> <p>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.</p> <pre class="wp-block-preformatted">chmod 777 /var/lib/tftpboot</pre> <p>Configure your firewall to allow TFTP traffic:</p> <pre class="wp-block-preformatted">firewall-cmd --add-service=tftp --perm firewall-cmd --reload</pre> <h2>Client Configuration</h2> <p>Install the TFTP client:</p> <pre class="wp-block-preformatted">yum install tftp -y</pre> <p>Run the <em>tftp</em> command to connect to the TFTP server. Here is an example that enables the verbose option:</p> <pre class="wp-block-preformatted">[client@thinclient:~ ]$ <strong>tftp 192.168.1.164</strong> tftp> <strong>verbose</strong> Verbose mode on. tftp> <strong>get server.logs</strong> getting from 192.168.1.164:server.logs to server.logs [netascii] Received 7 bytes in 0.0 seconds [inf bits/sec] tftp> <strong>quit</strong> [client@thinclient:~ ]$ </pre> <p>Remember, TFTP does not have the ability to list file names. So you’ll need to know the file name before running the <em>get</em> command to download any files.</p> <hr class="wp-block-separator" /> <p><em>Photo by </em><a href="https://unsplash.com/@laikanotebooks?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText"><em>Laika Notebooks</em></a><em> on <a href="https://unsplash.com/search/photos/file-folders?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a></em>.</p> </div> https://www.sickgaming.net/blog/2019/09/11/how-to-set-up-a-tftp-server-on-fedora/ |