# Doc / config serveur TFTP

####   


#### <span style="color: rgb(35, 111, 161);">1. Qu'est-ce que TFTP ?</span>

  
TFTP (Trivial File Transfer Protocol) est un protocole de transfert de fichiers simplifié. Contrairement à FTP, il ne dispose d'aucune authentification ni chiffrement, ce qui le rend très léger et rapide. Il fonctionne sur le port UDP 69.

<table cellpadding="5" cellspacing="0" id="bkmrk-caract%C3%A9ristique-d%C3%A9ta" width="624"><colgroup><col width="222"></col> <col width="380"></col> </colgroup><tbody><tr valign="top"><td bgcolor="#1f497d" style="background: #1f497d; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="222"><span style="color: #ffffff;"><span style="font-family: Arial, serif;"><span style="font-size: small;">**Caractéristique**</span></span></span>

</td><td bgcolor="#1f497d" style="background: #1f497d; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="380"><span style="color: #ffffff;"><span style="font-family: Arial, serif;"><span style="font-size: small;">**Détail**</span></span></span>

</td></tr><tr valign="top"><td bgcolor="#ffffff" style="background: #ffffff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="222"><span style="font-family: Arial, serif;"><span style="font-size: small;">Protocole</span></span>

</td><td bgcolor="#ffffff" style="background: #ffffff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="380"><span style="font-family: Arial, serif;"><span style="font-size: small;">UDP port 69</span></span>

</td></tr><tr valign="top"><td bgcolor="#f5f9ff" style="background: #f5f9ff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="222"><span style="font-family: Arial, serif;"><span style="font-size: small;">Authentification</span></span>

</td><td bgcolor="#f5f9ff" style="background: #f5f9ff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="380"><span style="font-family: Arial, serif;"><span style="font-size: small;">Aucune</span></span>

</td></tr><tr valign="top"><td bgcolor="#ffffff" style="background: #ffffff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="222"><span style="font-family: Arial, serif;"><span style="font-size: small;">Chiffrement</span></span>

</td><td bgcolor="#ffffff" style="background: #ffffff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="380"><span style="font-family: Arial, serif;"><span style="font-size: small;">Aucun</span></span>

</td></tr><tr valign="top"><td bgcolor="#f5f9ff" style="background: #f5f9ff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="222"><span style="font-family: Arial, serif;"><span style="font-size: small;">Taille max fichier</span></span>

</td><td bgcolor="#f5f9ff" style="background: #f5f9ff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="380"><span style="font-family: Arial, serif;"><span style="font-size: small;">~32 MB (selon implémentation)</span></span>

</td></tr><tr valign="top"><td bgcolor="#ffffff" style="background: #ffffff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="222"><span style="font-family: Arial, serif;"><span style="font-size: small;">Usage recommandé</span></span>

</td><td bgcolor="#ffffff" style="background: #ffffff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="380"><span style="font-family: Arial, serif;"><span style="font-size: small;">Réseau de gestion isolé uniquement</span></span>

</td></tr><tr valign="top"><td bgcolor="#f5f9ff" style="background: #f5f9ff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="222"><span style="font-family: Arial, serif;"><span style="font-size: small;">Alternative sécurisée</span></span>

</td><td bgcolor="#f5f9ff" style="background: #f5f9ff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="380"><span style="font-family: Arial, serif;"><span style="font-size: small;">SCP (ip scp server enable sur Cisco)</span></span>

</td></tr></tbody></table>

#### <span style="color: rgb(35, 111, 161);">2. Qu'est-ce que tftpd-hpa ?</span>

  
tftpd-hpa est l'implémentation la plus répandue et fiable d'un serveur TFTP sous Linux.

##### **Installation:**

```
apt update
apt install tftpd-hpa
```

##### **Fichier de configuration : /etc/default/tftpd-hpa:**

```
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/srv/tftp"        
TFTP_ADDRESS="0.0.0.0:69"         # Ecoute sur toutes les interfaces
TFTP_OPTIONS="--secure --create"  
```

##### **Préparer le dossier de stockage:**

```
mkdir -p /srv/tftp
chown tftp:tftp /srv/tftp
chmod 777 /srv/tftp
```

##### **Démarrer et activer le service:** 

```
systemctl restart tftpd-hpa
systemctl enable tftpd-hpa
systemctl status tftpd-hpa
```

#####  

#### <span style="color: rgb(35, 111, 161);">3. Sauvegarde de la configuration courante (Switch/Routeur):</span>

##### **Sauvegarde de la configuration courante:**

```
copy running-config tftp
! Address or name of remote host? 192.168.99.6
! Destination filename? "filename"
```

##### **Sauvegarde de la configuration de démarrage:**

```
copy startup-config tftp
! Address or name of remote host? 192.168.99.6
! Destination filename? "filename"
```

##### **Restauration d'une configuration depuis tftp:**

```
copy tftp running-config
! Address or name of remote host? 192.168.99.10
! Source filename? isr4321-running-config
```

#### <span style="color: rgb(35, 111, 161);">4. Vérification / Supervision :</span>

