summaryrefslogtreecommitdiff
path: root/docs/configuration/service/tftp-server.md
blob: de07eee4b775a0d80bcd82a2d2bbe50f1a385e8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
---
myst:
  html_meta:
    description: |
      The VyOS TFTP server lets clients download files from a
      configured directory over UDP. Uploads are disabled by default
      and can be enabled. The server can listen on multiple addresses
      and inside a non-default VRF.
    keywords: tftp, tftp-server, trivial file transfer protocol, file
      transfer, network boot
---

(tftp-server)=

# TFTP server

{abbr}`TFTP (Trivial File Transfer Protocol)` is a simple, UDP-based
file-transfer protocol defined in
[RFC 1350](https://datatracker.ietf.org/doc/html/rfc1350) that lets
clients upload files to and download files from a remote host. One of
its main uses is during the early stages of network boot, where
devices fetch a boot image or initial configuration from a TFTP server
before they are fully operational.

VyOS ships a TFTP server that lets clients download files from a
configured directory. Uploads are disabled by default but can be
enabled. The TFTP server is configured under `service tftp-server`.

## Configuration

```{cfgcmd} set service tftp-server directory \<directory\>

**Configure the directory from which clients download files and, when
uploads are enabled, upload files to.**

The directory is created if it does not exist, and its owner and
group are set to the `tftp` system user. This value is mandatory.
```

```{note}
This setting is mandatory. The commit fails if no directory is configured.
```

```{note}
Choose the location carefully, or the contents will be lost on image
upgrade. Any path under `/config` is preserved and migrated across
image upgrades.
```

Example:

```none
set service tftp-server directory /config/tftpboot
```

```{cfgcmd} set service tftp-server listen-address \<address\>

**Configure a local IPv4 or IPv6 address on which the TFTP server
accepts incoming requests.**

Repeat the command to listen on multiple IP addresses. The IP address must
be assigned to a local interface. Otherwise, the commit succeeds with
a warning, and the TFTP server does not accept connections on that IP
address.
```

```{note}
At least one listen address must be set whenever `service tftp-server`
is configured. Otherwise, the commit is rejected.
```

Example:

```none
set service tftp-server listen-address 192.0.2.1
set service tftp-server listen-address 2001:db8::1
```

```{cfgcmd} set service tftp-server listen-address \<address\> vrf \<name\>

**Expose the TFTP server on the specified IP address within a non-default VRF.**

The {abbr}`VRF (Virtual Routing and Forwarding instance)` must already
be configured under `vrf name <name>`. Otherwise, the commit is
rejected.
```

Example:

```none
set service tftp-server listen-address 192.0.2.1 vrf MGMT
```

```{cfgcmd} set service tftp-server port \<1-65535\>

**Configure the UDP port on which the TFTP server listens.**

The default is 69, the port assigned to TFTP by the
{abbr}`IANA (Internet Assigned Numbers Authority)`.
```

Example:

```none
set service tftp-server port 6969
```

```{cfgcmd} set service tftp-server allow-upload

**Enable client uploads (TFTP write requests) to the server.**

By default, the server operates in read-only mode and rejects write
requests.
```

Example:

```none
set service tftp-server allow-upload
```

## Example

The following example configures a TFTP server that uses
`/config/tftpboot` as its file directory, listens on both IPv4 and
IPv6 addresses, and accepts client uploads.

```none
set service tftp-server directory '/config/tftpboot'
set service tftp-server listen-address '192.0.2.1'
set service tftp-server listen-address '2001:db8::1'
set service tftp-server allow-upload
```

## Verification

Upload a file from a TFTP client to the server (write request):

```none
vyos@client:~$ tftp -p -l /config/config.boot -r backup 192.0.2.1
backup              100% |******************************|   723  0:00:00 ETA
```

On the server, the uploaded file appears in the configured directory,
owned by the `tftp` user:

```none
vyos@vyos:~$ ls -ltr /config/tftpboot/
total 1
-rw-rw-rw- 1 tftp tftp 723 May 19 16:02 backup
```