We have by far the largest RPM repository with NGINX module packages and VMODs for Varnish. If you want to install NGINX, Varnish, and lots of useful performance/security software with smooth yum
upgrades for production use, this is the repository for you.
Active subscription is required.
Operating System and Software
- Rocky Linux 8
Problem
-
On a default installation of TFTP server, using
get
to retrieve files fails withError code 2: xxxx
-
Attempt to retrieve a file using the relative path fails with
Error code 2: Only absolute filenames allowed
.
# tftp localhost
tftp> get testfile
Error code 2: Only absolute filenames allowed
- Attempt to retrieve a file using the absolute path fails with
Error code 2: Forbidden directory
.
tftp> get /var/lib/tftpboot/testfile
Error code 2: Forbidden directory
How to Fix
- The default installation of
tftp-server
on Rocky Linux 8 usessystemd
instead ofxinetd
and does not require a config file to run. - Inspect any existing config files in
/etc/xinetd.d
. - In this instance, a config file for
ftpd
was present in/etc/xinetd.d/ftpd
. This interfered withtftpd
and resulted in the errors displayed. - Removing the
ftpd
config file then restartingxinetd
resolved the issue.
Origin of the Problem
- An existing config file for
ftpd
was present in/etc/xinetd.d/ftpd
.
Diagnostic Steps
- Install
tftp-server
andtftp
packages on Rocky Linux 8.
# dnf install tftp-server tftp
- Start
tftp
server.
# systemctl start tftp
# systemctl status tftp
tftp.service - Tftp Server
Loaded: loaded (/usr/lib/systemd/system/tftp.service; indirect; vendor preset: disabled)
Active: active (running) since Thu 2020-07-09 10:46:07 BST; 5min ago
Docs: man:in.tftpd
Main PID: 27056 (in.tftpd)
Tasks: 1 (limit: 11482)
Memory: 376.0K
CGroup: /system.slice/tftp.service
└─27056 /usr/sbin/in.tftpd -s /var/lib/tftpboot
Jul 09 10:46:07 hostname.example.net systemd[1]: Started Tftp Server.
- Create test file in the default directory
/var/lib/tftpboot
# touch /var/lib/tftpboot/testfile
- Check UDP port for
tftpd
is listening. This issue will only reproduce if the first entry displays the name of the servicein.tftpd
andxinetd
# ss -pluton | grep ":69"
udp UNCONN 0 0 0.0.0.0:69 0.0.0.0:* users:(("in.tftpd",pid=10350,fd=0),("xinetd",pid=998,fd=6))
udp UNCONN 0 0 *:69 *:* users:(("systemd",pid=1,fd=220))
- Attempt to retrieve a file using the relative path fails with
Error code 2: Only absolute filenames allowed
.
# tftp localhost
tftp> get testfile
Error code 2: Only absolute filenames allowed
- Attempt to retrieve a file using the absolute path fails with
Error code 2: Forbidden directory
.
tftp> get /var/lib/tftpboot/testfile
Error code 2: Forbidden directory
0
1
Здравствуйте! Я хочу чтобы файл test, мой tftp сервер отдавал мне при всех комбинациях слова test вне зависимости от регистра, т.е. Test, TEST, TeSt, TEst и т.д. Насколько мне известно любой сервер tftp под Linux чувствителен к регистру, но есть один tftp сервер tftp-hpa, для которого можно создать правила замены символов, которые содержатся в строке запроса. Т.о. я решил создать правила, которые заменяют все заглавные буквы на строчные. Например если я делаю запрос get TeSt, то сервер заменит слово TeSt на test, а именно первую и третью букву T->t и S->s и я естественно получу свой файл.
Что я делаю:
1. Установил Ubuntu Server 10.10
2. Установил Samba (sudo apt-get install samba)
3. Настроил Samba. Содержимое /etc/smb.conf:
[global]
workgroup = WORKGROUP
security = share
[tftp]
path = /srv/tftp
guest only = yes
writeable = yes
4. Создал директорию и дал права доступа 777 и владельца nobody (sudo mkdir -m 777 /srv/tftp и sudo chown nobody /srv/tftp)
5. Установил tftp-hpa (sudo apt-get install tftp-hpa tftpd-hpa)
6. Настроил tftp-hpa. Содержимое /etc/default/tftpd-hpa:
# /etc/default/tftpd-hpa
TFTP_USERNAME=«tftp»
TFTP_DIRECTORY=«/srv/tftp»
TFTP_ADDRESS=«0.0.0.0:69»
#TFTP_OPTIONS=»—security»
7. Проверил работоспособность tftp сервера. Создал файл test в /srv/tftp (права доступа и владелец = 777 и nobody). Далее
tftp localhost
get test
Все работает. Файл был успешно передан в мою директорию. Содержимое не пострадало. Пробую получить get Test, сервер его естественно не находит т.к. правил я еще не создал.
8. Создаю файл tftpd.rules (т.е. правила замены) со следующим содержанием:
rg \ /
rg A a
rg B b
rg C c
rg D d
rg E e
rg F f
rg G g
rg H h
rg I i
rg J j
rg K k
rg L l
rg M m
rg N n
rg O o
rg P p
rg Q q
rg R r
rg S s
rg T t
rg U u
rg V v
rg W w
rg X x
rg Y y
rg Z z
Кладу его в каталог /etc (хотя не важно как он будет называться и где он будет лежать если я правильно понимаю)
9. Редактирую /etc/default/tftpd-hpa:
# /etc/default/tftpd-hpa
TFTP_USERNAME=«tftp»
TFTP_DIRECTORY=«/srv/tftp»
TFTP_ADDRESS=«0.0.0.0:69»
#TFTP_OPTIONS=»-m /etc/tftpd.rules»
10. Перезапускаю сервер (sudo restart tftpd-hpa)
11. Проверяю работоспособность п.7 и получаю в ответ ошибку:
Error code 2: Only absolute filenames allowed
12. Редактирую /etc/default/tftpd-hpa:
# /etc/default/tftpd-hpa
TFTP_USERNAME=«tftp»
TFTP_DIRECTORY=«/srv/tftp»
TFTP_ADDRESS=«0.0.0.0:69»
#TFTP_OPTIONS=»—security»
13. Перезапускаю сервер (sudo restart tftpd-hpa)
14. Проверяю работоспособность п.7 и получаю в ответ ошибку:
Error code 2: Only absolute filenames allowed
В чем подвох не могу понять. Пожалуйста помогите!
Issue
-
On a default installation of TFTP server, using
get
to retrieve files fails withError code 2: xxxx
-
Attempt to retrieve a file using the relative path fails with
Error code 2: Only absolute filenames allowed
.
# tftp localhost
tftp> get testfile
Error code 2: Only absolute filenames allowed
- Attempt to retrieve a file using the absolute path fails with
Error code 2: Forbidden directory
.
tftp> get /var/lib/tftpboot/testfile
Error code 2: Forbidden directory
Environment
- Red Hat Enterprise Linux 8
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.
Current Customers and Partners
Log in for full access
Log In
Появилась необходимость поднять в сети сервер TFTP (Trivial File Transfer Protocol — простой протокол передачи файлов. В отличие от FTP, он не содержит возможности аутентификации и основан на транспортном протоколе UDP). Он понадобился для закачки новых версий прошивок на cisco-роутеры, cisco-телефоны, маршрутизаторы dell и 3com, для выполнения автоматического сохранения конфигурация различного сетевого оборудования.
______________________
За основу была взята статья Алексея Цветного с сайта OpenNET.
Мой TFTP-сервер будет работать под управлением FreeBSD 7.2-RELEASE и представлять собой пакет tftp-hpa-0.49.
(после нескольких “гневных” отзывов, что приведенный ниже алгоритм не работает, несколько переделал статью. теперь все написанное справедливо для FreeBSD 8.4, 10.0, 10.1 (такие системы в моём подчинении) с установленным пакетом tftp-hpa
# pkg info | grep tftp tftp-hpa-5.2 Advanced tftp server
а на самом деле вся беда заключалась в неправильных кавычках в скрипте запуска…)
Установка порта tftp-hpa:
# cd /usr/ports/ftp/tftp-hpa/ # make config # make install clean
Так как tftp-сервер будет запускаться как самостоятельный сервис, для увеличения безопасности необходимо создать непривилегированного пользователя, от имени которого будут запускаться все дочерние процессы, а так же его группу. Добавляем новую группу:
# pw groupadd tftpd
Добавляем нового пользователя:
# pw useradd tftpd -c tftp_manager -d /nonexistent -g tftpd -s /usr/sbin/nologin
Проверяем:
# vipw # $FreeBSD: src/etc/master.passwd,v 1.40.20.1 2009/04/15 03:14:26 kensmith Exp $ # ... tftpd:*:1005:1004::0:0:tftp_manager:/nonexistent:/usr/sbin/nologin ...
Выход из текстового редактора vi :q
+ ввод.
Теперь необходимо создать рабочий каталог, в который будет осуществляться chroot и где будут храниться необходимые нам файлы. Пусть это будет /home/tftp
# mkdir /home/tftp
Дадим права доступа на него для только что созданных пользователя и группы, а так же запретим другим непривилегированным пользователям доступ в этот каталог:
# chown tftpd:tftpd /home/tftp # chmod 750 /home/tftp
По-умолчанию все протоколирование будет вестись в файл лог /var/log/xferlog
.
Теперь создадим конфигурационный файл обработки скачиваемых/закачиваемых файлов. Для безопасности все имена файлов прозрачно будут преобразовываться при записи из ИМЯ в IP-ИМЯ, а при чтении наоборот – из IP-ИМЯ в ИМЯ. Это позволит ограничить доступ к файлам, основываясь на IP-адресе клиента. Т.е. одно и тоже имя файла от абсолютно разных хостов на сервере будет сохраняться под разными именами и у каждого хоста будет доступ только к своей копии файла.
# touch /usr/local/etc/tftpd-remap.conf # chmod 440 /usr/local/etc/tftpd-remap.conf # chown tftpd:tftpd /usr/local/etc/tftpd-remap.conf
Добавьте в этот файл /usr/local/etc/tftpd-remap.conf с помощью вашего любимого текстового редактора следующие строки:
# Rename all files # If WRQ: filename -> IP-filename # If RRQ: IP-filename -> filename r .* i-
Теперь необходимо переделать стартовый скрипт tftp-hpa под наши нужды. Скопируйте существующий скрипт /usr/local/etc/rc.d/tftpd
куда-нибудь и внесите в него следующие изменения (напоминаю, что все кавычки – прямые "
!):
#!/bin/sh # PROVIDE: tftpd # REQUIRE: DAEMON # BEFORE: LOGIN # KEYWORD: shutdown . /etc/rc.subr name=“tftpd” rcvar=tftpd_enable load_rc_config $name : ${tftpd_enable=“NO”} : ${tftpd_pidfile=”/var/run/tftpd.pid”} : ${tftpd_remapfile=”/usr/local/etc/tftpd-remap.conf”} : ${tftpd_datadir=”/home/tftp”} : ${tftpd_flags=”-vcps -u tftpd -U 037 -B 1468”} extra_commands=“reload” start_cmd=“tftpd_start” stop_postcmd=“tftpd_poststop” reload_cmd=“tftpd_reload” required_files=”/usr/local/etc/tftpd-remap.conf” pidfile=$tftpd_pidfile procname=”/usr/local/libexec/in.tftpd” tftpd_start() { /bin/echo -n “Starting tftpd” /usr/local/libexec/in.tftpd $tftpd_flags -l -m $tftpd_remapfile $tftpd_datadir /bin/ps x | /usr/bin/grep in.tftpd | /usr/bin/grep -v grep | /usr/bin/awk ‘{print $1}’ > $tftpd_pidfile /bin/echo “.” } tftpd_poststop() { /bin/rm -f $tftpd_pidfile } tftpd_reload() { /bin/kill -1 `cat $tftpd_pidfile` } run_rc_command “$1”
Нам осталось разрешить запуск этого скрипта в /etc/rc.conf
, добавив в него следующие строчки:
tftpd_enable="YES" tftpd_flags="-4 -vcps -u tftpd -U 037 -B 1468"
И конечно же, если у вас работает файервол, надо разрешить в его настройках доступ к вашему tftp-серверу. Я использую pf и мои настройки выглядят так:
#tftp pass in quick on $int_if proto {tcp,udp} from $int_net to $int_addr port 69 pass in quick on $int_if proto {tcp,udp} from $int_net to $int_addr port {1024:65535} pass in quick on $ext_if proto {tcp,udp} from $some_host to $ext_addr port 69 pass in quick on $ext_if proto {tcp,udp} from $some_host to $ext_addr port {1024:65535}
Где:
- $int_if – внутренний интерфейс сервера;
- $ext_if – внешний интерфейс сервера;
- $int_net – внутренняя сеть (которой вы доверяете);
- $int_addr – внутренний ip-адрес;
- $ext_addr – внешний ip-адрес;
- $some_host – некоторый внешний хост, который будет работать с вашим tftp-сервером.
Теперь запустим наш tftp-сервер:
# /usr/local/etc/rc.d/tftpd start Starting tftpd.
Проверим, что демон работает:
# ps -x | grep tftp | grep -v grep 24600 ?? Is 0:00,00 /usr/local/libexec/in.tftpd -4 -vcps -u tftpd -U 037 -B 1468 -l -m /usr/local/etc/tftpd-remap.conf /home/tftp
Если вы увидели что-то подобное – значит все работает. Попробуйте что-нибудь записать на ваш tftp-сервер. В каталоге /home/tftp
вы увидите файл, преобразованный в вид ipадрес-имяфайла. Например, вы копировали running-config с маршрутизатора cisco с ip-адресом 192.168.0.1 на tftp-сервер с ip-адресом 192.168.0.2
cisco#copy running-config tftp://192.168.0.2 Address or name of remote host [192.168.0.2]? Destination filename [cisco-confg]? !! 2032 bytes copied in 1.408 secs (1434 bytes/sec) cisco#
На вашем tftp-сервере в каталоге /home/tftp
появится файл с именем 192.168.0.1-cisco-confg.
Если вам наоборот, необходимо скопировать с вашего tftp-сервера какой-нибудь файл, переименуйте его в вид ipадресс-имяфала. Только так к нему получит доступ сетевое устройство по tftp-протоколу. В противном случае вы будете получать на нем ошибку вида:
error code 2 received - Only absolute filenames allowed
Вот в принципе и все. Удачи!
TFTP server
Build a TFTP server
1. Online installation
First install the TFTP server
apt-get install tftpd-hpa
Install the TFTP client
apt-get install tftp-hpa
Enter all the way or press Y, it has been installed here
2. Modify TFTPD-HPA configuration file
gedit(vi) /etc/default/tftp-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/root/tftpboot"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="-l -c -s"
Just save it after modification
3. Create a new TFTPBOOT directory in the root directory
mkdir tftpboot
Don’t write the name wrong, and it is best to create in the root directory
4. Restart the TFTPD-HPA service
sudo service tftp-hpa restart
If you or not to add Sudo, you can do it
5. Use TFTP service
tftp 192.168.*.*
The next two*represent the IP address to be connected
For example, TFTP 192.168.0.101 is the IP address of the lower machine of our computer room
In this way, even if the connection is established, then you can transmit files by related instructions
Common error treatment
1 、Transfer timed out
Reason: TFTPD service is not started
Solution: Start the service
sudo /etc/init.d/tftpd-hpa restart
2、Error code 2:Only absolute filenames allowed
Reason: Configure errors in/etc/default/tftp-hpa
Solution: configuration referenceModify the TFTPD-HPA configuration file
3、Error code 1:File not found
Reason: The specified file does not exist; or there is no specified -C option in the TFTPD startup parameter, allowing upload file ~ When uploading
4、tftp::Permission denied
Reason: Insufficient permissions
See if chmod is not configured well
for example
View the current files have these files, some files are green, and some are white. We choose the test.c in it to check the permissions
By using ll test.c, we can see that the authority of the test.c is -RW -R -R—
Permissions are divided into r (read) w (writing) x (execution)
Express the permissions by the eight -to -order number
For example, the value of RW is 4+2 = 6.readandWritepermission
The value of RWXR-XR-X is 755
Note that each three are in a group, which is equivalent to R (4) w (2) x (1) | r (4) -x (1) | r (4) -x (1)
The three groups represent User 、Group 、Others permission
So the three groups of permissions are respectivelyReading+writing+execution (4+2+1), reading+execution (4+1), reading+execution (4+1)
Solution: CHMOD 744 file name, that is, that is,Set up read+write+execution permissions for filesThe default authority of the file is 644, which is only the permissions of reading and writing
chmod 744 filename
At this time, Test.c has execution permissions. Of course, here just find a file as an example. Test.c itself cannot be executed directly.
In the same way, I want to convert the test.c file to the original appearance to use chmod 644 test.c
n00b
Joined: 02 Sep 2003
Posts: 32
|
|
|
|
Hi all,
I emerged tftp then i try to save a file from a cisco switch to my gentoo tftp server. cisco says: tftp error 2 , only absolute filenames allowed. when i do it from my tftp server: tftp>connect x.x.x.x transfer timed out ??? What am i doing wrong most be something simple. if got no iptables running because i am on the local network together with the switch. doing nmap i see that udp port 69 is open, sooo anyone? |
Apprentice
Joined: 15 Apr 2004
Posts: 189
n00b
Joined: 02 Sep 2003
Posts: 32
|
|
|
|
but is this program ftp server program, not a tftp server program?
i think its a ftp server |
l33t
Joined: 23 Jun 2003
Posts: 943
n00b
Joined: 02 Jun 2004
Posts: 68
|
||||||
|
||||||
hi,
i have the same problem, currently using tftp-hpa. the tftp-server is running, but I can’t get no file. requestion-result is
, altough my /tftpboot directory is world readable. here’s my complete /etc/xinetd.d/tftp
and here my /etc/conf.d/in.tftpd
any idea what is missing? thanks in advance hopefully yours, tom |
n00b
Joined: 24 May 2004
Posts: 61
Location: Shelburne, VT
|
|
|
|
I did a fresh emerge of tftp-hpa and the initial init script doesn’t work even. If I modify the script to echo ${INTFTP_OPTS} it shows the options that I want, however, it won’t work with the variable. If a replace ${INTFTP_OPTS} with the actual parameters «-l -s /tftpboot» in /etc/init.d/in.tftpd it will work fine. When I use xinetd it with the config listed above it won’t work. I’ve tried adding «>& /root/tftpd.err.log to catch any errors that might be causing /etc/init.d/in.tftpd to not work when I use the variable, it creates the file, but doesn’t put anything in it!
Has anyone figured this out? Is there a bug for it yet? Laterz- |
n00b
Joined: 02 Jun 2004
Posts: 68
|
|
|
|
I don’t know anymore what I did, but somehow it works now. I think after installing I just had to restart the adequate service.
tom |
Tux’s lil’ helper
Joined: 30 May 2005
Posts: 82
|
|
|
|
Gee that doesnt really help us out the peopl who are not reading these posts to find the solution I had the same problem Does anyone else hav to do this? to tftp without creating the file first and changing the permissions |
n00b
Joined: 07 Nov 2002
Posts: 50
|
|
|
|
i had the same problem at first, but found a workaround:
for example i want to save router.confg i first make on the tftpserver an empty textfile router.confg which gets a nice chmod 777 over it. After that i save the config from the router on the tftp, for some weird reason that seems to work out pretty fine (though it is a workaround, don’t know the real issue) |
Tux’s lil’ helper
Joined: 14 Jan 2003
Posts: 127
Tux’s lil’ helper
Joined: 12 Aug 2002
Posts: 145
|
||
|
||
Old topic, yes, but since I just ran into the same permissions problem I thought I would post what fixed this for me. All I had to do is add the «-p» option to the server arguments. -p forces the tftpd daemon to only pay attention to the file permissions to determine whether a file can be read/written.
My /etc/xinetd.d/tftp file looks like this:
|
Display posts from previous:
Binary package hint: tftp-hpa
I’ve just upgraded a rarp/bootp/tftp PXE server that hosts bootable images for the LAN from Karmic to Lucid using:
do-release-upgrade -d
Prior to the upgrade it worked fine. After the upgrade PXE clients report:
Only absolute filename allowed
TFTP Error — Access Violation
Running a network sniffing session I see:
sudo tcpdump -ni eth0 -v -T tftp ‘udp’
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
18:14:33.056751 IP (tos 0x0, ttl 20, id 2, offset 0, flags [none], proto UDP (17), length 55)
10.254.251.95.2070 > 10.254.251.2.69: 27 RRQ «pxelinux.0» octet tsize 0
18:14:33.062219 IP (tos 0x0, ttl 64, id 9743, offset 0, flags [none], proto UDP (17), length 64)
10.254.251.2.48777 > 10.254.251.95.2070: 36 ERROR EACCESS «Only absolute filenames allowed»
18:14:33.063885 IP (tos 0x0, ttl 20, id 3, offset 0, flags [none], proto UDP (17), length 60)
10.254.251.95.2071 > 10.254.251.2.69: 32 RRQ «pxelinux.0» octet blksize 1456
18:14:33.069505 IP (tos 0x0, ttl 64, id 9744, offset 0, flags [none], proto UDP (17), length 64)
10.254.251.2.39907 > 10.254.251.95.2071: 36 ERROR EACCESS «Only absolute filenames allowed»