##### <span style="color: rgb(0, 0, 0);">**Vérifier les fichiers reçus sur le serveur TFTP (VM) :** </span>

```
ls -lh /srv/tftp/
```

##### **<span style="color: rgb(0, 0, 0);">Surveiller les transferts en temps réel (côté Cisco) :</span>**

```
debug ip tftp
! Pour désactiver :
no debug ip tftp
! Ou tout désactiver :
undebug all
```

#####  

##### <span style="color: rgb(0, 0, 0);">**Tester la connectivité TFTP depuis la vm:**  
  
</span>

```
tftp 192.168.99.6
> get isr4321-running-config
> quit
```

<span style="color: rgb(0, 0, 0);">  
</span>

#### <span style="color: rgb(35, 111, 161);">5. Résumer commandes clés:</span>

<table cellpadding="5" cellspacing="0" id="bkmrk-action-commande-%2F-em" width="624"><colgroup><col width="256"></col> <col width="346"></col> </colgroup><tbody><tr valign="top"><td bgcolor="#1f497d" style="background: #1f497d; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="256"><span style="color: #ffffff;"><span style="font-family: Arial, serif;"><span style="font-size: small;">**Action**</span></span></span>

</td><td bgcolor="#1f497d" style="background: #1f497d; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="346"><span style="color: #ffffff;"><span style="font-family: Arial, serif;"><span style="font-size: small;">**Commande / Emplacement**</span></span></span>

</td></tr><tr valign="top"><td bgcolor="#ffffff" style="background: #ffffff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="256"><span style="font-family: Arial, serif;"><span style="font-size: small;">Installer tftpd-hpa</span></span>

</td><td bgcolor="#ffffff" style="background: #ffffff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="346"><span style="font-family: Arial, serif;"><span style="font-size: small;">apt install tftpd-hpa</span></span>

</td></tr><tr valign="top"><td bgcolor="#f5f9ff" style="background: #f5f9ff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="256"><span style="font-family: Arial, serif;"><span style="font-size: small;">Fichier de config TFTP</span></span>

</td><td bgcolor="#f5f9ff" style="background: #f5f9ff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="346"><span style="font-family: Arial, serif;"><span style="font-size: small;">/etc/default/tftpd-hpa</span></span>

</td></tr><tr valign="top"><td bgcolor="#ffffff" style="background: #ffffff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="256"><span style="font-family: Arial, serif;"><span style="font-size: small;">Dossier des backups</span></span>

</td><td bgcolor="#ffffff" style="background: #ffffff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="346"><span style="font-family: Arial, serif;"><span style="font-size: small;">/srv/tftp/</span></span>

</td></tr><tr valign="top"><td bgcolor="#f5f9ff" style="background: #f5f9ff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="256"><span style="font-family: Arial, serif;"><span style="font-size: small;">Redémarrer le service</span></span>

</td><td bgcolor="#f5f9ff" style="background: #f5f9ff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="346"><span style="font-family: Arial, serif;"><span style="font-size: small;">systemctl restart tftpd-hpa</span></span>

</td></tr><tr valign="top"><td bgcolor="#ffffff" style="background: #ffffff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="256"><span style="font-family: Arial, serif;"><span style="font-size: small;">Voir les fichiers reçus</span></span>

</td><td bgcolor="#ffffff" style="background: #ffffff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="346"><span style="font-family: Arial, serif;"><span style="font-size: small;">ls -lh /srv/tftp/</span></span>

</td></tr><tr valign="top"><td bgcolor="#f5f9ff" style="background: #f5f9ff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="256"><span style="font-family: Arial, serif;"><span style="font-size: small;">Sauvegarder config routeur</span></span>

</td><td bgcolor="#f5f9ff" style="background: #f5f9ff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="346"><span style="font-family: Arial, serif;"><span style="font-size: small;">copy running-config tftp</span></span>

</td></tr><tr valign="top"><td bgcolor="#ffffff" style="background: #ffffff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="256"><span style="font-family: Arial, serif;"><span style="font-size: small;">Sauvegarder config switch</span></span>

</td><td bgcolor="#ffffff" style="background: #ffffff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="346"><span style="font-family: Arial, serif;"><span style="font-size: small;">copy running-config tftp</span></span>

</td></tr><tr valign="top"><td bgcolor="#f5f9ff" style="background: #f5f9ff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="256"><span style="font-family: Arial, serif;"><span style="font-size: small;">Vérifier port UDP 69</span></span>

</td><td bgcolor="#f5f9ff" style="background: #f5f9ff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="346"><span style="font-family: Arial, serif;"><span style="font-size: small;">ss -ulnp | grep 69</span></span>

</td></tr><tr valign="top"><td bgcolor="#ffffff" style="background: #ffffff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="256"><span style="font-family: Arial, serif;"><span style="font-size: small;">Debug TFTP (Cisco)</span></span>

</td><td bgcolor="#ffffff" style="background: #ffffff; border: 1px solid #cccccc; padding: 0.14cm 0.21cm;" width="346"><span style="font-family: Arial, serif;"><span style="font-size: small;">debug ip tftp</span></span>

</td></tr></tbody></table>