Загрузка шаблона операции на сервер проходит по протоколу TFTP. Для этого сервер отправляет запрос на загрузку определённых файлов с TFTP-сервера локации. Из-за ошибки, возникающей в работе некоторых сетевых адаптеров, имена файлов при запросе могут быть искажены. Например, вместо файла pxelinux.0 сервер может запрашивать файл pxelinux.0M-^. В результате сервер не сможет загрузиться, и операция не будет выполнена.
Чтобы избежать этой проблемы, настройте на сервере-локации правила подмены символов (remapping). Если TFTP-сервер получит запрос с искажённым именем файла, то автоматически изменит имя на правильное.
Диагностика
Если проблемы с загрузкой по TFTP связаны с искажением имён файлов, то при загрузке сервера могут появиться сообщения следующего вида:
Примеры сообщений об ошибках
Вы можете посмотреть подробный вывод ошибки на сервере-локации с помощью утилиты tcpdump:
Пример команды для интерфейса enp1s0
tcpdump -i enp1s0 port '(67 or 68 or 69)' -nn -A
CODE
Ответ должен содержать искажённое имя файла. Например, lpxelinux.0M-^.
Пример ответа
07:56:48.433740 IP 192.0.2.93.2070 > 192.0.2.92.69: 34 RRQ "srv1/lpxelinux.0M-^?" octet tsize 0
E..>......k..6[].6[...E.*.R..srv1/lpxelinux.0..octet.tsize.0.
07:56:48.436957 IP 192.0.2.93.2071 > 192.0.2.92.69: 39 RRQ "srv1/lpxelinux.0M-^?" octet blksize 1456
E..C......k..6[].6[...E./fq..srv1/lpxelinux.0..octet.blksize.1456.
CODE
Решение
-
vi /opt/ispsystem/etc/tftp/remap.conf
CODE
Пример файла
rg \ / ri (.*)ÿ$ 1 ri (.*)M-^?$ 1 ri (lpxelinux.0).*$ 1 ri (lpxelinux.efi).*$ 1 ri (syslinux.0).*$ 1 ri (syslinux.efi).*$ 1
CODE
Файл с помощью регулярных выражений описывает действия, которые нужно произвести с неправильными именами. В примере приведены наиболее часто встречающиеся ошибочные имена файлов. Вы можете дополнить этот файл собственными правилами.
-
docker restart tftpd
CODE
Обратите внимание!
Перезапуск TFTP-сервера может прервать запущенные операции.
Contents
Introduction
This document shows the TFTP Error codes.
Prerequisites
Requirements
There are no specific requirements for this document.
Components Used
This document is not restricted to specific software and hardware versions.
Conventions
For more information on document conventions, refer to the Cisco Technical Tips Conventions.
Error Codes
0 Not defined, see error message (if any). 1 File not found. 2 Access violation. 3 Disk full or allocation exceeded. 4 Illegal TFTP operation. 5 Unknown transfer ID. 6 File already exists. 7 No such user.
Refer to the revised RFC 1350 for more information about the TFTP protocol.
Related Information
- Technical Support — Cisco Systems
Ошибка при подключении по TFTP TIMEOUT waiting for Ack block #1
При подключении по TFTP (Tftpd64 Service Edition by Ph. Jounin) возникает следующее сообщение:
Connection received from 10.90.0.3 on port 62204 [01/03 18:43:41.307]
Read request for file <README_FIRST.txt>. Mode netascii [01/03 18:43:41.338]
Using local port 49595 [01/03 18:43:41.338]
Connection received from 10.90.0.3 on port 62204 [01/03 18:43:42.298]
Read request for file <README_FIRST.txt>. Mode netascii [01/03 18:43:42.313]
Using local port 49596 [01/03 18:43:42.313]
Connection received from 10.90.0.3 on port 62204 [01/03 18:43:44.307]
Read request for file <README_FIRST.txt>. Mode netascii [01/03 18:43:44.307]
Using local port 49597 [01/03 18:43:44.307]
Connection received from 10.90.0.3 on port 62204 [01/03 18:43:48.310]
Read request for file <README_FIRST.txt>. Mode netascii [01/03 18:43:48.310]
Using local port 49598 [01/03 18:43:48.310]
Connection received from 10.90.0.3 on port 62204 [01/03 18:43:56.325]
Read request for file <README_FIRST.txt>. Mode netascii [01/03 18:43:56.325]
Using local port 49599 [01/03 18:43:56.325]
TIMEOUT waiting for Ack block #1 [01/03 18:43:56.386]
TIMEOUT waiting for Ack block #1 [01/03 18:43:57.351]
TIMEOUT waiting for Ack block #1 [01/03 18:43:59.346]
TIMEOUT waiting for Ack block #1 [01/03 18:44:03.370]
Из данного лога понятно, что сервер пытается организовать исходящее соединение к клиенту, перебирая порты.
На клиентской стороне видим следующее сообщение:
C:>tftp 10.0.10.10 GET README_FIRST.txt d:TempREADME_FIRST.txt
Timeout occurred
Connect request failed
Проблема в настройках брандмауэра (filewall) на клиентской стороне, т.к. TFTP-сервер организует входящее соединение.
Необходимо добавить разрешающее правило для TFTP-клиента на входящие соединения.
Для этого заходим в настройки Filewall и создаем новое правило:
Тип правила — «Для программы» (Program):
Для TFTP Клиента (TFTP Client), входящего в состав Windows необходимо добавить следующий путь:
%WinDir%System32TFTP.EXE
Или, например, так:
«C:WindowsSystem32TFTP.EXE»
Если используется другой TFTP-клиент, то надо указать соответствующий путь к его исполняемому файлу:
Далее «Разрешить подключение» (Allow the connection):
Выбираем все профили:
В конце задаем имя правилу:
После данной настройки успешное соединение будет выглядеть примерно так:
C:tftp 10.0.10.10 GET README_FIRST.txt d:TempREADME_FIRST.txt
Transfer successful: 522 bytes in 1 second(s), 522 bytes/s
(с) Ella S.
Если Вам понравилась статья, пожалуйста, поставьте лайк, сделайте репост или оставьте комментарий. Если у Вас есть какие-либо замечания, также пишите комментарии.
-
crazyfa
- Сообщения: 25
- Зарегистрирован: Ср окт 10, 2012 11:47 am
Проблема с загрузкой TFTP
Иногда сама по себе всплывает вот такая вот проблема с загрузкой , так же сама по себе и уходит . Не очень приятно что никак выявить причину не удается, поэтому выкладываю лог в надежде на какие нибудь советы, по логу в принципе все ясно, но не понятно почему так. При чем грузятся все по разному от 2 до 10 мин, есть и такие что как и раньше моментально. Может быть конечно проблема с сетью , но после загрузки все ровно работает, потерь нет
Лог в ручную чуть почистил т.к. «слишком большой файл для загрузки» , просто вырезал строчки которые повторяются меняются только цифры..
11-20-29-453| [TFTP] Incorrect ACK received (expected 83, received 82).
11-20-29-453| [TFTP] Timeout occured while transfer «5.8.10packageskernel».
11-20-29-453| [TFTP] Resend block 83.
до
11-24-19-375| [TFTP] Timeout occured while transfer «5.8.10packageskernel».
11-24-19-375| [TFTP] Resend block 3928.
- Вложения
-
- WTware_60.02.92.64.07.92_2019-10-16_11-41-52.txt
- (222.09 КБ) 791 скачивание
-
aka
- Разработчик
- Сообщения: 11610
- Зарегистрирован: Ср окт 01, 2003 12:06 am
- Откуда: Роcсия, Тольятти
-
Контактная информация:
Re: Проблема с загрузкой TFTP
Сообщение
aka » Ср окт 16, 2019 12:35 pm
Физическая сеть теряет пакеты. Провода, розетки, свичи, наука о контактах. Программно не лечится.
-
AlexPetrov
- Сообщения: 11
- Зарегистрирован: Пн окт 14, 2019 4:12 pm
Re: Проблема с загрузкой TFTP
Сообщение
AlexPetrov » Чт дек 19, 2019 12:48 pm
Периодически всплывает проблема с загрузкой по сети WTware на Raspberry Pi 3 B+. Помогает только многократная перезагрузка Raspberry Pi.
В логах проблема выглядит так:
10-54-11-546| [192.168.10.110] «0ca90504fixup.dat»: tsize is requested, blksize default.
10-54-11-546| [192.168.10.110] «0ca90504fixup.dat»: «C:Program Files (x86)WTwareTFTPDROOT5.8.68pi2localbootfixup.dat».
10-54-11-546| [192.168.10.110] «0ca90504fixup.dat»: completed.
10-54-13-546| [192.168.10.110] Timeout occured while transfer «0ca90504start.elf».
10-54-13-546| [192.168.10.110] Resend block 3774.
10-54-15-561| [192.168.10.110] Timeout occured while transfer «0ca90504start.elf».
10-54-15-561| [192.168.10.110] Resend block 3774.
10-54-17-561| [192.168.10.110] Timeout occured while transfer «0ca90504start.elf».
10-54-17-561| [192.168.10.110] Resend block 3774.
10-54-19-561| [192.168.10.110] Timeout occured while transfer «0ca90504start.elf».
10-54-19-561| [192.168.10.110] Resend block 3774.
10-54-21-561| [192.168.10.110] Timeout occured while transfer «0ca90504start.elf».
10-54-21-561| [192.168.10.110] Resend block 3774.
10-54-23-561| [192.168.10.110] Timeout occured while transfer «0ca90504start.elf».
10-54-23-561| [192.168.10.110] Resend block 3774.
10-54-25-577| [192.168.10.110] Timeout occured while transfer «0ca90504start.elf».
10-54-25-577| [192.168.10.110] Resend block 3774.
10-54-27-593| [192.168.10.110] Timeout occured while transfer «0ca90504start.elf».
10-54-27-593| [192.168.10.110] Resend block 3774.
10-54-29-593| [192.168.10.110] Timeout occured while transfer «0ca90504start.elf».
10-54-29-593| [192.168.10.110] Resend block 3774.
10-54-31-609| [192.168.10.110] Timeout occured while transfer «0ca90504start.elf».
10-54-31-609| [192.168.10.110] Client not responding. Connection closed.
или так:
11-31-46-704| [TFTP] «0ca90504kernel7.img»: tsize is requested, blksize default.
11-31-46-704| [TFTP] «0ca90504kernel7.img»: «C:Program Files (x86)WTwareTFTPDROOT5.8.68pi2localbootkernel7.img».
11-31-50-283| [TFTP] Timeout occured while transfer «0ca90504kernel7.img».
11-31-50-283| [TFTP] Resend block 2233.
11-31-52-283| [TFTP] Timeout occured while transfer «0ca90504kernel7.img».
11-31-52-283| [TFTP] Resend block 2233.
11-31-54-283| [TFTP] Timeout occured while transfer «0ca90504kernel7.img».
11-31-54-283| [TFTP] Resend block 2233.
11-31-56-298| [TFTP] Timeout occured while transfer «0ca90504kernel7.img».
11-31-56-298| [TFTP] Resend block 2233.
11-31-58-298| [TFTP] Timeout occured while transfer «0ca90504kernel7.img».
11-31-58-298| [TFTP] Resend block 2233.
11-32-00-314| [TFTP] Timeout occured while transfer «0ca90504kernel7.img».
11-32-00-314| [TFTP] Resend block 2233.
11-32-02-314| [TFTP] Timeout occured while transfer «0ca90504kernel7.img».
11-32-02-314| [TFTP] Resend block 2233.
11-32-04-330| [TFTP] Timeout occured while transfer «0ca90504kernel7.img».
11-32-04-330| [TFTP] Resend block 2233.
11-32-06-330| [TFTP] Timeout occured while transfer «0ca90504kernel7.img».
11-32-06-330| [TFTP] Resend block 2233.
11-32-08-330| [TFTP] Timeout occured while transfer «0ca90504kernel7.img».
11-32-08-330| [TFTP] Client not responding. Connection closed.
На сниффере, снимающему трафик с порта, к которому подключен Raspberry Pi, видно, что от WTware на Raspberry Pi, просто перестают приходить TFTP Acknowledgement.
-
aka
- Разработчик
- Сообщения: 11610
- Зарегистрирован: Ср окт 01, 2003 12:06 am
- Откуда: Роcсия, Тольятти
- Контактная информация:
Re: Проблема с загрузкой TFTP
Сообщение
aka » Чт дек 19, 2019 3:49 pm
TFTP сервер перепосылает пакет. Подтверждения приёма (Acknowledgement) от клиента нет. В TFTP обмен пакетами по очереди идёт: пакет с данными от сервера, подтверждение от клеинта, спосле опдтверждения следующий пакет с данными от сервера.
Вероятно, пакет теряется из-за неисправности физической сети, или если между клиентом и сервером есть роутер — он может резать.
-
AlexPetrov
- Сообщения: 11
- Зарегистрирован: Пн окт 14, 2019 4:12 pm
Re: Проблема с загрузкой TFTP
Сообщение
AlexPetrov » Чт дек 19, 2019 4:34 pm
Вам не кажется, что вы сами себе противоречите?
aka писал(а): ↑
Чт дек 19, 2019 3:49 pm
TFTP сервер перепосылает пакет. Подтверждения приёма (Acknowledgement) от клиента нет.
aka писал(а): ↑
Чт дек 19, 2019 3:49 pm
В TFTP обмен пакетами по очереди идёт: пакет с данными от сервера, подтверждение от клиента, после подтверждения следующий пакет с данными от сервера.
Я для чего выложил скриншот сниффера, на котором продемонстрирован пример возникающей проблемы? Видно же, что начиная с 2233 блока подтверждения перестают отравляться в сторону сервера.
aka писал(а): ↑
Чт дек 19, 2019 3:49 pm
Вероятно, пакет теряется из-за неисправности физической сети, или если между клиентом и сервером есть роутер — он может резать.
Напомню, сниффер снимает данные с порта коммутатора, к которому подключено WTwarе на RPI.
Где вы видите потерю пакетов на сети? На скриншоте же видно, что все пакеты от сервера TFTP до порта коммутатора, к которому подключено WTwarе на RPI, успешно дошли. Проблема в том что WTwarе на RPI перестал отправлять на сервер подтверждения приема пакетов.
-
aka
- Разработчик
- Сообщения: 11610
- Зарегистрирован: Ср окт 01, 2003 12:06 am
- Откуда: Роcсия, Тольятти
- Контактная информация:
Re: Проблема с загрузкой TFTP
Сообщение
aka » Чт дек 19, 2019 4:48 pm
AlexPetrov писал(а): ↑
Чт дек 19, 2019 4:34 pm
Вам не кажется, что вы сами себе противоречите?
Нет.
AlexPetrov писал(а): ↑
Чт дек 19, 2019 4:34 pm
Я для чего выложил скриншот сниффера, на котором продемонстрирован пример возникающей проблемы? Видно же, что начиная с 2233 блока подтверждения перестают отравляться в сторону сервера.
Да. Сервер свой пакет отправляет. Дальше этот пакет либо не доходит до клиента, теряется по дороге. Порт коммутатора, проводка от коммутатора до малины тоже могут быть неисправны.
Либо клиент ломается и не отвечает.
Либо клиент посылает ответ, но ответ не доходит до сервера, тебяется по дороге.
В любом случае это проблема или сети, или клиента. Со стороны сервера её не исправить.
AlexPetrov писал(а): ↑
Чт дек 19, 2019 4:34 pm
Напомню, сниффер снимает данные с порта коммутатора, к которому подключено WTwarе на RPI.
Где вы видите потерю пакетов на сети? На скриншоте же видно, что все пакеты от сервера TFTP до порта коммутатора, к которому подключено WTwarе на RPI, успешно дошли. Проблема в том что WTwarе на RPI перестал отправлять на сервер подтверждения приема пакетов.
На RPI в это время ещё нет никакого WTware. kernel7.img — это первый файл, в котором есть немного нашего кода, и он так и не догружается. Всё, что работает в это время на малине, сделано малиновыми разработчиками, мы знаем о нём не сильно больше вас, исходники малиновых загрузчиков закрыты.
-
AlexPetrov
- Сообщения: 11
- Зарегистрирован: Пн окт 14, 2019 4:12 pm
Re: Проблема с загрузкой TFTP
Сообщение
AlexPetrov » Чт дек 19, 2019 5:02 pm
Давайте подведем итог, как решить проблему? Я так понимаю, 100% гарантия работы будет только если использовать SD карту. Без SD карты вы ничего не гарантируете, т.к. на этапе загрузки по сети работает не ваш (а малиновый) софт, а за него вы не отвечаете.
-
aka
- Разработчик
- Сообщения: 11610
- Зарегистрирован: Ср окт 01, 2003 12:06 am
- Откуда: Роcсия, Тольятти
- Контактная информация:
Re: Проблема с загрузкой TFTP
Сообщение
aka » Чт дек 19, 2019 5:13 pm
Дело же не в том, что «мы за него не отвечаем». Мы не имеем возможности его менять. Этот софт раздают разработчики малины готовым, откомпилированным, без исходников. Как BIOS в обычных компьютерах.
-
aka
- Разработчик
- Сообщения: 11610
- Зарегистрирован: Ср окт 01, 2003 12:06 am
- Откуда: Роcсия, Тольятти
-
Контактная информация:
Re: Проблема с загрузкой TFTP
Сообщение
aka » Чт дек 19, 2019 5:21 pm
Да. Загрузка по сети у малин работает в самых простых сетях: сервер — тупой свич — клиент. Если сеть сложнее, начинаются капризы, и нет никакой возможности их чинить.
In this article, we will focus on how to troubleshoot the common Trivial File Transfer Protocol (TFTP) issues with Wireshark between server and client.
What is TFTP?
TFTP is a file transfer protocol that enables a client to upload a file to a server or download a file from the server. The protocol is simple and designed to be implemented in ROM for booting diskless systems like X terminals, diskless workstations, and routers. It was planned to be small and easy to implement. Therefore, it lacks most of the features of a regular FTP. The protocol is only capable of reading and writing files (or mail) from/to a remote server. It cannot list directories, and currently has no provisions for user authentication.
ALSO READ: How to do TCP Retransmission Analysis using Wireshark
TFTP Packet Types
TFTP packets are transferred over User Datagram Protocol (UDP), which is an unreliable transport protocol. In other words, UDP provides no recovery for lost packets. To fix this problem, TFTP uses a mechanism like TCP ACK and provides reliability in application layer. Any transfer begins with a request to read or write a file and then the data packets are sent in fixed length, which is called a block. Each data packet contains only one block of data, and is acknowledged by an acknowledgment packet before the next packet can be sent.
TFTP supports 6 packet types:
Following steps show a typical file transfer and packet types used between the client and server.
Packet flow of File Transfer between TFTP Server and Client
Step-1: The client sends a read request for “startup-config” file and asks server to use block size of 128 bytes.
Step-2: The server replies with an Option ACK packet, which includes the block size accepted by the server and the size of the file to be transferred.
Step-3: After acknowledging the options, the server sends the first block (packet) of the data.
Step-4: The client acknowledges the first block of the data and the file transfer follows the same pattern (sending data and expecting an ack) until it is transferred completely.
ALSO READ: Analyze TCP Receive Window with Wireshark [Step-by-Step]
Troubleshooting TFTP Errors
During a file transfer, errors may occur and RFC 1350 defines 8 error codes for identifying the problems. The codes and their brief explanations are below.
TFTP errors are caused by three types of events:
- Not being able to satisfy the request (e.g., file not found, access violation, or no such user).
- Receiving a packet which cannot be explained by a delay or duplication in the network (e.g., an incorrectly formed packet).
- Losing access to a necessary resource (e.g., disk full or access denied during a transfer).
TFTP issues can be categorized into 2 groups:
- Client or server related issues
- Network related issues
We will mainly focus on the first category. TFTP peers use Opcode 5 to inform each other when they come across an error. Each error packet has an error code and error message. Following figure shows a typical error packet format.
Understanding different TFTP Error Codes
We will produce the TFTP errors and analyze them with Wireshark.
Error Code 0 (Not defined, see error message (if any))
This is a general error code. When the client or server can’t identify the error, it replies with this error code and includes more details in the error message. Following screenshot shows the error.
ALSO READ: Breaking down HTTP response at Packet Level [Wireshark Tutorial]
To produce this error, I dropped TFTP packets on the firewall purposely. The client (192.168.1.50) requested for “test.txt” file and did not receive any response from the server. Since the packet filtering on the network was the cause of the problem, the client could not categorize the error and sent this general error. Even though there is no error code in the RFC to define this problem, the client puts some reasonable information in the “Error message”, which is “timeout on receive” in this case. Unfortunately, not all TFTP clients send this error, which makes it hard to resolve the problems.
Error Code 1 (File not found)
The client receives this error code when the requested file does not exist. As seen below, the error message is also enough to define the problem. This is clearly not a network related problem. When getting this error, we should check the file path and name of the file to see if it is correct or not.
Error Code 2 (Access violation)
This error is seen when we ask for a file on which we do not have the right to read or write. I produced this error with trying to transfer (write) a file to the server while I did not have that right (writing). A TFTP server can let you change security settings like reading, writing or both of them.
ALSO READ: Learn How to Use Wireshark like a PRO
Error Code 3 (Disk full or allocation exceeded)
TFTP client receives this error when there is limited storage area on the server. I produced this error with limiting the quota for the folder and then transferring a larger file than the reserved quota.
Error Code 4 (Unknown transfer ID)
Any TFTP packet does not follow the RFC is called illegal. A packet with an unknown opcode, a packet with a malformed payload, or a packet that is out of sequence with the normal flow of commands/responses would all be considered «illegal». I produced this error with crafting a TFP data packet and sending it to the server without sending a read or write request in the beginning.
Error Code 5 (Unknown transfer ID)
When a TFTP client sends a duplicate read request (typically this happens when the first read request times out), the requests may create an unexpected situation on the server. The server thinks it received different requests from the client and responds accordingly. When the client notices the server interpreted the duplicate packets as different requests, it sends this error to the server, which does not cause a termination. After receiving this error, the server immediately stops the other transferring. I was not be able to produce this error code.
ALSO READ: Analyse Slow Networks with TCP Zero Window — Wireshark
Error Code 6 (File already exists)
This error is received when there is a file with the same name on the server. I produced this file with transferring the same file to the server.
Error Code 7 (No such user)
Once the protocol was first adopted, it supported three modes of transferring, which were netascii, octet and mail mode, which was used for sending files to an email address. This error is received when the recipient username does not exist on the server. This mode is not used anymore.
Error Code 8 (Terminate transfer due to option negotiation)
TFTP client and server negotiate options during a read or write request. When the negotiations fail, the peer sends this error code to terminate the transfer. I produced this error with sending some option that server did not support. As seen below, Wireshark is not able to decode this new error properly.
Network Related TFTP Issues
TFTP uses port 69 as its destination when making a read or write request. After receiving the request, the server uses a random port for the transfer instead of answering from port 69. Even if you allow port 69 on the firewall, the transfer may fail due to not inspecting TFTP as service (protocol). Most common network failures happen because of firewall policy. Following screenshot shows a typical file transfer in perspective of using ports.
ALSO READ: Detect Rogue DHCP Server with Wireshark [Step-by-Step]
TFTP server and client generally use block size of 512 bytes on default. For faster transmission, we may need to set the size to a higher value, which may fail the transfer when the data packets size exceeds the path MTU size.
Packet loss in the network is another factor that can disrupt TFTP transfer.
Final Thoughts
It is easy to troubleshoot when the problem caused by either TFTP client or server. With using Wireshark’s “tftp.opcode == 5” display filter, we can list all TFTP errors and inspect them. Some network issues may not be identified by only using this filter. We need a network trace file from both of the side to have a better observation.
References
https://docstore.mik.ua/orelly/networking_2ndEd/fire/ch17_02.htm
https://datatracker.ietf.org/doc/html/rfc783
Related Keywords: Not defined, File not found, Access violation, Disk full or allocation exceeded, Unknown transfer ID, Unknown transfer ID, File already exists, No such user, Terminate transfer due to option negotiation, troubleshoot tftp errors with wireshark