Difference between revisions of "TFTP"

From ArchWiki
Jump to: navigation, search
(Add configuration for tftpd, removed configuration for dhcpd (unrelated))
(Configuration: Merge info from Network Installation Guide.)
(12 intermediate revisions by 9 users not shown)
Line 1: Line 1:
[[Category:Networking (English)]]
+
[[Category:File Transfer Protocol]]
 +
The [[Wikipedia:Trivial File Transfer Protocol|Trivial File Transfer Protocol]] (TFTP) provides a minimalistic means for transferring files.  It is generally used as a part of [[PXE]] booting or for updating configuration and firmware on devices which have limited memory such as routers and printers.
  
== Introduction ==
+
This article describes how to set up a tftpd server under Arch Linux using the {{Pkg|tftp-hpa}} package.
This HOWTO describes how to set up a tftpd server under Arch Linux.
+
  
 
== Installation ==
 
== Installation ==
The first thing is to install all necessary stuff:
+
[[pacman|Install]] the package {{Pkg|tftp-hpa}} which can be found in the [[Official Repositories|official repositories]].
# pacman -S tftp-hpa
+
  
 
== Configuration ==
 
== Configuration ==
The configuration for tftpd is in /etc/conf.d/tftpd
+
The configuration for tftpd is in {{ic|/etc/conf.d/tftpd}}
 
+
The default configuration is
+
  
 +
The default configuration is:
 
  #
 
  #
 
  # Parameters to be passed to TFTPD
 
  # Parameters to be passed to TFTPD
 
  #
 
  #
  TFTPD_ARGS="-l -s /var/tftpboot"  
+
  TFTPD_ARGS="-l -s /srv/tftp/"
  
The directory /var/tftpdboot is created automatically when tftp-hpa is installed.
+
{{ic|-s /srv/tftp/}} set ftpd root directory to {{ic|/srv/tftp/}}. The directory {{ic|/srv/tftp}} is created automatically when {{Pkg|tftp-hpa}} is installed.
 +
 
 +
For systemd configuration, {{ic|/usr/lib/systemd/system/tftpd.service}} is used:
 +
 
 +
[Unit]
 +
Description=hpa's original TFTP daemon
 +
 +
[Service]
 +
ExecStart=/usr/sbin/in.tftpd -s /srv/tftp/
 +
StandardInput=socket
 +
StandardOutput=inherit
 +
StandardError=journal
 +
 
 +
Copy the tftp unit files in {{ic|/usr/lib/systemd/system}} to {{ic|/etc/systemd/system}}; the former gets overwritten when systemd is updated. The [[systemd]] article talks in more detail about customizing unit files.
 +
 
 +
For a complete list of parameters:
 +
$ man in.tftpd
  
 
== Run ==
 
== Run ==
Tftpd daemon can be started in one of the three ways.
 
  
1. From /etc/rc.conf
+
=== Systemd ===
 +
To start the daemon at boot, run:
 +
# systemctl enable tftpd.socket
 +
 
 +
 
 +
To start the daemon manually (You must respect this order):
 +
# systemctl start tftpd.socket
 +
# systemctl start tftpd.service
 +
 
 +
 
 +
To stop the daemon manually (You must respect this order):
 +
# systemctl stop tftpd.socket
 +
# systemctl stop tftpd.service
  
Add "tftpd" to the DAEMON line in /etc/rc.conf
+
=== Sysvinit ===
 +
To start the daemon at boot, add {{ic|tftpd}} to the {{ic|DAEMONS}} array in {{ic|/etc/[[rc.conf]]}}.
  
2. From /etc/rc.d
+
To start the daemon manually:
 +
# /etc/rc.d/tftpd start
  
  /etc/rc.d/tftpd start
+
To start the daemon without a configuration file:
 +
  # /usr/sbin/in.tftpd -l -s path/to/folder/to/export
  
3. From commandline
+
== Troubleshooting ==
 +
=== tftpd startup fails if ipv6 is disabled ===
 +
If tftpd startup fails without leaving error messages, it might be because ipv6 is disabled and you are not explicitly telling tftpd not to use ipv6. You can make tftpd start by enabling ipv6 or by telling tftpd to only use ipv4, adding the '-4' switch to /etc/conf.d/tftpd
  
/usr/sbin/tftpd -l -s path/to/folder/to/export.
+
{{hc|/etc/conf.d/tftpd|<nowiki>
 +
TFTPD_ARGS="-l -4 -s /srv/tftp/"
 +
</nowiki>}}

Revision as of 13:26, 14 December 2012

The Trivial File Transfer Protocol (TFTP) provides a minimalistic means for transferring files. It is generally used as a part of PXE booting or for updating configuration and firmware on devices which have limited memory such as routers and printers.

This article describes how to set up a tftpd server under Arch Linux using the tftp-hpa package.

Installation

Install the package tftp-hpa which can be found in the official repositories.

Configuration

The configuration for tftpd is in /etc/conf.d/tftpd

The default configuration is:

#
# Parameters to be passed to TFTPD
#
TFTPD_ARGS="-l -s /srv/tftp/"

-s /srv/tftp/ set ftpd root directory to /srv/tftp/. The directory /srv/tftp is created automatically when tftp-hpa is installed.

For systemd configuration, /usr/lib/systemd/system/tftpd.service is used:

[Unit]
Description=hpa's original TFTP daemon

[Service]
ExecStart=/usr/sbin/in.tftpd -s /srv/tftp/
StandardInput=socket
StandardOutput=inherit
StandardError=journal

Copy the tftp unit files in /usr/lib/systemd/system to /etc/systemd/system; the former gets overwritten when systemd is updated. The systemd article talks in more detail about customizing unit files.

For a complete list of parameters:

$ man in.tftpd

Run

Systemd

To start the daemon at boot, run:

# systemctl enable tftpd.socket


To start the daemon manually (You must respect this order):

# systemctl start tftpd.socket
# systemctl start tftpd.service


To stop the daemon manually (You must respect this order):

# systemctl stop tftpd.socket
# systemctl stop tftpd.service

Sysvinit

To start the daemon at boot, add tftpd to the DAEMONS array in /etc/rc.conf.

To start the daemon manually:

# /etc/rc.d/tftpd start

To start the daemon without a configuration file:

# /usr/sbin/in.tftpd -l -s path/to/folder/to/export

Troubleshooting

tftpd startup fails if ipv6 is disabled

If tftpd startup fails without leaving error messages, it might be because ipv6 is disabled and you are not explicitly telling tftpd not to use ipv6. You can make tftpd start by enabling ipv6 or by telling tftpd to only use ipv4, adding the '-4' switch to /etc/conf.d/tftpd

/etc/conf.d/tftpd
TFTPD_ARGS="-l -4 -s /srv/tftp/"