Ci-dessous, les différences entre deux révisions de la page.
| Prochaine révision | Révision précédente | ||
| software:applications:tftpd-hpa:installer_serveur_tftp [2023/12/11 22:22] – créée yoann | software:applications:tftpd-hpa:installer_serveur_tftp [2024/07/22 14:59] (Version actuelle) – [Echec de l'upload] yoann | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| {{tag> | {{tag> | ||
| + | : | ||
| - | ====== tftpd-hpa : Un serveur | + | ====== tftpd-hpa : Un serveur |
| Plusieurs versions de serveurs TFTP ((Trivial File Transfert Protocol)) sont disponibles sur la majorité des distributions GNU/Linux : | Plusieurs versions de serveurs TFTP ((Trivial File Transfert Protocol)) sont disponibles sur la majorité des distributions GNU/Linux : | ||
| Ligne 16: | Ligne 17: | ||
| ===== Installer/ | ===== Installer/ | ||
| + | |||
| + | Via le gestionnaire de paquetage, installer le paquet **tftp-hpa** : | ||
| <code bash> | <code bash> | ||
| Ligne 21: | Ligne 24: | ||
| </ | </ | ||
| - | Le fichier de configuration est minimaliste : | + | < |
| + | Sur certaines distributions, | ||
| + | </ | ||
| + | |||
| + | Pour vérifier l' | ||
| + | <code bash> | ||
| + | systemctl status tftpd-hpa.service | ||
| + | |||
| + | netstat -anpe | grep :69 | ||
| + | </ | ||
| + | |||
| + | Le fichier de configuration | ||
| <file txt tftpd-hpa> | <file txt tftpd-hpa> | ||
| # / | # / | ||
| Ligne 31: | Ligne 45: | ||
| </ | </ | ||
| - | L' | + | L' |
| - | Pour permettre | + | Avec la configuration par défaut, l' |
| + | |||
| + | < | ||
| + | Le service TFTP est peu sûr, il fonctionne sans authentification. Il est donc fortement conseillé : | ||
| + | * de limiter sa portée (autoriser les clients bien connus, les réseaux locaux via le pare-feu) ; | ||
| + | * de limiter son activation (activer le service seulement au besoin). | ||
| + | </ | ||
| + | |||
| + | <code bash> | ||
| + | # Désactive le démarrage automatique du service | ||
| + | systemctl disable tftpd-hpa.service | ||
| + | </ | ||
| + | |||
| + | Pour limiter l' | ||
| + | * soit les règles appropriées du pare-feu ; | ||
| + | * soit s' | ||
| + | |||
| + | < | ||
| + | Sur Ubuntu 20.04 le programme est compilé pour utiliser la base **host_access** : il faut éditer les fichiers / | ||
| + | </ | ||
| + | |||
| + | <file conf hosts.deny> | ||
| + | # / | ||
| + | # See the manual pages hosts_access(5) and hosts_options(5). | ||
| + | # | ||
| + | # Example: | ||
| + | # ALL EXCEPT in.fingerd: other.host.name, | ||
| + | # | ||
| + | # If you're going to protect the portmapper use the name " | ||
| + | # daemon name. See rpcbind(8) and rpc.mountd(8) for further information. | ||
| + | # | ||
| + | # The PARANOID wildcard matches any host whose name does not match its | ||
| + | # address. | ||
| + | # | ||
| + | # You may wish to enable this to ensure any programs that don' | ||
| + | # validate looked up hostnames still leave understandable logs. In past | ||
| + | # versions of Debian this has been the default. | ||
| + | # ALL: PARANOID | ||
| + | |||
| + | # Tout service non explicitement autorisé est bloqué | ||
| + | ALL: ALL | ||
| + | |||
| + | </ | ||
| + | |||
| + | <file conf hosts.allow> | ||
| + | # / | ||
| + | # See the manual pages hosts_access(5) and hosts_options(5). | ||
| + | # | ||
| + | # Example: | ||
| + | # ALL: .foobar.edu EXCEPT terminalserver.foobar.edu | ||
| + | # | ||
| + | # If you're going to protect the portmapper use the name " | ||
| + | # daemon name. See rpcbind(8) and rpc.mountd(8) for further information. | ||
| + | # | ||
| + | in.tftpd: LOCAL 192.168.1.0/ | ||
| + | </ | ||
| + | |||
| + | :TODO: | ||
| + | * Voir pourquoi le service est accessible alors que le pare-feu est paramétré pour interdire l’accès ; | ||
| + | * Voir désactivation du service. | ||
| + | |||
| + | ===== Autoriser l' | ||
| + | |||
| + | Par défaut le serveur TFTP rend accessible ses fichiers aux clients mais ne permet pas la création de nouveau contenu/l' | ||
| + | |||
| + | |||
| + | Si le serveur n'est pas paramétré pour accepter la création de nouveaux fichiers, lors de l' | ||
| + | < | ||
| + | tftp> put prise-A10.txt | ||
| + | Error code 1: File not found | ||
| + | </ | ||
| + | |||
| + | Modifier le fichier de configuration **/ | ||
| + | < | ||
| + | ... | ||
| + | TFTP_OPTIONS=" | ||
| + | </ | ||
| + | |||
| + | Modifier les droits sur le dossier racine du serveur TFTP, l' | ||
| + | |||
| + | < | ||
| + | sudo chown tftp:tftp / | ||
| + | </ | ||
| + | |||
| + | Relancer le service | ||
| + | |||
| + | <code bash> | ||
| + | systemctl restart tftpd-hpa.service | ||
| + | </ | ||
| + | |||
| + | :TODO: | ||
| + | |||
| + | Modifier le masque associé à l' | ||
| + | |||
| + | |||
| + | ===== Pare-feu ===== | ||
| + | |||
| + | Il est possible de spécifier une plage de ports | ||
| + | < | ||
| + | TFTP_OPTIONS=" | ||
| + | </ | ||
| + | |||
| + | Pour pouvoir gérer correctement les connexions, le module **ip_conntrack_tftp** doit être chargé : | ||
| + | |||
| + | <code bash> | ||
| + | modprobe ip_conntrack_tftp | ||
| + | |||
| + | # Vérifier que le module est bien chargé | ||
| + | lsmod | grep -i tftp | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | # Autorise le trafi | ||
| + | </ | ||
| + | |||
| + | |||
| + | < | ||
| + | table ip ipfilter { | ||
| + | comment " | ||
| + | |||
| + | ct helper tftp-standard { | ||
| + | type " | ||
| + | l3proto ip | ||
| + | } | ||
| + | |||
| + | chain PRE { | ||
| + | type filter hook prerouting priority filter; policy accept; | ||
| + | udp dport 69 ct helper set " | ||
| + | } | ||
| + | |||
| + | chain inbound { | ||
| + | comment " | ||
| + | type filter hook input priority filter; policy drop; | ||
| + | ct state invalid counter drop | ||
| + | |||
| + | ct state established, | ||
| + | |||
| + | iif " | ||
| + | |||
| + | udp dport 69 counter accept | ||
| + | ct helper " | ||
| + | |||
| + | |||
| + | log prefix "[FW] [REJECT] [RID=666] " counter reject comment " | ||
| + | } | ||
| + | |||
| + | chain outbound { | ||
| + | comment " | ||
| + | type filter hook output priority filter; policy drop; | ||
| + | |||
| + | ct state established, | ||
| + | |||
| + | log prefix "[FW] [REJECT] [RID=667] " counter reject comment " | ||
| + | } | ||
| + | |||
| + | chain forward { | ||
| + | type filter hook forward priority filter; policy drop; | ||
| + | log prefix "[FW] [REJECT] [RID=668] " counter reject comment " | ||
| + | } | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
| + | ===== Dépannage ===== | ||
| + | |||
| + | ==== Echec de démarrage du service après installation ==== | ||
| + | |||
| + | Le service ne démarre pas à la fin du processus d' | ||
| + | <code bash> | ||
| + | systemctl status tftpd-hpa.service | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | juil. 02 14:31:57 node-7c87 systemd[1]: Starting tftpd-hpa.service - LSB: HPA' | ||
| + | juil. 02 14:31:57 node-7c87 tftpd-hpa[16693]: | ||
| + | juil. 02 14:31:57 node-7c87 systemd[1]: tftpd-hpa.service: | ||
| + | juil. 02 14:31:57 node-7c87 systemd[1]: tftpd-hpa.service: | ||
| + | juil. 02 14:31:57 node-7c87 systemd[1]: Failed to start tftpd-hpa.service - LSB: HPA's tftp server. | ||
| + | </ | ||
| + | |||
| + | Le journal indique également : | ||
| + | <code bash> | ||
| + | | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | juil. 02 14:31:57 node-7c87 in.tftpd[16700]: | ||
| + | juil. 02 14:31:57 node-7c87 in.tftpd[16700]: | ||
| + | juil. 02 14:31:57 node-7c87 systemd[1]: Failed to start tftpd-hpa.service - LSB: HPA's tftp server. | ||
| + | </ | ||
| + | |||
| + | Modifier le fichier **''/ | ||
| + | |||
| + | < | ||
| + | TFTP_USERNAME=" | ||
| + | TFTP_DIRECTORY="/ | ||
| + | TFTP_ADDRESS=" | ||
| + | TFTP_OPTIONS=" | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==== Echec de l' | ||
| + | |||
| + | Toute tentative d' | ||
| + | |||
| + | < | ||
| + | Error code 1: File not found | ||
| + | </ | ||
| + | |||
| + | |||
| + | < | ||
| + | ERROR: transfer fail. | ||
| + | </ | ||
| + | * Vérifier que l' | ||
| + | * Vérifier la présence de l' | ||
| + | voir section [[software: | ||
| ===== Références ===== | ===== Références ===== | ||
| * [[https:// | * [[https:// | ||
| * [[https:// | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * man tftpd | ||
| + | * https:// | ||